Class TCastleCamera
Unit
Declaration
type TCastleCamera = class(TCastleTransform)
Description
Camera determines viewer position and orientation in the viewport.
You can create instances of this class yourself, and add them to TCastleViewport.Items, and set them as TCastleViewport.Camera.
Note that this class does not handle any user input to modify the camera. For this, see TCastleNavigation descendants.
Hierarchy
- TObject
- TPersistent
- TComponent
- TCastleComponent
- TCastleTransform
- TCastleCamera
Overview
Fields
InternalOnSceneBoundViewpointChanged: TNotifyEvent; |
|
InternalOnSceneBoundViewpointVectorsChanged: TNotifyEvent; |
|
InternalOnSceneBoundNavigationInfoChanged: TNotifyEvent; |
|
InternalOnCameraChanged: TNotifyEvent; |
Methods
constructor Create(AOwner: TComponent); override; |
|
destructor Destroy; override; |
|
procedure Assign(Source: TPersistent); override; |
|
function PropertySections(const PropertyName: String): TPropertySections; override; |
|
procedure LocalRender(const Params: TRenderParams); override; |
|
procedure CustomSerialization(const SerializationProcess: TSerializationProcess); override; |
|
function Matrix: TMatrix4; |
|
function MatrixInverse: TMatrix4; |
|
function RotationMatrix: TMatrix4; |
|
procedure CustomRay( const ViewportRect: TFloatRectangle; const WindowPosition: TVector2; const Projection: TProjection; out RayOrigin, RayDirection: TVector3); |
|
procedure AnimateTo(const OtherCamera: TCastleCamera; const Time: TFloatTime); overload; |
|
procedure AnimateTo(const APos, ADir, AUp: TVector3; const Time: TFloatTime); overload; |
|
function Animation: boolean; |
|
procedure Init(const AInitialPosition, AInitialDirection, AInitialUp, AGravityUp: TVector3); deprecated 'use SetWorldView, set GravityUp directly'; |
|
procedure Update(const SecondsPassed: Single; var RemoveMe: TRemoveType); override; |
|
function EffectiveProjectionNear: Single; |
|
function EffectiveProjectionFar: Single; |
|
procedure VisibleChangeHere(const Changes: TVisibleChanges); override; |
Properties
property GravityUp: TVector3 read FGravityUp write SetGravityUp; |
|
property Frustum: TFrustum read FFrustum; |
|
property ProjectionMatrix: TMatrix4
read FProjectionMatrix write SetProjectionMatrix; |
|
property Orientation default TCastleTransform.DefaultCameraOrientation; |
|
property ProjectionNear: Single read FProjectionNear write SetProjectionNear default 0; |
|
property ProjectionFar: Single read FProjectionFar write SetProjectionFar default 0; |
|
property ProjectionType: TProjectionType
read FProjectionType write SetProjectionType default ptPerspective; |
|
property Perspective: TCastlePerspective read FPerspective; |
|
property Orthographic: TCastleOrthographic read FOrthographic; |
|
property GravityUpPersistent: TCastleVector3Persistent read FGravityUpPersistent ; |
Description
Fields
InternalOnSceneBoundViewpointChanged: TNotifyEvent; |
|
InternalOnSceneBoundViewpointVectorsChanged: TNotifyEvent; |
|
InternalOnSceneBoundNavigationInfoChanged: TNotifyEvent; |
|
InternalOnCameraChanged: TNotifyEvent; |
|
Methods
constructor Create(AOwner: TComponent); override; |
|
destructor Destroy; override; |
|
procedure Assign(Source: TPersistent); override; |
|
function PropertySections(const PropertyName: String): TPropertySections; override; |
|
procedure LocalRender(const Params: TRenderParams); override; |
|
procedure CustomSerialization(const SerializationProcess: TSerializationProcess); override; |
|
function Matrix: TMatrix4; |
|
Camera matrix, transforming from world space into camera space. |
function MatrixInverse: TMatrix4; |
|
Inverse of Matrix, transforming from camera space into world space. |
function RotationMatrix: TMatrix4; |
|
Extract only rotation from your current camera Matrix. This is useful for rendering skybox in 3D programs (e.g. for VRML/X3D Background node) and generally to transform directions between world and camera space. It's guaranteed that this is actually only 3x3 matrix, the 4th row and 4th column are all zero except the lowest right item which is 1.0. |
procedure CustomRay( const ViewportRect: TFloatRectangle; const WindowPosition: TVector2; const Projection: TProjection; out RayOrigin, RayDirection: TVector3); |
|
Calculate a ray picked by WindowPosition position on the viewport, assuming current viewport dimensions are as given. This doesn't look at our container sizes at all. Projection (read-only here) describe projection, required for calculating the ray properly. Resulting RayDirection is always normalized. WindowPosition is given in the same style as TCastleContainer.MousePosition: (0, 0) is bottom-left. |
procedure AnimateTo(const OtherCamera: TCastleCamera; const Time: TFloatTime); overload; |
|
Animate a camera smoothly into another camera settings. This will gradually change our settings (only the most important settings, that determine actual camera view, i.e. Matrix result) into another camera. Current OtherCamera settings will be internally copied during this call. So you can even free OtherCamera instance immediately after calling this. Calling AnimateTo while the previous animation didn't finish yet is OK. This simply cancels the previous animation, and starts the new animation from the current position. |
procedure AnimateTo(const APos, ADir, AUp: TVector3; const Time: TFloatTime); overload; |
|
function Animation: boolean; |
|
Are we currently during animation (caused by AnimateTo). TCastleNavigation descendants may use it to abort normal input handling. E.g. when camera is animating, then the gravity in TCastleWalkNavigation should not work, key/mouse handling in TCastleWalkNavigation shoult not work etc. |
procedure Init(const AInitialPosition, AInitialDirection, AInitialUp, AGravityUp: TVector3); deprecated 'use SetWorldView, set GravityUp directly'; |
|
Warning: this symbol is deprecated: use SetWorldView, set GravityUp directly |
procedure Update(const SecondsPassed: Single; var RemoveMe: TRemoveType); override; |
|
function EffectiveProjectionNear: Single; |
|
Currently used projection near. Derived from ProjectionNear and possibly scene sizes. |
function EffectiveProjectionFar: Single; |
|
Currently used projection far. Derived from ProjectionFar and possibly scene sizes. May be equal ZFarInfinity. |
procedure VisibleChangeHere(const Changes: TVisibleChanges); override; |
|
Properties
property GravityUp: TVector3 read FGravityUp write SetGravityUp; |
|
"Up" direction of the world in which player moves. Always normalized (when setting this property, we take care to normalize the provided vector). This determines in which direction TCastleWalkNavigation.Gravity works. This is also the "normal" value for "up" vector in world coordinates. Navigation uses it, e.g. features like PreferGravityUpForRotations and/or PreferGravityUpForMoving. The default value of this vector is (0, 1, 0) (same as the default Up vector). |
property Frustum: TFrustum read FFrustum; |
|
The current camera (viewing frustum, based on ProjectionMatrix (set by you) and Matrix (calculated here). This is recalculated whenever one of these two properties change. Be sure to set ProjectionMatrix before using this. |
property ProjectionMatrix: TMatrix4
read FProjectionMatrix write SetProjectionMatrix; |
|
Projection matrix of the camera. Camera needs to know this to calculate Frustum, which in turn allows rendering code to use frustum culling. In normal circumstances, if you use TCastleViewport for rendering, this is automatically correctly set for you. |
property Orientation default TCastleTransform.DefaultCameraOrientation; |
|
property ProjectionNear: Single read FProjectionNear write SetProjectionNear default 0; |
|
Projection near plane distance. 0 (default) means to automatically calculate a correct value. Note that automatic calculation differs between perspective projection (uses DefaultCameraRadius, RadiusToProjectionNear for near, and infinity for far) and orthographic projection (adjusts to scene sizes and distance from camera). For perspective projection, values <= 0 are invalid. So both value = 0 and value < 0 behave the same: they indicate we should automatically calculate the effective For orthographic projection, all values are valid and reasonable. So value < 0 is just used literally, it doesn't cause the effective value to be autocalculated. |
property ProjectionFar: Single read FProjectionFar write SetProjectionFar default 0; |
|
Projection far plane distance. 0 (default) means to automatically calculate a correct value. Note that automatic calculation differs between perspective projection (uses DefaultCameraRadius, RadiusToProjectionNear for near, and infinity for far) and orthographic projection (adjusts to scene sizes and distance from camera). |
property ProjectionType: TProjectionType
read FProjectionType write SetProjectionType default ptPerspective; |
|
Perspective or orthographic projection. Depending on it, we either use Perspective or Orthographic settings. |
property Perspective: TCastlePerspective read FPerspective; |
|
Perspective projection properties, used only if ProjectionType is ptPerspective. |
property Orthographic: TCastleOrthographic read FOrthographic; |
|
Orthographic projection properties, used only if ProjectionType is ptOrthographic. |
property GravityUpPersistent: TCastleVector3Persistent read FGravityUpPersistent ; |
|
GravityUp that can be visually edited in Castle Game Engine Editor, Lazarus and Delphi. Normal user code does not need to deal with this, instead read or write GravityUp directly. See also
|
Generated by PasDoc 0.16.0.