Class TGLWindowNavigated

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type TGLWindowNavigated = class(TGLWindowDemo)

Description

This class has a Navigator property (TMatrixNavigator instance) and handles some usual things related to using TMatrixNavigator instance with TGLWindow window.

  1. Po pierwsze, pole Navigator jest swobodne do odczytu i zapisu. Mozesz w dowolnym momencie wymieniac uzywany tutaj Navigator. Domyslnie Navigator = nil. W Destroy klasy jezeli OwnsNavigator (domyslnie true) robimy Navigator.Free.

  2. W metodach Event Idle/KeyPress, w AllowsProcessMessageSuspend zajmujemy sie wywolywaniem odpowiednich metod z Navigator, o ile tylko Navigator <> nil i UseNavigator = true. Oh, and we use IdleCompSpeed for navigator.

  3. Metoda PostRedisplayOnMatrixChanged nie jest tu nigdzie uzywana ale mozesz ja podac jako TMatrixChangedFunc przy tworzeniu Navigatora. Wywoluje ona po prostu PostRediplay. (Jezeli chcesz robic cos innego w reakcji na MatrixChanged to naturalnie nie musisz uzywac PostRedisplayOnMatrixChanged.)

  4. This will also helps you use MouseLook feature of TMatrixWalker: This will call MouseMove of Navigator with a suitable parameters, and this gives you UpdateMouseLook method that you should use. All that remains to you is to call UpdateMouseLook at appropriate times, and mouse look will work.

Typical use of this class:

  1. na poczatku programu

      glw.Navigator := TMatrix<...>.Create(glw.PostRedisplayOnMatrixChanged);
      glw.Navigator.Init(...);
    

  2. w OnDraw uzyj gdzies glMultMatrix/glLoadMatrix(glw.Navigator.Matrix)

And that's all.

Hierarchy

Overview

Methods

Public constructor Create;
Public destructor Destroy; override;
Public function NavExaminer: TMatrixExaminer;
Public function NavWalker: TMatrixWalker;
Public procedure PostRedisplayOnMatrixChanged(ChangedNavigator: TMatrixNavigator);
Public procedure EventInit; override;
Public procedure EventKeyDown(key: TKey; c: char); override;
Public procedure EventIdle; override;
Public procedure EventMouseDown(Button: TMouseButton); override;
Public procedure EventMouseMove(NewX, NewY: Integer); override;
Public function AllowsProcessMessageSuspend: boolean; override;
Public procedure Ray(const WindowX, WindowY: Integer; const ViewAngleDegX, ViewAngleDegY: Single; out Ray0, RayVector: TVector3Single);
Public procedure MousePickedRay( const ViewAngleDegX, ViewAngleDegY: Single; out Ray0, RayVector: TVector3Single);
Public procedure UpdateMouseLook;

Properties

Public property Navigator: TMatrixNavigator read FNavigator write FNavigator;
Public property OwnsNavigator: boolean read FOwnsNavigator write FOwnsNavigator default true;
Public property UseNavigator: boolean read FUseNavigator write FUseNavigator default true;

Description

Methods

Public constructor Create;
 
Public destructor Destroy; override;
 
Public function NavExaminer: TMatrixExaminer;

These are shortcuts for writing TMatrixExaminer(Navigator) and TMatrixWalker(Navigator). In DEBUG version they use operator "as" but in RELEASE version they use direct type-casts for speed.

Public function NavWalker: TMatrixWalker;
 
Public procedure PostRedisplayOnMatrixChanged(ChangedNavigator: TMatrixNavigator);
 
Public procedure EventInit; override;
 
Public procedure EventKeyDown(key: TKey; c: char); override;
 
Public procedure EventIdle; override;
 
Public procedure EventMouseDown(Button: TMouseButton); override;
 
Public procedure EventMouseMove(NewX, NewY: Integer); override;
 
Public function AllowsProcessMessageSuspend: boolean; override;
 
Public procedure Ray(const WindowX, WindowY: Integer; const ViewAngleDegX, ViewAngleDegY: Single; out Ray0, RayVector: TVector3Single);

Calculate a ray picked by WindowX, WindowY position on the window. Use this only when Navigator <> nil and Navigator is TMatrixWalker.

ViewAngleDegX, ViewAngleDegY are your camera view angles.

WindowX, WindowY are given in the same style as MouseX, MouseY: WindowX = 0 is left, WindowY = 0 is top.

This uses PrimaryRay call.

Public procedure MousePickedRay( const ViewAngleDegX, ViewAngleDegY: Single; out Ray0, RayVector: TVector3Single);

Calculate a ray corresponding to current Navigator (must be TMatrixWalker instance) settings and MouseX, MouseY position on the screen.

This is actually just a shortcut for Ray, passing MouseX, MouseY as WindowX, WindowY.

Public procedure UpdateMouseLook;

If you use Navigator of class TMatrixWalker with this window and you want to use it's MouseLook feature then you should call this after you changed Navigator.MouseLook value.

This sets Cursor (to gcNone or gcDefault, based on whether mouse look is used now, that is Navigator.MouseLook is True) and, if mouse look is used, repositions mouse cursor at the middle of the window.

TODO: when the need will be, cursor will not be so carelessly changed to gcDefault.

You should also call this after you changed Navigator's instance, or UseNavigator, as these things also effectively change the actual state of "using mouse look". OTOH sometimes you don't have to call this — e.g. if you push/pop mode states using TGLMode and in the mode you set temporary UseNavigator = False, then you don't have to call this, because TGLMode will push/pop Cursor state anyway. That's why I explicitly wrote above what this function does (sets Cursor and repositions the mouse) — so that you can figure out where exactly you have to use it.

Properties

Public property Navigator: TMatrixNavigator read FNavigator write FNavigator;

Navigator instance used. Initially it's nil.

Public property OwnsNavigator: boolean read FOwnsNavigator write FOwnsNavigator default true;
 
Public property UseNavigator: boolean read FUseNavigator write FUseNavigator default true;

jezeli not UseNavigator albo Navigator = nil to to okienko bedzie sie zachowywalo jakby wcale nie bylo TGLWindowNavigated. Wszystkie metody Event* beda wywolywaly po prostu inherited; i nic wiecej nie beda robic


Generated by PasDoc 0.10.0 on 2008-02-25 00:00:31