Class T3DOrient

Unit

Declaration

type T3DOrient = class(T3DCustomTransform)

Description

Transform other 3D objects by changing their orientation.

The rotation of objects depends on given Direction and Up vectors, see Orientation for details. The translation of objects is just taken from Position, and works just like normal T3DTransform.Translation. There is no scaling of 3D objects, ever.

Hierarchy

Overview

Fields

Public DefaultOrientation: TOrientationType; static;

Methods

Protected procedure TransformMatricesMult(var M, MInverse: TMatrix4Single); override;
Protected function OnlyTranslation: boolean; override;
Protected function GetTranslation: TVector3Single; override;
Protected function GetRotation: TVector4Single; override;
Public constructor Create(AOwner: TComponent); override;
Public destructor Destroy; override;
Public procedure GetView(out APos, ADir, AUp: TVector3Single);
Public procedure SetView(const APos, ADir, AUp: TVector3Single; const AdjustUp: boolean = true);
Public procedure SetView(const ADir, AUp: TVector3Single; const AdjustUp: boolean = true);
Public procedure UpPrefer(const AUp: TVector3Single);
Public procedure Translate(const T: TVector3Single); override;

Properties

Public property Position: TVector3Single read GetPosition write SetPosition;
Public property Direction: TVector3Single read GetDirection write SetDirection;
Public property Up: TVector3Single read GetUp write SetUp;
Public property Orientation: TOrientationType read FOrientation write FOrientation;
Public property Camera: TWalkCamera read FCamera;

Description

Fields

Public DefaultOrientation: TOrientationType; static;

Default value of T3DOrient.Orientation, for new instances of T3DOrient (creatures, items, player etc.).

Methods

Protected procedure TransformMatricesMult(var M, MInverse: TMatrix4Single); override;
 
Protected function OnlyTranslation: boolean; override;
 
Protected function GetTranslation: TVector3Single; override;
 
Protected function GetRotation: TVector4Single; override;
 
Public constructor Create(AOwner: TComponent); override;
 
Public destructor Destroy; override;
 
Public procedure GetView(out APos, ADir, AUp: TVector3Single);

Get at once vectors: position, direction, up.

Public procedure SetView(const APos, ADir, AUp: TVector3Single; const AdjustUp: boolean = true);

Set at once vectors: position, direction, up.

ADir and AUp given here do not have to be normalized (they will be normalized if needed). They will be automatically fixed to be orthogonal, if necessary: when AdjustUp = True (the default) we will adjust the up vector (preserving the given direction value), otherwise we will adjust the direction (preserving the given up value).

Public procedure SetView(const ADir, AUp: TVector3Single; const AdjustUp: boolean = true);
 
Public procedure UpPrefer(const AUp: TVector3Single);

Change up vector, keeping the direction unchanged. If necessary, the up vector provided here will be fixed to be orthogonal to direction.

This is similar to assigning Up vector using it's property setter, but different behavior happens when we need to fix vectors to have direction orthogonal to up (which must be always true). In case of assigning Up by property setter, the Direction vector is changed (if necessary, to be orthogonal to up). In case of this method, the up vector is changed (if necessary, to be orthogonal to direction).

It's good to use this if you have a preferred up vector for creatures, but still preserving the direction vector has the highest priority.

Public procedure Translate(const T: TVector3Single); override;
 

Properties

Public property Position: TVector3Single read GetPosition write SetPosition;

Position (translation) of this 3D object.

Public property Direction: TVector3Single read GetDirection write SetDirection;

Direction the creature is facing, and up vector.

The Direction and Up vectors should always be normalized (have length 1). When setting them by these properties, we will normalize them automatically.

They must also always be orthogonal. When setting Direction, Up will always be automatically adjusted to be orthogonal to Direction. And vice versa — when setting Up, Direction will be adjusted.

Initially, they follow VRML/X3D standard vectors suitable for gravity along the Y axis. So direction is -Z (DefaultCameraDirection), up is +Y (DefaultCameraUp).

Public property Up: TVector3Single read GetUp write SetUp;
 
Public property Orientation: TOrientationType read FOrientation write FOrientation;

How the direction and up vectors determine transformation. See TOrientationType for values documentation.

The default value of this is determined by static variable DefaultOrientation, this is usually comfortable (because almost always you use the same Orientation throughout your game). By default it's otUpYDirectionMinusZ (matching default cameras of OpenGL and VRML/X3D).

This value determines how you should model your 3D models, like the creatures, the items, and the player weapons. Generally, it applies to every 3D model that is used as a child of this T3DOrient instance.

Public property Camera: TWalkCamera read FCamera;

Camera, with view vectors (position, direction and up) always synchronized with this T3DOrient instance. You should not set Camera vectors (by TWalkCamera.Position, TWalkCamera.SetView and such) directly, instead use this object's properties (T3DOrient.Position, T3DOrient.SetView), as we will call proper VisibleChangeHere method.

We don't deal with any other camera properties in T3DOrient. If you want, you can ignore this camera (you will probably do this if you use T3DOrient for creature like TCastleCreature; although camera may still have a fun usage then, for observing world from a creature view). Or you can use this camera, taking care of all it's settings, even asssigning this camera to TCastleSceneManager.Camera to allow user to directly control it (you will probably do this if you use T3DOrient for player like TPlayer; in fact, TGameSceneManager.LoadLevel does this automatically for you).


Generated by PasDoc 0.14.0.