Class TCastleAbstractRootTransform

Unit

Declaration

type TCastleAbstractRootTransform = class(TCastleTransform)

Description

Root of transformations and scenes (tree of TCastleTransform and TCastleScene). This is the base abstract class, the non-abstract descendant is TCastleRootTransform.

Hierarchy

Overview

Fields

Public OnCursorChange: TNotifyEvent;
Public InternalVisibleStateId: TFrameId;
Public InternalVisibleGeometryStateId: TFrameId;
Public InternalVisibleNonGeometryStateId: TFrameId;

Methods

Public constructor Create(AOwner: TComponent); override;
Public destructor Destroy; override;
Public procedure Update(const SecondsPassed: Single; var RemoveMe: TRemoveType); override;
Public function GravityCoordinate: Integer;
Public function GravityUp: TVector3;
Public function WorldMoveAllowed( const OldPos, ProposedNewPos: TVector3; out NewPos: TVector3; const IsRadius: boolean; const Radius: Single; const OldBox, NewBox: TBox3D; const BecauseOfGravity: boolean): boolean; overload;
Public function WorldMoveAllowed( const OldPos, NewPos: TVector3; const IsRadius: boolean; const Radius: Single; const OldBox, NewBox: TBox3D; const BecauseOfGravity: boolean): boolean; overload;
Public function WorldHeight(const APosition: TVector3; out AboveHeight: Single; out AboveGround: PTriangle): boolean;
Public function WorldLineOfSight(const Pos1, Pos2: TVector3): boolean;
Public function WorldRay(const RayOrigin, RayDirection: TVector3): TRayCollision;
Public function WorldRayCast(const RayOrigin, RayDirection: TVector3; out Distance: Single): TCastleTransform;
Public function WorldRayCast(const RayOrigin, RayDirection: TVector3): TCastleTransform;
Public function WorldBoxCollision(const Box: TBox3D): boolean;
Public function WorldSegmentCollision(const Pos1, Pos2: TVector3): boolean;
Public function WorldSphereCollision(const Pos: TVector3; const Radius: Single): boolean;
Public function WorldSphereCollision2D(const Pos: TVector2; const Radius: Single; const Details: TCollisionDetails = nil): boolean;
Public function WorldPointCollision2D(const Point: TVector2): boolean;
Public function CameraPosition: TVector3; deprecated 'use MainCamera.Position if MainCamera <> nil';
Public function CameraDirection: TVector3; deprecated 'use MainCamera.Direction if MainCamera <> nil';
Public function CameraUp: TVector3; deprecated 'use MainCamera.Up if MainCamera <> nil';
Public function CameraGravityUp: TVector3; deprecated 'use MainCamera.GravityUp if MainCamera <> nil';
Public function CameraKnown: Boolean; deprecated 'use MainCamera <> nil';

Properties

Public property EnablePhysics: boolean read FEnablePhysics write FEnablePhysics default true;
Public property MoveLimit: TBox3D read FMoveLimit write FMoveLimit;
Public property MainCamera: TCastleCamera read FMainCamera write SetMainCamera;
Published property PhysicsProperties: TPhysicsProperties read FPhysicsProperties;
Published property TimeScale: Single read FTimeScale write FTimeScale default 1;
Published property Paused: boolean read FPaused write SetPaused default false;

Description

Fields

Public OnCursorChange: TNotifyEvent;
 
Public InternalVisibleStateId: TFrameId;

Latest frame when VisibleChangeNotification was called (with any params, even empty).

Public InternalVisibleGeometryStateId: TFrameId;

Latest frame when VisibleChangeNotification was called (with vcVisibleGeometry).

Public InternalVisibleNonGeometryStateId: TFrameId;

Latest frame when VisibleChangeNotification was called (with vcVisibleNonGeometry).

Methods

Public constructor Create(AOwner: TComponent); override;
 
Public destructor Destroy; override;
 
Public procedure Update(const SecondsPassed: Single; var RemoveMe: TRemoveType); override;
 
Public function GravityCoordinate: Integer;

The major axis of gravity vector: 0, 1 or 2. This is trivially derived from the known camera GravityUp value. It can only truly express GravityUp vector values (1,0,0) or (0,1,0) or (0,0,1), although in practice this is enough for normal games (normal 3D scenes use up either +Y or +Z).

We try to avoid using it in the engine, and use full GravityUp vector wherever possible. Full GravityUp vector may allow for more fun with weird gravity in future games.

Public function GravityUp: TVector3;
 
Public function WorldMoveAllowed( const OldPos, ProposedNewPos: TVector3; out NewPos: TVector3; const IsRadius: boolean; const Radius: Single; const OldBox, NewBox: TBox3D; const BecauseOfGravity: boolean): boolean; overload;

Is the move from OldPos to ProposedNewPos possible. Returns true and sets NewPos if some move is allowed, thus allows for wall-sliding.

This checks collisions with world (everything inside this TCastleAbstractRootTransform).

This checks collision with all objects that have Collides and Exists equal True. To be more exact, it checks GetCollides virtual method, which by default returns Collides property and GetExists, and GetExists in turn by default checks Exists property and whether the object is not between Disable and Enable.

If your query originates from some existing TCastleTransform instance, you should prefer to instead use TCastleTransform.MoveAllowed method, that automatically prevents "collisions with yourself".

See also
TCastleTransform.MoveAllowed
Is the move from OldPos to NewPos possible for this object.
Public function WorldMoveAllowed( const OldPos, NewPos: TVector3; const IsRadius: boolean; const Radius: Single; const OldBox, NewBox: TBox3D; const BecauseOfGravity: boolean): boolean; overload;

Is the move from OldPos to NewPos possible.

This checks collisions with world (everything inside this TCastleAbstractRootTransform).

This checks collision with all objects that have Collides and Exists equal True. To be more exact, it checks GetCollides virtual method, which by default returns Collides property and GetExists, and GetExists in turn by default checks Exists property and whether the object is not between Disable and Enable.

If your query originates from some existing TCastleTransform instance, you should prefer to instead use TCastleTransform.MoveAllowed method, that automatically prevents "collisions with yourself".

See also
TCastleTransform.MoveAllowed
Is the move from OldPos to NewPos possible for this object.
Public function WorldHeight(const APosition: TVector3; out AboveHeight: Single; out AboveGround: PTriangle): boolean;

Get height of point APosition above the world. Looks at current MainCamera to know the gravity direction.

This checks collisions with world (everything inside this TCastleAbstractRootTransform).

This checks collision with all objects that have Collides and Exists equal True. To be more exact, it checks GetCollides virtual method, which by default returns Collides property and GetExists, and GetExists in turn by default checks Exists property and whether the object is not between Disable and Enable.

If your query originates from some existing TCastleTransform instance, you should prefer to instead use TCastleTransform.MoveAllowed method, that automatically prevents "collisions with yourself".

Public function WorldLineOfSight(const Pos1, Pos2: TVector3): boolean;

Check that the line segment between 2 points that not collide with anything (that has opaque material).

This checks collisions with world (everything inside this TCastleAbstractRootTransform).

This checks collision with all objects that have Collides and Exists equal True. To be more exact, it checks GetCollides virtual method, which by default returns Collides property and GetExists, and GetExists in turn by default checks Exists property and whether the object is not between Disable and Enable.

Public function WorldRay(const RayOrigin, RayDirection: TVector3): TRayCollision;

What is hit by this ray.

This checks collisions with world (everything inside this TCastleAbstractRootTransform).

This checks collision with all objects that have Collides and Exists equal True. To be more exact, it checks GetCollides virtual method, which by default returns Collides property and GetExists, and GetExists in turn by default checks Exists property and whether the object is not between Disable and Enable.

Public function WorldRayCast(const RayOrigin, RayDirection: TVector3; out Distance: Single): TCastleTransform;

What is hit by this ray. Returns the TCastleTransform that is hit (this is the "leaf" TCastleTransform in the TCastleTransform tree that is hit) and a distance from RayOrigin to the hit point. Returns Nil (Distance is undefined in this case) if nothing was hit. Use WorldRay for a more advanced version of this, with more complicated result.

Public function WorldRayCast(const RayOrigin, RayDirection: TVector3): TCastleTransform;
 
Public function WorldBoxCollision(const Box: TBox3D): boolean;

Check whether something collides with axis-aligned box in 3D.

This checks collisions with world (everything inside this TCastleAbstractRootTransform).

This checks collision with all objects that have Collides and Exists equal True. To be more exact, it checks GetCollides virtual method, which by default returns Collides property and GetExists, and GetExists in turn by default checks Exists property and whether the object is not between Disable and Enable.

Public function WorldSegmentCollision(const Pos1, Pos2: TVector3): boolean;

Check whether something collides with a line segment.

This checks collisions with world (everything inside this TCastleAbstractRootTransform).

This checks collision with all objects that have Collides and Exists equal True. To be more exact, it checks GetCollides virtual method, which by default returns Collides property and GetExists, and GetExists in turn by default checks Exists property and whether the object is not between Disable and Enable.

Public function WorldSphereCollision(const Pos: TVector3; const Radius: Single): boolean;

Check whether something collides with a sphere.

This checks collisions with world (everything inside this TCastleAbstractRootTransform).

This checks collision with all objects that have Collides and Exists equal True. To be more exact, it checks GetCollides virtual method, which by default returns Collides property and GetExists, and GetExists in turn by default checks Exists property and whether the object is not between Disable and Enable.

Public function WorldSphereCollision2D(const Pos: TVector2; const Radius: Single; const Details: TCollisionDetails = nil): boolean;

Check whether something collides with a sphere in 2D (a circle, extruded to infinity along the Z axis).

This checks collisions with world (everything inside this TCastleAbstractRootTransform).

This checks collision with all objects that have Collides and Exists equal True. To be more exact, it checks GetCollides virtual method, which by default returns Collides property and GetExists, and GetExists in turn by default checks Exists property and whether the object is not between Disable and Enable.

Public function WorldPointCollision2D(const Point: TVector2): boolean;

Check whether something collides with a point in 2D (which is an infinite line along the Z axis in 3D).

This checks collisions with world (everything inside this TCastleAbstractRootTransform).

This checks collision with all objects that have Collides and Exists equal True. To be more exact, it checks GetCollides virtual method, which by default returns Collides property and GetExists, and GetExists in turn by default checks Exists property and whether the object is not between Disable and Enable.

Public function CameraPosition: TVector3; deprecated 'use MainCamera.Position if MainCamera <> nil';

Warning: this symbol is deprecated: use MainCamera.Position if MainCamera <> nil

 
Public function CameraDirection: TVector3; deprecated 'use MainCamera.Direction if MainCamera <> nil';

Warning: this symbol is deprecated: use MainCamera.Direction if MainCamera <> nil

 
Public function CameraUp: TVector3; deprecated 'use MainCamera.Up if MainCamera <> nil';

Warning: this symbol is deprecated: use MainCamera.Up if MainCamera <> nil

 
Public function CameraGravityUp: TVector3; deprecated 'use MainCamera.GravityUp if MainCamera <> nil';

Warning: this symbol is deprecated: use MainCamera.GravityUp if MainCamera <> nil

 
Public function CameraKnown: Boolean; deprecated 'use MainCamera <> nil';

Warning: this symbol is deprecated: use MainCamera <> nil

 

Properties

Public property EnablePhysics: boolean read FEnablePhysics write FEnablePhysics default true;

Yoo can temporarily disable physics (no transformations will be updated by the physics engine) by setting this property to False.

Public property MoveLimit: TBox3D read FMoveLimit write FMoveLimit;

Limit the movement allowed by WorldMoveAllowed. Ignored when empty (default).

This property allows to easily limit the possible places where player and creatures go. Player is honoring this if it uses WorldMoveAllowed, in particular our TCastleWalkNavigation navigation honors it. Creatures honor it if they use WorldMoveAllowed for their decision, in particular all creatures in CastleCreatures use it.

Note that the TLevel.Load always assigns this property to be non-empty. It either determines it by CasMoveLimit placeholder in the level 3D model, or by calculating to include level bounding box + some space for flying.

Public property MainCamera: TCastleCamera read FMainCamera write SetMainCamera;

Central camera, that controls the features that require a single "main" camera (features that do not make sense with multiple cameras from multiple viewports).

This camera controls:

- the X3D nodes that "sense" camera like ProximitySensor, Billboard, LOD. - an audio listener (controlling the spatial sound). - the headlight position/direction. - when X3D nodes change Viewport/NavigationInfo, they apply these changes to this camera.

Note that it means that "headlight" is assigned to one camera in case of multiple viewports looking at the same world. You cannot have a different "headlight" in each viewport, this would cause subtle problems since it's not how it would work in reality (where every light is visible in all viewports), e.g. mirror textures (like GeneratedCubeMapTexture) would need different contents in different viewpoints.

Note that features like LOD or Billboard or ProximitySensor need to transform this camera to scene local space. Which is not possible if the same scene instance is used multiple times (e.g. under many different TCastleTransform parents). If you need to use these features of TCastleScene, then simply do not use the same scene reference multiple times (instead clone the scene by TCastleScene.Clone).

By default this is set to TCastleViewport.Camera of the TCastleViewport that created this TCastleAbstractRootTransform instance. So in simple cases (when you just create one TCastleViewport and add your scenes to it's already-created TCastleViewport.Items) you don't have to do anything, it just works. In general, you can change this to any camera of any associated TCastleViewport, or Nil (in case no camera should be that "central" camera).

Published property PhysicsProperties: TPhysicsProperties read FPhysicsProperties;

Adjust physics behaviour.

Published property TimeScale: Single read FTimeScale write FTimeScale default 1;

Time scale used when not Paused.

Published property Paused: boolean read FPaused write SetPaused default false;

Pausing means that no events (key, mouse, update) are processed. So time doesn't move, and input is not processed.

Navigation also doesn't work (this part is implemented by TCastleViewport and each TCastleNavigation).

This is useful if you want to unconditionally make your world temporary still (for example, useful when entering some modal dialog box and you want the world to behave as a still background).

See also: For other pausing methods, there are other methods of pausing / disabling some events processing for the world:

  • You can set TCastleScene.TimePlaying to False. This is roughly equivalent to not running their Update methods. This means that time will "stand still" for them, so their animations will not play. Although they may still react and change in response to mouse clicks / key presses, if TCastleScene.ProcessEvents.

  • You can set TCastleScene.ProcessEvents to False. This means that scene will not receive and process any key / mouse and other events (through VRML/X3D sensors). Some animations (not depending on VRML/X3D events processing) may still run, for example MovieTexture will still animate, if only TCastleScene.TimePlaying.

  • For navigation, you can set TCastleNavigation.Input := [] to ignore key / mouse clicks.

    Or you can set TCastleNavigation.Exists to False, this is actually equivalent to what pausing does now for TCastleNavigation.


Generated by PasDoc 0.15.0.