Class TCastleTransform
Unit
Declaration
type TCastleTransform = class(TCastleComponent)
Description
Group and transform (move, rotate, scale) children objects.
Add and remove children using the Add, Remove and similar methods. A child can be any TCastleTransform instance, in particular it can be a TCastleScene instance (which allows to load and render any 3D or 2D model).
Control the transformation using these properties:
Move using Translation.
Rotate using Rotation. The rotation is performed around the Center point. The rotation may be alternatively controlled using the Direction and Up vectors.
Change size using Scale. Scale is done around Center and with orientation given by ScaleOrientation.
This class is the base object that is managed by the TCastleViewport. You insert instances of this class into TCastleViewport.Items, which is actually an instance of TCastleTransform too.
This class implements also optional gravity and physics. See the Gravity property for a simple unrealistic gravity model. See the RigidBody for a proper rigid-bidy simulation, with correct gravity model and collisions with other rigid bodies.
Hierarchy
- TObject
- TPersistent
- TComponent
- TCastleComponent
- TCastleTransform
Overview
Fields
nested const DefaultMiddleHeight = 0.5; |
|
nested const DefaultDirection: array [TOrientationType] of TVector3 = (
(X: 0; Y: 0; Z: -1),
(X: 0; Y: 0; Z: +1),
(X: 0; Y: -1; Z: 0),
(X: 1; Y: 0; Z: 0)
); |
|
nested const DefaultUp: array [TOrientationType] of TVector3 = (
(X: 0; Y: 1; Z: 0),
(X: 0; Y: 1; Z: 0),
(X: 0; Y: 0; Z: 1),
(X: 0; Y: 0; Z: 1)
); |
|
nested const DefaultCameraOrientation = otUpYDirectionMinusZ; |
|
class var DefaultOrientation: TOrientationType; |
Methods
procedure RegisterGLContextClose; |
|
procedure ChangeWorld(const Value: TCastleAbstractRootTransform); virtual; |
|
procedure Notification(AComponent: TComponent; Operation: TOperation); override; |
|
function HeightCollision(const APosition, GravityUp: TVector3; const TrianglesToIgnoreFunc: TTriangleIgnoreFunc; out AboveHeight: Single; out AboveGround: PTriangle): boolean; |
|
function MoveCollision( const OldPos, ProposedNewPos: TVector3; out NewPos: TVector3; const IsRadius: boolean; const Radius: Single; const OldBox, NewBox: TBox3D; const TrianglesToIgnoreFunc: TTriangleIgnoreFunc): boolean; overload; |
|
function MoveCollision( const OldPos, NewPos: TVector3; const IsRadius: boolean; const Radius: Single; const OldBox, NewBox: TBox3D; const TrianglesToIgnoreFunc: TTriangleIgnoreFunc): boolean; overload; |
|
function SegmentCollision(const Pos1, Pos2: TVector3; const TrianglesToIgnoreFunc: TTriangleIgnoreFunc; const ALineOfSight: boolean): boolean; |
|
function SphereCollision(const Pos: TVector3; const Radius: Single; const TrianglesToIgnoreFunc: TTriangleIgnoreFunc): boolean; |
|
function SphereCollision2D(const Pos: TVector2; const Radius: Single; const TrianglesToIgnoreFunc: TTriangleIgnoreFunc; const Details: TCollisionDetails = nil): boolean; |
|
function PointCollision2D(const Point: TVector2; const TrianglesToIgnoreFunc: TTriangleIgnoreFunc): boolean; |
|
function BoxCollision(const Box: TBox3D; const TrianglesToIgnoreFunc: TTriangleIgnoreFunc): boolean; |
|
function RayCollision(const RayOrigin, RayDirection: TVector3; const TrianglesToIgnoreFunc: TTriangleIgnoreFunc): TRayCollision; |
|
function LocalHeightCollision(const APosition, GravityUp: TVector3; const TrianglesToIgnoreFunc: TTriangleIgnoreFunc; out AboveHeight: Single; out AboveGround: PTriangle): boolean; virtual; |
|
function LocalMoveCollision( const OldPos, ProposedNewPos: TVector3; out NewPos: TVector3; const IsRadius: boolean; const Radius: Single; const OldBox, NewBox: TBox3D; const TrianglesToIgnoreFunc: TTriangleIgnoreFunc): boolean; overload; virtual; |
|
function LocalMoveCollision( const OldPos, NewPos: TVector3; const IsRadius: boolean; const Radius: Single; const OldBox, NewBox: TBox3D; const TrianglesToIgnoreFunc: TTriangleIgnoreFunc): boolean; overload; virtual; |
|
function LocalSegmentCollision(const Pos1, Pos2: TVector3; const TrianglesToIgnoreFunc: TTriangleIgnoreFunc; const ALineOfSight: boolean): boolean; virtual; |
|
function LocalSphereCollision(const Pos: TVector3; const Radius: Single; const TrianglesToIgnoreFunc: TTriangleIgnoreFunc): boolean; virtual; |
|
function LocalSphereCollision2D(const Pos: TVector2; const Radius: Single; const TrianglesToIgnoreFunc: TTriangleIgnoreFunc; const Details: TCollisionDetails = nil): boolean; virtual; |
|
function LocalPointCollision2D(const Point: TVector2; const TrianglesToIgnoreFunc: TTriangleIgnoreFunc): boolean; virtual; |
|
function LocalBoxCollision(const Box: TBox3D; const TrianglesToIgnoreFunc: TTriangleIgnoreFunc): boolean; virtual; |
|
function LocalRayCollision(const RayOrigin, RayDirection: TVector3; const TrianglesToIgnoreFunc: TTriangleIgnoreFunc): TRayCollision; virtual; |
|
procedure LocalRender(const Params: TRenderParams); virtual; |
|
procedure LocalRenderShadowVolume(const Params: TRenderParams; const ShadowVolumeRenderer: TBaseShadowVolumeRenderer); virtual; |
|
function Translation2D: TVector2; deprecated 'use TranslationXY'; |
|
procedure TransformMatricesMult(var M, MInverse: TMatrix4); deprecated 'do not use this directly, instead use Transform and InverseTransform methods'; |
|
procedure TransformMatrices(out M, MInverse: TMatrix4); deprecated 'do not use this directly, instead use Transform and InverseTransform methods'; |
|
function AverageScale: Single; |
|
function AverageScale2D: Single; |
|
procedure Fall(const FallHeight: Single); virtual; |
|
procedure ChangedTransform; virtual; |
|
procedure ExistsInRootChanged; virtual; |
|
constructor Create(AOwner: TComponent); override; |
|
destructor Destroy; override; |
|
procedure CustomSerialization(const SerializationProcess: TSerializationProcess); override; |
|
function PropertySections(const PropertyName: String): TPropertySections; override; |
|
function GetEnumerator: TEnumerator; |
|
function CheckCollides: Boolean; |
|
function GetCollides: boolean; virtual; deprecated 'use CheckCollides'; |
|
function CheckPickable: boolean; |
|
function GetPickable: boolean; virtual; deprecated 'use CheckPickable'; |
|
function CheckVisible: boolean; |
|
function GetVisible: boolean; virtual; deprecated 'use CheckVisible'; |
|
procedure Add(const Item: TCastleTransform); |
|
procedure Insert(const Index: Integer; const Item: TCastleTransform); |
|
procedure Remove(const Item: TCastleTransform); |
|
procedure RemoveDelayed(const Item: TCastleTransform; const FreeItem: Boolean = false); |
|
procedure Delete(const Index: Integer); |
|
function Count: Integer; |
|
procedure Clear; |
|
procedure Exchange(const Index1, Index2: Integer); |
|
procedure SortBackToFront(const BlendingSort: TBlendingSort; const CameraPosition: TVector3); |
|
procedure SortBackToFront2D; |
|
function BoundingBox: TBox3D; |
|
function LocalBoundingBox: TBox3D; virtual; |
|
function WorldBoundingBox: TBox3D; |
|
procedure Render(const Params: TRenderParams); overload; virtual; |
|
procedure Render(const Frustum: TFrustum; const Params: TRenderParams); overload; deprecated 'use Render method without an explicit Frustum parameter, it is in Params.Frustum now'; |
|
procedure RenderShadowVolume(const Params: TRenderParams; const ShadowVolumeRenderer: TBaseShadowVolumeRenderer); |
|
procedure PrepareResources(const Options: TPrepareResourcesOptions; const ProgressStep: boolean; const Params: TPrepareParams); virtual; |
|
function PrepareResourcesSteps: Cardinal; virtual; |
|
function Press(const Event: TInputPressRelease): boolean; virtual; |
|
function Release(const Event: TInputPressRelease): boolean; virtual; |
|
function PointingDevicePress(const Pick: TRayCollisionNode; const Distance: Single): Boolean; virtual; |
|
function PointingDeviceRelease(const Pick: TRayCollisionNode; const Distance: Single; const CancelAction: Boolean): Boolean; virtual; |
|
function PointingDeviceMove(const Pick: TRayCollisionNode; const Distance: Single): Boolean; virtual; |
|
procedure Update(const SecondsPassed: Single; var RemoveMe: TRemoveType); virtual; |
|
procedure VisibleChangeHere(const Changes: TVisibleChanges); virtual; |
|
procedure GLContextClose; virtual; |
|
function Middle: TVector3; virtual; |
|
function Sphere(out Radius: Single): boolean; virtual; |
|
function Height(const MyPosition: TVector3; out AboveHeight: Single): boolean; overload; |
|
function Height(const MyPosition: TVector3; out AboveHeight: Single; out AboveGround: PTriangle): boolean; overload; |
|
function LineOfSight(const Pos1, Pos2: TVector3): boolean; |
|
function MoveAllowed(const OldPos, ProposedNewPos: TVector3; out NewPos: TVector3; const BecauseOfGravity: boolean): boolean; overload; |
|
function MoveAllowed(const OldPos, NewPos: TVector3; const BecauseOfGravity: boolean): boolean; overload; |
|
function Ray(const RayOrigin, RayDirection: TVector3): TRayCollision; |
|
function RayCast(const RayOrigin, RayDirection: TVector3): TCastleTransform; overload; |
|
function RayCast(const RayOrigin, RayDirection: TVector3; out Distance: Single): TCastleTransform; overload; |
|
function OutsideToLocal(const Pos: TVector3): TVector3; |
|
function LocalToOutside(const Pos: TVector3): TVector3; |
|
function WorldToLocal(const Pos: TVector3): TVector3; |
|
function LocalToWorld(const Pos: TVector3): TVector3; |
|
function WorldToLocalDirection(const Dir: TVector3): TVector3; |
|
function LocalToWorldDirection(const Dir: TVector3): TVector3; |
|
function LocalToWorldDistance(const Distance: Single): Single; |
|
function WorldToLocalDistance(const Distance: Single): Single; |
|
function PreferredHeight: Single; virtual; deprecated 'use physics (TCastleRigidBody, TCastleCollider) to make things affected by gravity'; |
|
function Transform: TMatrix4; |
|
function InverseTransform: TMatrix4; |
|
function HasWorldTransform: boolean; |
|
function WorldTransform: TMatrix4; |
|
function WorldInverseTransform: TMatrix4; |
|
procedure Translate(const TranslationChange: TVector3); |
|
function Move(const TranslationChange: TVector3; const BecauseOfGravity: boolean; const EnableWallSliding: boolean = true): boolean; |
|
function GetTranslation: TVector3; deprecated 'use Translation'; |
|
procedure Identity; |
|
procedure GetView(out APos, ADir, AUp: TVector3); |
|
procedure GetWorldView(out APos, ADir, AUp: TVector3); |
|
function WorldTranslation: TVector3; |
|
procedure SetView(const APos, ADir, AUp: TVector3; const AdjustUp: boolean = true); overload; |
|
procedure SetView(const ADir, AUp: TVector3; const AdjustUp: boolean = true); overload; |
|
procedure SetWorldView(const APos, ADir, AUp: TVector3; const AdjustUp: boolean = true); |
|
procedure UpPrefer(const AUp: TVector3); |
|
procedure AddBehavior(const Behavior: TCastleBehavior); |
|
procedure RemoveBehavior(const Behavior: TCastleBehavior); |
|
function FindBehavior(const BehaviorClass: TCastleBehaviorClass): TCastleBehavior; |
|
function FindRequiredBehavior(const BehaviorClass: TCastleBehaviorClass): TCastleBehavior; |
|
function BehaviorsCount: Integer; |
|
function BehaviorsEnumerate: TCastleBehaviorEnumerator; |
Properties
property GetExists: Boolean read FExists; deprecated 'use Exists'; |
|
property Items[constI:Integer]: TCastleTransform read GetItem write SetItem; |
|
property Parent: TCastleTransform read FParent; |
|
property UniqueParent: TCastleTransform read FParent; deprecated 'use Parent'; |
|
property CastShadowVolumes: boolean
read FCastShadowVolumes write FCastShadowVolumes default true; |
|
property ListenPressRelease: Boolean
read FListenPressRelease write SetListenPressRelease default false; |
|
property World: TCastleAbstractRootTransform read FWorld; |
|
property Cursor: TMouseCursor read FCursor write SetCursor default mcDefault; |
|
property CollidesWithMoving: boolean read FCollidesWithMoving write FCollidesWithMoving default false; |
|
property InternalExcludeFromParentBoundingVolume: boolean
read FInternalExcludeFromParentBoundingVolume
write FInternalExcludeFromParentBoundingVolume; |
|
property Gravity: boolean read FGravity write FGravity default false; deprecated 'use physics (TCastleRigidBody, TCastleCollider) to make things affected by gravity'; |
|
property FallSpeed: Single read FFallSpeed write FFallSpeed default 0; deprecated 'use physics (TCastleRigidBody, TCastleCollider) to make things affected by gravity'; |
|
property GrowSpeed: Single read FGrowSpeed write FGrowSpeed default 0; deprecated 'use physics (TCastleRigidBody, TCastleCollider) to make things affected by gravity'; |
|
property MiddleHeight: Single read FMiddleHeight write FMiddleHeight
default DefaultMiddleHeight; |
|
property Translation: TVector3 read FTranslation write SetTranslation; |
|
property TranslationXY: TVector2 read GetTranslationXY write SetTranslationXY; |
|
property Center: TVector3 read FCenter write SetCenter; |
|
property Rotation: TVector4 read FRotation write SetRotation; |
|
property Scale: TVector3 read FScale write SetScale; |
|
property ScaleOrientation: TVector4 read FScaleOrientation write SetScaleOrientation; |
|
property RigidBody: TRigidBody read FRigidBody write SetRigidBody; |
|
property Position: TVector3 read FTranslation write SetTranslation; deprecated 'use Translation'; |
|
property Direction: TVector3 read GetDirection write SetDirection; |
|
property Up: TVector3 read GetUp write SetUp; |
|
property Orientation: TOrientationType read FOrientation write FOrientation; |
|
property List: TCastleTransformList read FList; |
|
property Behaviors [constIndex:Integer]: TCastleBehavior read GetBehaviors; |
|
property ExistsInRoot: Boolean read FExistsInRoot; |
|
property Exists: Boolean read FExists write SetExists default true; |
|
property Collides: boolean read FCollides write FCollides default true; |
|
property Pickable: boolean read FPickable write FPickable default true; |
|
property Visible: boolean read FVisible write FVisible default true; |
|
property ExcludeFromStatistics: boolean
read FExcludeFromStatistics write FExcludeFromStatistics default false; |
|
property CollisionSphereRadius: Single read FCollisionSphereRadius write FCollisionSphereRadius; |
|
property CenterPersistent: TCastleVector3Persistent read FCenterPersistent ; |
|
property RotationPersistent: TCastleVector4Persistent read FRotationPersistent ; |
|
property ScalePersistent: TCastleVector3Persistent read FScalePersistent ; |
|
property ScaleOrientationPersistent: TCastleVector4Persistent read FScaleOrientationPersistent ; |
|
property TranslationPersistent: TCastleVector3Persistent read FTranslationPersistent ; |
Description
Fields
nested const DefaultMiddleHeight = 0.5; |
|
nested const DefaultDirection: array [TOrientationType] of TVector3 = (
(X: 0; Y: 0; Z: -1),
(X: 0; Y: 0; Z: +1),
(X: 0; Y: -1; Z: 0),
(X: 1; Y: 0; Z: 0)
); |
|
nested const DefaultUp: array [TOrientationType] of TVector3 = (
(X: 0; Y: 1; Z: 0),
(X: 0; Y: 1; Z: 0),
(X: 0; Y: 0; Z: 1),
(X: 0; Y: 0; Z: 1)
); |
|
nested const DefaultCameraOrientation = otUpYDirectionMinusZ; |
|
Default TCastleCamera.Orientation. |
class var DefaultOrientation: TOrientationType; |
|
Default value of TCastleTransform.Orientation for new TCastleTransform instances, but not for cameras (cameras use special DefaultCameraOrientation). This is otUpYDirectionZ by default. This matches glTF orientation (as exported from Blender and other software). |
Methods
procedure RegisterGLContextClose; |
|
Call this when doing anything that allocates GL resources. This will make sure GLContextClose will get called. |
procedure ChangeWorld(const Value: TCastleAbstractRootTransform); virtual; |
|
Called when the current World that contains this object changes. In the usual case, World corresponds to a TCastleViewport.Items instance, and when this method is called it means that object is added/removed from a viewport. You can ignore this when called with Value equal to current World. Note that each TCastleTransform instance can only be part of one world (TCastleAbstractRootTransform) at a time. Although we may be present many times within the same world. Always remove the TCastleTransform from previous world before adding it to a new one. |
procedure Notification(AComponent: TComponent; Operation: TOperation); override; |
|
function HeightCollision(const APosition, GravityUp: TVector3; const TrianglesToIgnoreFunc: TTriangleIgnoreFunc; out AboveHeight: Single; out AboveGround: PTriangle): boolean; |
|
Height of a point above the 3D model. This checks ray collision, from APosition along the negated GravityUp vector. Measures distance to the nearest scene item (called "ground" here).
Parameters
ReturnsIf the 3D scene is hit. |
function MoveCollision( const OldPos, ProposedNewPos: TVector3; out NewPos: TVector3; const IsRadius: boolean; const Radius: Single; const OldBox, NewBox: TBox3D; const TrianglesToIgnoreFunc: TTriangleIgnoreFunc): boolean; overload; |
|
Can other 3D object (maybe a player) move without colliding with this object. If IsRadius, then you should prefer to perform exact collision with sphere of given radius (must be > 0). At the very least, this checks that the line segment between OldPos and NewPos doesn't collide, and that sphere with given Radius centered around NewPos doesn't collide. If not IsRadius, or if checking for collisions with sphere is not possible for some reasons, then you can check for collisions with boxes. OldBox should usually be ignored (it can be useful when collision-checking has to be approximate in some corner cases, see TCreature.MoveCollision). NewBox plays the same role as "sphere centered around NewPos" in paragraph above. Overloaded version with separate ProposedNewPos and NewPos parameters allows you to accept the move, but for NewPos (that should be some slightly modified version of ProposedNewPos). This allows to implement wall-sliding: when camera tries to walk into the wall, we will change movement to move alongside the wall (instead of just completely blocking the move). When this version returns |
function MoveCollision( const OldPos, NewPos: TVector3; const IsRadius: boolean; const Radius: Single; const OldBox, NewBox: TBox3D; const TrianglesToIgnoreFunc: TTriangleIgnoreFunc): boolean; overload; |
|
function SegmentCollision(const Pos1, Pos2: TVector3; const TrianglesToIgnoreFunc: TTriangleIgnoreFunc; const ALineOfSight: boolean): boolean; |
|
Check collision with a line segment, that is: a line between 2 points in 3D. |
function SphereCollision(const Pos: TVector3; const Radius: Single; const TrianglesToIgnoreFunc: TTriangleIgnoreFunc): boolean; |
|
Check collision with a 3D sphere. This works precisely when transformation hierarchy has uniform scaling, i.e. scale is the same in all X, Y, Z axes. In case of non-uniform scaling, this is an approximation. |
function SphereCollision2D(const Pos: TVector2; const Radius: Single; const TrianglesToIgnoreFunc: TTriangleIgnoreFunc; const Details: TCollisionDetails = nil): boolean; |
|
Check collision with a sphere in 2D (a circle, extruded to infinity along the Z axis). Note that PointCollision2D and This works precisely when transformation hierarchy has uniform scaling, i.e. scale is the same in all X, Y, Z axes. In case of non-uniform scaling, this is an approximation. Parameters
|
function PointCollision2D(const Point: TVector2; const TrianglesToIgnoreFunc: TTriangleIgnoreFunc): boolean; |
|
Check collision with a point in 2D (which is an infinite line along the Z axis in 3D). Note that
|
function BoxCollision(const Box: TBox3D; const TrianglesToIgnoreFunc: TTriangleIgnoreFunc): boolean; |
|
Check collision with axis-aligned box in 3D. |
function RayCollision(const RayOrigin, RayDirection: TVector3; const TrianglesToIgnoreFunc: TTriangleIgnoreFunc): TRayCollision; |
|
Check collision with a ray, building a TRayCollision result. Returns a collision as TRayCollision instance, or Contrary to other collision routines, this should ignore the Collides property. The Collides property specifies whether item collides with camera. And this method is used for picking (pointing) 3D stuff — everything visible can be picked, collidable or not. Instead, this looks at Pickable and Exists properties. This always returns the first collision with the world, that is the one with smallest TRayCollision.Distance. For example, when implemented in TCastleTransform, this checks collisions for all list items, and chooses the closest one. |
function LocalHeightCollision(const APosition, GravityUp: TVector3; const TrianglesToIgnoreFunc: TTriangleIgnoreFunc; out AboveHeight: Single; out AboveGround: PTriangle): boolean; virtual; |
|
function LocalMoveCollision( const OldPos, ProposedNewPos: TVector3; out NewPos: TVector3; const IsRadius: boolean; const Radius: Single; const OldBox, NewBox: TBox3D; const TrianglesToIgnoreFunc: TTriangleIgnoreFunc): boolean; overload; virtual; |
|
function LocalMoveCollision( const OldPos, NewPos: TVector3; const IsRadius: boolean; const Radius: Single; const OldBox, NewBox: TBox3D; const TrianglesToIgnoreFunc: TTriangleIgnoreFunc): boolean; overload; virtual; |
|
function LocalSegmentCollision(const Pos1, Pos2: TVector3; const TrianglesToIgnoreFunc: TTriangleIgnoreFunc; const ALineOfSight: boolean): boolean; virtual; |
|
function LocalSphereCollision(const Pos: TVector3; const Radius: Single; const TrianglesToIgnoreFunc: TTriangleIgnoreFunc): boolean; virtual; |
|
function LocalSphereCollision2D(const Pos: TVector2; const Radius: Single; const TrianglesToIgnoreFunc: TTriangleIgnoreFunc; const Details: TCollisionDetails = nil): boolean; virtual; |
|
function LocalPointCollision2D(const Point: TVector2; const TrianglesToIgnoreFunc: TTriangleIgnoreFunc): boolean; virtual; |
|
function LocalBoxCollision(const Box: TBox3D; const TrianglesToIgnoreFunc: TTriangleIgnoreFunc): boolean; virtual; |
|
function LocalRayCollision(const RayOrigin, RayDirection: TVector3; const TrianglesToIgnoreFunc: TTriangleIgnoreFunc): TRayCollision; virtual; |
|
procedure LocalRender(const Params: TRenderParams); virtual; |
|
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. |
procedure LocalRenderShadowVolume(const Params: TRenderParams; const ShadowVolumeRenderer: TBaseShadowVolumeRenderer); virtual; |
|
Render shadow volumes (with a full transformation of this scene). This is mostly an internal method. You should not need to override it during normal engine usage. If you render everything using TCastleScene, then rendering shadow volumes is also automatically handled by TCastleScene. |
function Translation2D: TVector2; deprecated 'use TranslationXY'; |
|
Warning: this symbol is deprecated: use TranslationXY Get translation in 2D (uses Translation, ignores Z coord). |
procedure TransformMatricesMult(var M, MInverse: TMatrix4); deprecated 'do not use this directly, instead use Transform and InverseTransform methods'; |
|
Warning: this symbol is deprecated: do not use this directly, instead use Transform and InverseTransform methods Transformation matrices, like Transform and InverseTransform. |
procedure TransformMatrices(out M, MInverse: TMatrix4); deprecated 'do not use this directly, instead use Transform and InverseTransform methods'; |
|
Warning: this symbol is deprecated: do not use this directly, instead use Transform and InverseTransform methods |
function AverageScale: Single; |
|
Average value of 3D scale in Scale. It is not calculated as a simple average, it's a little smarter to prevent from weird results sometimes, see Approximate3DScale. |
function AverageScale2D: Single; |
|
Average value of 2D scale, from XY components of Scale. It is not calculated as a simple average, it's a little smarter to prevent from weird results sometimes, see Approximate2DScale. |
procedure Fall(const FallHeight: Single); virtual; |
|
Called when fall ended. You can use FallHeight to decrease creature life or such. |
procedure ChangedTransform; virtual; |
|
Override to be notified about every transformation change. By default, this calls VisibleChangeHere, which causes the window to redraw. |
procedure ExistsInRootChanged; virtual; |
|
Override to be notified after ExistsInRoot value changed. |
constructor Create(AOwner: TComponent); override; |
|
destructor Destroy; override; |
|
procedure CustomSerialization(const SerializationProcess: TSerializationProcess); override; |
|
function PropertySections(const PropertyName: String): TPropertySections; override; |
|
function GetEnumerator: TEnumerator; |
|
function CheckCollides: Boolean; |
|
Does the item really collide. Trivial shortcut for checking Collides and Exists. |
function GetCollides: boolean; virtual; deprecated 'use CheckCollides'; |
|
Warning: this symbol is deprecated: use CheckCollides |
function CheckPickable: boolean; |
|
Is the item really pickable. Trivial shortcut for checking Pickable and Exists. |
function GetPickable: boolean; virtual; deprecated 'use CheckPickable'; |
|
Warning: this symbol is deprecated: use CheckPickable |
function CheckVisible: boolean; |
|
Is the item really visible. Trivial shortcut for checking Visible and Exists. |
function GetVisible: boolean; virtual; deprecated 'use CheckVisible'; |
|
Warning: this symbol is deprecated: use CheckVisible |
procedure Add(const Item: TCastleTransform); |
|
Add a child. Note that adding the same child multiple times is allowed, in general you can use the same TCastleTransform instance multiple times in one hierarchy of TCastleRootTransform. |
procedure Insert(const Index: Integer; const Item: TCastleTransform); |
|
Insert a child at a specific position on the children list. Usually the order of children doesn't matter, so there's not much point in using this method. You can as well use Add. In particular, for rendering opaque (3D or 2D objects) the front/back is decided by the actual translation of the object in 3D, i.e. what is closer to the camera. (In a typical 2D setup, larger Z values mean "closer to the camera".) The position on the children list doesn't matter in this case. However, the position matters in case of blending. See https://castle-engine.io/blending . For correct blending, when you have multiple partially-transparent scenes, the partially-transparent objects must be sorted from back to front on the list. So you should add them in the proper order, or insert on proper positions, or use SortBackToFront2D on parent transformation. |
procedure Remove(const Item: TCastleTransform); |
|
Remove a child. Note that adding and removing from the TCastleTransform hierarchy is guaranteed to be fast, so you can do it even in the middle of the game. In particular calling Remove doesn't free rendering reasources of the removed scene, so removing scene only to add it later to another TCastleViewport.Items is fast. |
procedure RemoveDelayed(const Item: TCastleTransform; const FreeItem: Boolean = false); |
|
Use this to remove (and possibly free) the child, but not immediately. The actual removal (and freeing, if FreeItem) will be done at some crucial points:
This allows to use this method safely even in the middle of iteration over TCastleTransform children. For example you can use it from Update method, from any TCastleTransform.Update or TCastleUserInterface.Update (including TUIState.Update). Note: It is not a problem if the child scheduled to be removed will also be removed (or even freed) directly e.g. by just calling |
procedure Delete(const Index: Integer); |
|
Remove a child, by index on the Items list. |
function Count: Integer; |
|
Count of current children, to iterate over Items from 0 to Count-1. |
procedure Clear; |
|
Remove all children TCastleTransform instances. |
procedure Exchange(const Index1, Index2: Integer); |
|
Exchange position of 2 children TCastleTransform instances. |
procedure SortBackToFront(const BlendingSort: TBlendingSort; const CameraPosition: TVector3); |
|
Sort objects back-to-front right now following one of the blending sorting algorithms. Only the immediate list items are reordered, looking at their bounding boxes (the sorting is not recursive). Calling this method makes sense if you use blending and multiple partially-transparent objects may be visible at the same place on the screen. Sorting avoids artifacts when rendering.
Note that this doesn't take care of sorting the shapes within the scenes. For this, you should set Scene.RenderOptions.BlendingSort to a value like bs3D, to keep it sorted. It is the default now, so you typically don't need to worry about it. See the TBlendingSort documentation for the exact specification of sorting algorithms. Using BlendingSort = bsNone does nothing. See also
|
procedure SortBackToFront2D; |
|
Sort objects back-to-front right now following the 2D blending sorting algorithm. See SortBackToFront for documentation, this method is only a shortcut for See also
|
function BoundingBox: TBox3D; |
|
Bounding box of this object, in the coordinate system of the parent transformation. This method takes into account current transformation (like Translation, Rotation) but not parent TCastleTransform transformations. Use WorldBoundingBox instead to know bounding box that accounts for all TCastleTransform transformations. Use LocalBoundingBox instead to know bounding box that does not account for any parent or this TCastleTransform transformations. Takes into account both collidable and visible objects. For example, invisible walls (not visible) and fake walls (not collidable) should all be accounted here. It's a bounding volume, it should be as large as necessary to include the object inside. At the same time, it should be as "tight" as it can, to make various optimizations work best.
See also
|
function LocalBoundingBox: TBox3D; virtual; |
|
Bounding box of this object, ignoring the transformations of this scene and parents.
See also
|
function WorldBoundingBox: TBox3D; |
|
Bounding box of this object, taking into account all transformations of this and parents.
See also
|
procedure Render(const Params: TRenderParams); overload; virtual; |
|
Render given object. Should check and immediately exit when CheckVisible is The rendering transformation, frustum, and filtering is specified inside TRenderParams class. This method should only update |
procedure Render(const Frustum: TFrustum; const Params: TRenderParams); overload; deprecated 'use Render method without an explicit Frustum parameter, it is in Params.Frustum now'; |
|
Warning: this symbol is deprecated: use Render method without an explicit Frustum parameter, it is in Params.Frustum now |
procedure RenderShadowVolume(const Params: TRenderParams; const ShadowVolumeRenderer: TBaseShadowVolumeRenderer); |
|
Render shadow quads for all the things rendered by Render. This is done only if Exists and CastShadowVolumes. It does shadow volumes culling inside (so ShadowVolumeRenderer should have FrustumCullingInit already initialized). Params.Transform,InverseTransform,TransformIdentity describe the transformation, just like for Render. |
procedure PrepareResources(const Options: TPrepareResourcesOptions; const ProgressStep: boolean; const Params: TPrepareParams); virtual; |
|
Prepare resources, making various methods (like rendering and such) to execute fast. It is usually simpler to call TCastleViewport.PrepareResources then this method. Calling It is best to call this when the rendering context is initailized, e.g. at Application.OnInitialize or later. Calling this method before the rendering context is initialized (e.g. from initializaton section of some unit) will have to skip some preparations, thus reducing the effectiveness of this method. This makes sure that appropriate methods execute as fast as possible. It's never required to call this method — everything will be prepared "as needed" anyway. But if you allow everything to be prepared "as needed", then e.g. the first Render call may take a long time because it may have to prepare resources that will be reused in next Render calls. This may make your program seem slow at the beginning (when rendering resources are being prepared, so at the first frame, or a couple of first animation frames). To avoid this, call this method, showing the user something like "now we're preparing the resources — please wait".
Parameters
|
function PrepareResourcesSteps: Cardinal; virtual; |
|
How many times PrepareResources will call Progress.Step. Useful only if you want to pass ProgressStep = |
function Press(const Event: TInputPressRelease): boolean; virtual; |
|
Press and release events of key and mouse, passed only to instances that set ListenPressRelease. Return |
function Release(const Event: TInputPressRelease): boolean; virtual; |
|
function PointingDevicePress(const Pick: TRayCollisionNode; const Distance: Single): Boolean; virtual; |
|
Pointing device (mouse or touch) events, you can override these to handle pointing device events. These methods are automatically called by the TCastleViewport. They are exposed here only to allow overriding them. Return
They receive Pick information (TRayCollisionNode) about what exactly is hit by the 3D ray corresponding to the current pointing device position. It contains the detailed information about the point, triangle and ray (all in local coordinate system of this TCastleTransform) that are indicated by the pointing device. TRayCollisionNode.Triangle is They also receive Distance to the collision point, in world coordinates. See TRayCollision.Distance. The Distance may be MaxSingle when it was not possible to determine. There is a concept of a TCastleTransform that is currently "capturing" the pointing device events. Once TCastleTransform handles After the "capturing" instance, every pointing device event (press, release or move) is send to the leaf in TCastleTransform hierarchy (usually a TCastleScene) that is under the mouse/touch position. If the event is not handled, it is passed to other objects under the mouse/touch position. The PointingDeviceMove event is also always passed to TCastleRootTransform.MainScene at the end (if it wasn't already the "capturing" transform, or under the mouse/touch position). This way TCastleRootTransform.MainScene is always informed about pointing device movement. These methods are called only if the object Exists. There's no need to check this condition inside the method implementation. |
function PointingDeviceRelease(const Pick: TRayCollisionNode; const Distance: Single; const CancelAction: Boolean): Boolean; virtual; |
|
function PointingDeviceMove(const Pick: TRayCollisionNode; const Distance: Single): Boolean; virtual; |
|
procedure Update(const SecondsPassed: Single; var RemoveMe: TRemoveType); virtual; |
|
Continuously occuring event, for various tasks. Executed only on instances that have Exists (no need to check this in overridden Update implementation). Parameters
|
procedure VisibleChangeHere(const Changes: TVisibleChanges); virtual; |
|
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. |
function Middle: TVector3; virtual; |
|
Middle point, usually "eye point", of the 3D model. This is used for sphere center (if CollisionSphereRadius is non-zero or Sphere returns In short, it's usually most comfortable to think about this as a position of the eye, or the middle of the creature's head. In an ideal situation, it should not be based on anything dynamic. For example, when this is based on the current bounding box of the animation, there is a risk that a large and sudden change in animation box could make the Middle point to jump to the other side of the wall (breaking collisions, as it changes Middle without a chance to check for collisions by MoveAllowed). Ideally, it should remain constant even when the shape of the object changes, and be possible to change only when MoveAllowed is checked (so only when TCastleTransform.Translation can change). In this class this returns something sensible above the bottom of the box. See TCastleTransform.MiddleHeight. This is expressed in the parent coordinate system (so it is close to the Translation value, but moved up, following GravityUp). It ignores parent transformations (using |
function Sphere(out Radius: Single): boolean; virtual; |
|
Can the approximate sphere (around Middle point) be used for some collision-detection tasks. If Must return By default, in TCastleTransform class, this returns The advantages of using a sphere, that does not have to be a perfect bounding sphere (it may be smaller than necessary, and only account e.g. for upper body part of the creature), are:
Sphere disadvantage:
|
function Height(const MyPosition: TVector3; out AboveHeight: Single): boolean; overload; |
|
Get height of my point above the rest of the world. The given MyPosition, and returned AboveHeight, are in the parent coordinate system of this TCastleTransform. So for example query like this works naturally: This ignores the geometry of this 3D object (to not accidentally collide with your own geometry), and checks collisions with the rest of the world. |
function Height(const MyPosition: TVector3; out AboveHeight: Single; out AboveGround: PTriangle): boolean; overload; |
|
function LineOfSight(const Pos1, Pos2: TVector3): boolean; |
|
Whether there is line of sight (the line segment does not collide with anything opaque) between these 2 points. The given Pos1, Pos2 are in the parent coordinate system of this TCastleTransform. So for example query like this works naturally: This ignores the geometry of this 3D object (to not accidentally collide with your own geometry), and checks collisions with the rest of the world. |
function MoveAllowed(const OldPos, ProposedNewPos: TVector3; out NewPos: TVector3; const BecauseOfGravity: boolean): boolean; overload; |
|
Is the move from OldPos to ProposedNewPos possible for this object. Returns true and sets NewPos if some move is allowed. The NewPos may be different than ProposedNewPos, which allows to perform wall-sliding. Wall sliding will only work if collision sphere is defined, which should be configured by setting CollisionSphereRadius to something non-zero. Otherwise, the move uses only box collisions, and wall sliding doesn't happen. When checking collisions, it avoids colliding with itself, so it only checks collisions with the rest of the world (things outside of this TCastleTransform). The given OldPos, ProposedNewPos, NewPos are in the parent coordinate system of this TCastleTransform. Intuitively, you are asking "Can I change Translation from OldPos to NewPos". So this method is consistent with Move, Translate. |
function MoveAllowed(const OldPos, NewPos: TVector3; const BecauseOfGravity: boolean): boolean; overload; |
|
Is the move from OldPos to NewPos possible for this object. This overloaded version of If this object allows to use sphere for collisions (see CollisionSphereRadius and Sphere) then sphere will be used. Otherwise, it will collide as a bounding box. When checking collisions, it avoids colliding with itself, so it only checks collisions with the rest of the world (things outside of this TCastleTransform). The given OldPos, NewPos are in the parent coordinate system of this TCastleTransform. Intuitively, you are asking "Can I change Translation from OldPos to NewPos". So this method is consistent with Move, Translate. |
function Ray(const RayOrigin, RayDirection: TVector3): TRayCollision; |
|
Cast a ray, see what is hit (checks the whole world, not just this TCastleTransform hierarchy). The given RayOrigin, RayDirection are in the parent coordinate system of this TCastleTransform. So for example query like this works naturally: This ignores the geometry of this object (to not accidentally collide with your own geometry), and checks collisions with the rest of the world. |
function RayCast(const RayOrigin, RayDirection: TVector3): TCastleTransform; overload; |
|
Cast a ray, see what is hit (checks the whole world, not just this TCastleTransform hierarchy). The given RayOrigin, RayDirection are in the parent coordinate system of this TCastleTransform. So for example query like this works naturally: This ignores the geometry of this object (to not accidentally collide with your own geometry), and checks collisions with the rest of the world. This 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 |
function RayCast(const RayOrigin, RayDirection: TVector3; out Distance: Single): TCastleTransform; overload; |
|
function OutsideToLocal(const Pos: TVector3): TVector3; |
|
Convert position between local and outside coordinate system. This is called |
function LocalToOutside(const Pos: TVector3): TVector3; |
|
function WorldToLocal(const Pos: TVector3): TVector3; |
|
Convert position between local and world coordinate system. This applies all the transformations on the way to root, so it looks at this object as well as all parents' transformations. |
function LocalToWorld(const Pos: TVector3): TVector3; |
|
function WorldToLocalDirection(const Dir: TVector3): TVector3; |
|
Convert direction between local and world coordinate system. This applies all the transformations on the way to root, so it looks at this object as well as all parents' transformations. |
function LocalToWorldDirection(const Dir: TVector3): TVector3; |
|
function WorldToLocalDistance(const Distance: Single): Single; |
|
function PreferredHeight: Single; virtual; deprecated 'use physics (TCastleRigidBody, TCastleCollider) to make things affected by gravity'; |
|
Warning: this symbol is deprecated: use physics (TCastleRigidBody, TCastleCollider) to make things affected by gravity The preferred height of the object Middle above the ground, when the object is standing on the ground firmly. This is used by objects affected by gravity (like non-flying creatures and items) to know how far they should fall down or grow up. The default implementation in this class looks at MiddleHeight property, see the algorithm described there. This may be dynamic (may change during creature lifetime, so you can make the creature duck or grow if you want). |
function Transform: TMatrix4; |
|
Transformation (from local to outside) as a matrix. This matrix represents a concise version of properties like Translation, Rotation, Scale. It does not take into account the transformation of parent TCastleTransform (for this, use WorldTransform). |
function InverseTransform: TMatrix4; |
|
Inverse transformation as a matrix, thus transforming from outside to local coordinate system. This is an inverse of Transform. |
function HasWorldTransform: boolean; |
|
All conditions are satisfied to have WorldTransform. When this returns |
function WorldTransform: TMatrix4; |
|
Transformation (from local to world) as a matrix. This accumulates the transformation of this instance (derived from properties like Translation, Rotation, Scale) with the transformation of parent TCastleTransform instances, all the way up to and including the root transformation (TCastleAbstractRootTransform). Thus, this is a transformation to the world known to the TCastleViewport instance. Two conditions are necessary to make this available:
You can check HasWorldTransform before calling this method, to avoid catching an exception. Note that the
Exceptions raised
|
function WorldInverseTransform: TMatrix4; |
|
Inverse transformation of WorldTransform, thus transforming from world to local coordinate system. See WorldTransform for more details how this works.
Exceptions raised
|
procedure Translate(const TranslationChange: TVector3); |
|
Unconditionally move this object by a given vector. To move and check collisions, use Move instead of this method. The provided TranslationChange should be a direction in the parent coordinate system of this TCastleTransform. Using this routine is exactly equivalent to |
function Move(const TranslationChange: TVector3; const BecauseOfGravity: boolean; const EnableWallSliding: boolean = true): boolean; |
|
Move, if possible (checking collisions with other objects in world). This is the simplest way to move an object, and a basic building block for artificial intelligence of creatures. Checks move possibility by MoveAllowed, using Middle point. Actual move is done using Translate. Note that wall sliding will only work if collision sphere is defined, which should be configured by setting CollisionSphereRadius to something non-zero. Otherwise, the move uses only box collisions, and wall sliding doesn't happen. The provided TranslationChange should be a direction in the parent coordinate system of this TCastleTransform, so using this routine is consistent with doing |
function GetTranslation: TVector3; deprecated 'use Translation'; |
|
Warning: this symbol is deprecated: use Translation |
procedure Identity; |
|
Make the transform do nothing — zero Translation, zero Rotation, Scale to one. Also resets ScaleOrientation. |
procedure GetView(out APos, ADir, AUp: TVector3); |
|
Get at once vectors: position, direction, up. Just like Translation and Rotation, these vectors reflect the transformation defined locally in this TCastleTransform, disregarding the parent transformations. Use GetWorldView to account for parent transformations. |
procedure GetWorldView(out APos, ADir, AUp: TVector3); |
|
Get position, direction, up. Similar to GetView, but in world coordinates. Returned ADir and AUp are always orthogonal. Returned ADir and AUp are always normalized. |
function WorldTranslation: TVector3; |
|
Get position in world coordinates. The returned position is the same as by GetWorldView. This method just doesn't calculation anything else, thus it is faster than GetWorldView if you don't need direction/up. |
procedure SetView(const APos, ADir, AUp: TVector3; const AdjustUp: boolean = true); overload; |
|
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 = Just like Translation and Rotation, these vectors reflect the transformation defined locally in this TCastleTransform, disregarding the parent transformations. Use SetWorldView to account for parent transformations. |
procedure SetView(const ADir, AUp: TVector3; const AdjustUp: boolean = true); overload; |
|
procedure SetWorldView(const APos, ADir, AUp: TVector3; const AdjustUp: boolean = true); |
|
Set position, direction, up. Similar to SetView, but in world coordinates. Given ADir, AUp do not have to be normalized, we will normalize them internally if necessary. But make sure they are non-zero. We will automatically fix ADir and AUp to be orthogonal, if necessary: when AdjustUp = |
procedure UpPrefer(const AUp: TVector3); |
|
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. |
procedure AddBehavior(const Behavior: TCastleBehavior); |
|
Add a TCastleBehavior to this TCastleTransform. In effect, the virtual methods of TCastleBehavior, like TCastleBehavior.Update, will be automatically called. Also the TCastleBehavior.Parent gets assigned. If the TCastleBehavior was part of another TCastleTransform, it is removed from it.
See also
|
procedure RemoveBehavior(const Behavior: TCastleBehavior); |
|
Remove TCastleBehavior from this TCastleTransform. In effect, the virtual methods of TCastleBehavior, like TCastleBehavior.Update, will no longer be automatically called. The TCastleBehavior.Parent is set to |
function FindBehavior(const BehaviorClass: TCastleBehaviorClass): TCastleBehavior; |
|
Find the first behavior of the given class, |
function FindRequiredBehavior(const BehaviorClass: TCastleBehaviorClass): TCastleBehavior; |
|
Find the first behavior of the given class, or create and add a new one if necessary. Never returns |
function BehaviorsCount: Integer; |
|
Count of behaviors. See also
|
function BehaviorsEnumerate: TCastleBehaviorEnumerator; |
|
You can enumerate current behaviors using loop like |
Properties
property GetExists: Boolean read FExists; deprecated 'use Exists'; |
|
Warning: this symbol is deprecated: use Exists |
property Items[constI:Integer]: TCastleTransform read GetItem write SetItem; |
|
List of current children. |
property Parent: TCastleTransform read FParent; |
|
Return parent TCastleTransform. It ignores (never returns) parents caused by referencing transform in TCastleTransformReference. If there is (or was, at some point) more than 1 parent (not counting parents caused by TCastleTransformReference) then it may return nil, or any of the existing parents – it is undefined which exactly. In simple cases, one TCastleTransform is just a child of one other TCastleTransform, and then this property returns this obvios parent. In general, one TCastleTransform instance may be used multiple times as a child of other TCastleTransform instances (as long as they are all within the same TCastleViewport). The parent TCastleTransform instances may include TCastleTransformReference (this allows to create multiple references to one TCastleTransform from editor) but in general any parents are allowed (when you use code, you can just insert TCastleTransform as a child of other TCastleTransform, without the need for TCastleTransformReference). This property indicates the one parent that is not TCastleTransformReference. If there are multiple such parents (this is impossible at design-time in editor, but it is possible at runtime if you add/remove TCastleTransform children by code) then this returns It is |
property UniqueParent: TCastleTransform read FParent; deprecated 'use Parent'; |
|
Warning: this symbol is deprecated: use Parent |
property CastShadowVolumes: boolean
read FCastShadowVolumes write FCastShadowVolumes default true; |
|
Does the 3D object cast shadows by shadow volumes. See also TCastleScene.ReceiveShadowVolumes. |
property ListenPressRelease: Boolean
read FListenPressRelease write SetListenPressRelease default false; |
|
property World: TCastleAbstractRootTransform read FWorld; |
|
Root transformation (TCastleAbstractRootTransform) containing us. |
property Cursor: TMouseCursor read FCursor write SetCursor default mcDefault; |
|
Mouse cursor over this object. |
property CollidesWithMoving: boolean read FCollidesWithMoving write FCollidesWithMoving default false; |
|
Can this object be pushed by (or block movement of) doors, elevators and other moving level parts (TCastleMoving instances). Some 3D moving objects may try to avoid crushing this item. Like an automatic door that stops it's closing animation to not crush things standing in the doorway. Some other 3D moving objects may push this object. Like elevators (vertical, or horizontal moving platforms). We may use sphere (see CollisionSphereRadius and Sphere) for checking collisions, or bounding box (TCastleTransform.BoundingBox), depending on need. |
property InternalExcludeFromParentBoundingVolume: boolean
read FInternalExcludeFromParentBoundingVolume
write FInternalExcludeFromParentBoundingVolume; |
|
Is this object's bounding volume (BoundingBox) included in parent bounding volume. This should be always |
property Gravity: boolean read FGravity write FGravity default false; deprecated 'use physics (TCastleRigidBody, TCastleCollider) to make things affected by gravity'; |
|
Warning: this symbol is deprecated: use physics (TCastleRigidBody, TCastleCollider) to make things affected by gravity Gravity may make this object fall down (see FallSpeed) or grow up (see GrowSpeed). See also PreferredHeight. Special notes for TPlayer: player doesn't use this (TPlayer.Gravity should remain TODO: This will be deprecated at some point, and you will be adviced to always use physics, through TCastleTransform.RigidBody, to have realistic gravity. |
property FallSpeed: Single read FFallSpeed write FFallSpeed default 0; deprecated 'use physics (TCastleRigidBody, TCastleCollider) to make things affected by gravity'; |
|
Warning: this symbol is deprecated: use physics (TCastleRigidBody, TCastleCollider) to make things affected by gravity Falling speed, in units per second, for Gravity. This is relevant only if Gravity and PreferredHeight <> 0. 0 means no falling. TODO: In CGE 7.x this will be deprecated, and you will be adviced to always use physics, through TCastleTransform.RigidBody, to have realistic gravity. |
property GrowSpeed: Single read FGrowSpeed write FGrowSpeed default 0; deprecated 'use physics (TCastleRigidBody, TCastleCollider) to make things affected by gravity'; |
|
Warning: this symbol is deprecated: use physics (TCastleRigidBody, TCastleCollider) to make things affected by gravity Growing (raising from crouching to normal standing position) speed, in units per second. This is used by non-flying creatures when climbing up stairs, in which case Translation ("legs positon") may be sometimes under the ground while Middle ("eyes position") will be always above the ground and will try to grow to be at PreferredHeight above the ground. This is relevant only if Gravity and PreferredHeight <> 0. 0 means no growing. |
property MiddleHeight: Single read FMiddleHeight write FMiddleHeight
default DefaultMiddleHeight; |
|
How high are creature eyes in the model. Value 0 means that eyes are at the bottom of the model, 0.5 means the middle, 1 means top. The top is always considered to be at the top of the bounding box. Definition of bottom depends on Gravity:
This property determines how the TCastleTransform handles the Middle implementation (this is the point used for various collision detection routines) and PreferredHeight (this is the preferred height of Middle above the ground). You can override these two methods to use a different approach, and then ignore |
property Translation: TVector3 read FTranslation write SetTranslation; |
|
Translation (move) the children. Zero by default. Set it like this: Scene.Translation := Vector3(1, 2, 3); Scene.Translation := Scene.Translation + Vector3(4, 5, 6); |
property TranslationXY: TVector2 read GetTranslationXY write SetTranslationXY; |
|
Get or set the XY components of the translation. Useful for 2D games. |
property Center: TVector3 read FCenter write SetCenter; |
|
Center point around which the Rotation and Scale is performed. |
property Rotation: TVector4 read FRotation write SetRotation; |
|
Rotation in 3D, around a specified axis. Rotation is expressed as a 4D vector, in which the first 3 components specify the rotation axis (does not need to be normalized, but must be non-zero) and the last component is the rotation angle in radians. Note: the Rotation axis (first 3 components) must not be a zero vector, however as a special case the rotation value Rotation is done around Center. Set it like this: Scene.Rotation := Vector4(0, 0, 1, Pi / 10); Scene.Rotation := Scene.Rotation + Vector4(0, 0, 0, Pi / 10); |
property Scale: TVector3 read FScale write SetScale; |
|
Scale in 3D. Scaling is done around Center and with orientation given by ScaleOrientation. We do the best we can to work with any scale value, even negative or zero. But usually, it's best to keep the scale positive. More information:
Set it like this: Scene.Scale := Vector3(5, 5, 5); Scene.Scale := Scene.Scale * 1.5; |
property ScaleOrientation: TVector4 read FScaleOrientation write SetScaleOrientation; |
|
Orientation in which 3D Scale is performed. |
property RigidBody: TRigidBody read FRigidBody write SetRigidBody; |
|
Participate in rigid body physics simulation. This makes this object collidable with other rigid bodies (if Collides) and it allows to move and rotate because of gravity or because of collisions with other objects (if TRigidBody.Dynamic is Setting this property makes this 3D object a single rigid body for the physics engine. If this property is assigned and the TRigidBody.Dynamic is The TRigidBody.Collider property must be initialized before assigning the TRigidBody instance here. So you must create a TCollider descendant, specyfying the given TRigidBody as a parent. A rigid body without a collider would in theory not collide with anything, and (if TRigidBody.Dynamic) would simply fall down because of gravity. In practice, a rigid body without a collider is simply not allowed. If you really need this, assign anything to TRigidBody.Collider and just set Collides to Our engine (for now) also has an internal, simple physics simulation, used to perform collisions with player, creatures, and optional (unrealistic) gravity. So we have two independent physics systems, but they try to not get into each others way (they each perform a different task). In the future there will be an option to use the full-featured physics engine for all simulations, also for player and creatures, at which point our "internal physics simulation" will become deprecated. For now, be aware of these:
Note that an object can only be present once in the World to be a rigid body. Breaking this rule will cause the EMultipleReferencesInWorld exception at an undefined time. |
property Position: TVector3 read FTranslation write SetTranslation; deprecated 'use Translation'; |
|
Warning: this symbol is deprecated: use Translation Deprecated name for Translation. |
property Direction: TVector3 read GetDirection write SetDirection; |
|
Direction the transformation (like creature or camera) is facing, and up vector. These properties provide an alternative way to get and set the Rotation of the transformation. Thinking in terms of "direction" and "up" is often more natural when transforming creatures and player. The Orientation determines what is your default direction and up (when the Rotation is zero). See Orientation for documentation of its default value. 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. |
property Up: TVector3 read GetUp write SetUp; |
|
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:
This value determines how you should model your 3D models, like the creatures, the items, and the player weapons. |
property List: TCastleTransformList read FList; |
|
Transformation objects inside. Freeing these items automatically removes them from this list. |
property Behaviors [constIndex:Integer]: TCastleBehavior read GetBehaviors; |
|
Enumerate current See also
|
property ExistsInRoot: Boolean read FExistsInRoot; |
|
Does this object, and all it's parents up to the root, exist. This has undefined value in case you place this TCastleTransform instance (or any parent) many times within the viewport root, and some parents exist while some not. This property doesn't check whether this TCastleTransform is actually part of some World. So it will be |
property Collides: boolean read FCollides write FCollides default true; |
|
Should this 3D object participate in collision detection. You can turn this off, useful to make e.g. "fake" walls (to some secret places on level). This describes collision resolution with almost everything — camera, player (in third-person perspective, camera may differ from player), other creatures. That is because everything resolves collisions through our methods MoveCollision and HeightCollision (high-level) or SegmentCollision, SphereCollision, SphereCollision2D, PointCollision2D, BoxCollision (low-level). (Note that RayCollision is excluded from this, it exceptionally ignores Collides value, as it's primarily used for picking. Same for SegmentCollision with LineOfSight=true.) The only exception are the collisions with TCastleMoving instances (movable world parts like elevators and doors) that have their own detection routines and look at CollidesWithMoving property of other objects. That is, the TCastleMoving instance itself must still have Collides = Note that if not Exists then this doesn't matter (non-existing objects never participate in collision detection). |
property Pickable: boolean read FPickable write FPickable default true; |
|
Is item pickable by RayCollision method. Note that if not Exists then this doesn't matter (non-existing objects are never pickable). This is independent from Collides, as RayCollision does not look at Collides, it only looks at Pickable. |
property Visible: boolean read FVisible write FVisible default true; |
|
Is item visible. Note that if not Exists then this doesn't matter (non-existing objects are never visible). |
property ExcludeFromStatistics: boolean
read FExcludeFromStatistics write FExcludeFromStatistics default false; |
|
Exclude from rendering statistics in TCastleViewport.Statistics. |
property CollisionSphereRadius: Single read FCollisionSphereRadius write FCollisionSphereRadius; |
|
When non-zero, we can approximate collisions with this object using a sphere in certain situations (MoveAllowed, Gravity). This usually makes dynamic objects, like player and creatures, collide better. |
property CenterPersistent: TCastleVector3Persistent read FCenterPersistent ; |
|
Center 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 Center directly. See also |
property RotationPersistent: TCastleVector4Persistent read FRotationPersistent ; |
|
Rotation 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 Rotation directly. See also
|
property ScalePersistent: TCastleVector3Persistent read FScalePersistent ; |
|
Scale 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 Scale directly. See also
|
property ScaleOrientationPersistent: TCastleVector4Persistent read FScaleOrientationPersistent ; |
|
ScaleOrientation 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 ScaleOrientation directly. See also
|
property TranslationPersistent: TCastleVector3Persistent read FTranslationPersistent ; |
|
Translation 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 Translation directly. See also
|
Generated by PasDoc 0.16.0.