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

Overview

Fields

Public InternalOnSceneBoundViewpointChanged: TNotifyEvent;
Public InternalOnSceneBoundViewpointVectorsChanged: TNotifyEvent;
Public InternalOnSceneBoundNavigationInfoChanged: TNotifyEvent;
Public InternalOnCameraChanged: TNotifyEvent;

Methods

Public constructor Create(AOwner: TComponent); override;
Public destructor Destroy; override;
Public procedure Assign(Source: TPersistent); override;
Public function PropertySections(const PropertyName: String): TPropertySections; override;
Public procedure DesignerInfo(const SList: TStrings); override;
Public procedure LocalRender(const Params: TRenderParams); override;
Public procedure CustomSerialization(const SerializationProcess: TSerializationProcess); override;
Public function Matrix: TMatrix4;
Public function MatrixInverse: TMatrix4;
Public function RotationMatrix: TMatrix4;
Public procedure CustomRay( const ViewportRect: TFloatRectangle; const WindowPosition: TVector2; const Projection: TProjection; out RayOrigin, RayDirection: TVector3);
Public procedure AnimateTo(const OtherCamera: TCastleCamera; const Time: TFloatTime); overload;
Public procedure AnimateTo(const APos, ADir, AUp: TVector3; const Time: TFloatTime); overload;
Public function Animation: boolean;
Public procedure Init(const AInitialPosition, AInitialDirection, AInitialUp, AGravityUp: TVector3); deprecated 'use SetWorldView, set GravityUp directly';
Public procedure Update(const SecondsPassed: Single; var RemoveMe: TRemoveType); override;
Public function EffectiveProjectionNear: Single;
Public function EffectiveProjectionFar: Single;
Public procedure VisibleChangeHere(const Changes: TVisibleChanges); override;

Properties

Public property GravityUp: TVector3 read FGravityUp write SetGravityUp;
Public property Frustum: TFrustum read FFrustum;
Public property ProjectionMatrix: TMatrix4 read FProjectionMatrix write SetProjectionMatrix;
Public property Orientation default TCastleTransform.DefaultCameraOrientation;
Published property ProjectionNear: Single read FProjectionNear write SetProjectionNear default 0;
Published property ProjectionFar: Single read FProjectionFar write SetProjectionFar default 0;
Published property ProjectionType: TProjectionType read FProjectionType write SetProjectionType default ptPerspective;
Published property Perspective: TCastlePerspective read FPerspective;
Published property Orthographic: TCastleOrthographic read FOrthographic;
Published property GravityUpPersistent: TCastleVector3Persistent read FGravityUpPersistent ;

Description

Fields

Public InternalOnSceneBoundViewpointChanged: TNotifyEvent;

This item has no description.

Public InternalOnSceneBoundViewpointVectorsChanged: TNotifyEvent;

This item has no description.

Public InternalOnSceneBoundNavigationInfoChanged: TNotifyEvent;

This item has no description.

Public InternalOnCameraChanged: TNotifyEvent;

This item has no description.

Methods

Public constructor Create(AOwner: TComponent); override;

This item has no description.

Public destructor Destroy; override;

This item has no description.

Public procedure Assign(Source: TPersistent); override;

This item has no description.

Public function PropertySections(const PropertyName: String): TPropertySections; override;

This item has no description. Showing description inherited from TCastleComponent.PropertySections.

Section where to show property in the editor.

Public procedure DesignerInfo(const SList: TStrings); override;

This item has no description. Showing description inherited from TCastleComponent.DesignerInfo.

Override to add information that should be visible at design-time. Call SList.Add for each new line of information.

Public procedure LocalRender(const Params: TRenderParams); override;

This item has no description. Showing description inherited from TCastleTransform.LocalRender.

Render with given Params (includes a full transformation of this scene).

This is mostly an internal method. You should not need to override it during normal engine usage. Instead, you should render everything using TCastleScene, which allows to load or build (by code) nodes to display meshes, light and everything else. But overriding this may be useful for special customized rendering.

Public procedure CustomSerialization(const SerializationProcess: TSerializationProcess); override;

This item has no description. Showing description inherited from TCastleComponent.CustomSerialization.

Override this method to call various methods of SerializationProcess, which in turn allows to serialize/deserialize things that are not published. This allows to serialize/deserialize with more freedom, e.g. to serialize/deserialize some private field.

Public function Matrix: TMatrix4;

Camera matrix, transforming from world space into camera space.

Public function MatrixInverse: TMatrix4;

Inverse of Matrix, transforming from camera space into world space.

Public 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.

Public 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.

Public procedure AnimateTo(const OtherCamera: TCastleCamera; const Time: TFloatTime); overload;

Animate a camera smoothly into another camera settings. This will gradually change our settings (position, direction, up) to match the target vectors (in world coordinate space).

If you use overload with OtherCamera: 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.

Check Animation to see if we're currently during the camera animation.

Public procedure AnimateTo(const APos, ADir, AUp: TVector3; const Time: TFloatTime); overload;

This item has no description.

Public function Animation: boolean;

Are we currently during animation (caused by AnimateTo).

Public procedure Init(const AInitialPosition, AInitialDirection, AInitialUp, AGravityUp: TVector3); deprecated 'use SetWorldView, set GravityUp directly';

Warning: this symbol is deprecated: use SetWorldView, set GravityUp directly

This item has no description.

Public procedure Update(const SecondsPassed: Single; var RemoveMe: TRemoveType); override;

This item has no description. Showing description inherited from TCastleTransform.Update.

Continuously occuring event, for various tasks.

Executed only on instances that have Exists (no need to check this in overridden Update implementation).

Public function EffectiveProjectionNear: Single;

Currently used projection near. Derived from ProjectionNear and possibly scene sizes.

Public function EffectiveProjectionFar: Single;

Currently used projection far. Derived from ProjectionFar and possibly scene sizes. May be equal ZFarInfinity.

Public procedure VisibleChangeHere(const Changes: TVisibleChanges); override;

This item has no description. Showing description inherited from TCastleTransform.VisibleChangeHere.

Something visible changed inside this object. This is usually called by implementation of this object, to notify others that it changed.

Changes is a set describing what changes occurred. See TVisibleChange docs for more information. It must specify all things that possibly changed.

Changes can be [], meaning "something tells us to redraw, but no visible change happened yet, maybe something will happen during a redraw" (this is used when e.g. possibly LOD level changed). We still increase TCastleAbstractRootTransform.InternalVisibleStateId even when Changes=[].

The information about visibility changed is passed to TCastleAbstractRootTransform in World. It increases TCastleAbstractRootTransform.InternalVisibleStateId, TCastleAbstractRootTransform.InternalVisibleGeometryStateId, TCastleAbstractRootTransform.InternalVisibleNonGeometryStateId. If you want to react to visibility changes, you should not override this method, instead watch above "state id" variables and react when they change.

Properties

Public 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).

Public 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.

Public 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.

Public property Orientation default TCastleTransform.DefaultCameraOrientation;

This item has no description. Showing description inherited from TCastleTransform.Orientation.

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

The default value of this is:

This value determines how you should model your 3D models, like the creatures, the items, and the player weapons.

Published 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 ProjectionNear.

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.

Published 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).

Published property ProjectionType: TProjectionType read FProjectionType write SetProjectionType default ptPerspective;

Perspective or orthographic projection. Depending on it, we either use Perspective or Orthographic settings.

Published property Perspective: TCastlePerspective read FPerspective;

Perspective projection properties, used only if ProjectionType is ptPerspective.

Published property Orthographic: TCastleOrthographic read FOrthographic;

Orthographic projection properties, used only if ProjectionType is ptOrthographic.

Published 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
GravityUp
"Up" direction of the world in which player moves.

Generated by PasDoc 0.16.0-snapshot.