Class TRigidBody
Unit
Declaration
type TRigidBody = class(TComponent)
Description
Rigid body properties for the physics engine, see TCastleTransform.RigidBody.
TODO: For now all the properties of this class, including the Collider and all properties of Collider, must be assigned before setting TCastleTransform.RigidBody .
Hierarchy
- TObject
- TPersistent
- TComponent
- TRigidBody
Overview
Methods
constructor Create(AOwner: TComponent); override; |
|
destructor Destroy; override; |
|
procedure Setup2D; |
|
procedure InitializeTransform(const Transform: TCastleTransform); |
|
procedure DeinitializeTransform(const Transform: TCastleTransform); |
|
procedure Update(const Transform: TCastleTransform; const SecondsPassed: Single); |
|
function GetCollidingTransforms: TCastleTransformList; |
|
function PhysicsRayCast(const RayOrigin, RayDirection: TVector3; const MaxDistance: Single): TCastleTransform; overload; |
|
function PhysicsRayCast(const RayOrigin, RayDirection: TVector3; const MaxDistance: Single; out Distance: Single): TCastleTransform; overload; |
Properties
property AngularVelocity: TVector3 read FAngularVelocity write SetAngularVelocity; |
|
property AngularVelocityDamp: Single read FAngularVelocityDamp write SetAngularVelocityDamp; |
|
property MaximalAngularVelocity: Single read FMaximalAngularVelocity write SetMaximalAngularVelocity; |
|
property LinearVelocity: TVector3 read FLinearVelocity write SetLinearVelocity; |
|
property LinearVelocityDamp: Single read FLinearVelocityDamp write SetLinearVelocityDamp; |
|
property MaximalLinearVelocity: Single read FMaximalLinearVelocity write SetMaximalLinearVelocity; |
|
property InitialAngularVelocity: TVector3 read FAngularVelocity write SetAngularVelocity; deprecated 'use AngularVelocity'; |
|
property InitialLinearVelocity: TVector3 read FLinearVelocity write SetLinearVelocity; deprecated 'use LinearVelocity'; |
|
property OnCollisionEnter: TCollisionEvent read FOnCollisionEnter write SetOnCollisionEnter; |
|
property OnCollisionExit: TCollisionEvent read FOnCollisionExit write SetOnCollisionExit; |
|
property OnCollisionStay: TCollisionEvent read FOnCollisionStay write SetOnCollisionStay; |
|
property Dynamic: Boolean read FDynamic write FDynamic default true; |
|
property Animated: Boolean read FAnimated write FAnimated default false; |
|
property Trigger: Boolean read FTrigger write SetTrigger default false; |
|
property Collider: TCollider read FCollider; |
|
property Gravity: Boolean read FGravity write FGravity default true; |
|
property LockTranslation: T3DCoords read FLockTranslation write FLockTranslation; |
|
property LockRotation: T3DCoords read FLockRotation write FLockRotation; |
|
property Exists: Boolean read FExists write SetExists default true; |
Description
Methods
constructor Create(AOwner: TComponent); override; |
|
destructor Destroy; override; |
|
procedure Setup2D; |
|
Utility function to set common values for physics in 2D games. Locks moving along the Z axis, locks rotating along the X and Y axes. |
procedure InitializeTransform(const Transform: TCastleTransform); |
|
Connect this rigid body with Transform and Transform.World. |
procedure DeinitializeTransform(const Transform: TCastleTransform); |
|
Disconnect from Transform.World, if was connected. |
procedure Update(const Transform: TCastleTransform; const SecondsPassed: Single); |
|
function GetCollidingTransforms: TCastleTransformList; |
|
Transformations that we collide with currently. |
function PhysicsRayCast(const RayOrigin, RayDirection: TVector3; const MaxDistance: Single): TCastleTransform; overload; |
|
Cast a ray using physics engine, see what is hit. The given RayOrigin, RayDirection are in the parent coordinate system of this TCastleTransform. So for example query like this works naturally: This ignores the collider of this rigid body (to not accidentally collide with your own collider), and checks collisions with the rest of the world in given max distance. Only collisions with the physics colliders (defined inside TRigidBody.Collider) are considered. The TCastleTransform.Pickable property is ignored by this method, i.e. it considers all colliders regardless of their TCastleTransform.Pickable value. This is in contrast to TCastleTransform.RayCast. In the future this method will become the basis of a new TCastleTransform.RayCast implementation and the concept of "pickable" flag will change into collision layers. This returns the TCastleTransform that is hit and a distance from RayOrigin to the hit point. Returns |
function PhysicsRayCast(const RayOrigin, RayDirection: TVector3; const MaxDistance: Single; out Distance: Single): TCastleTransform; overload; |
|
Properties
property AngularVelocity: TVector3 read FAngularVelocity write SetAngularVelocity; |
|
property AngularVelocityDamp: Single read FAngularVelocityDamp write SetAngularVelocityDamp; |
|
property MaximalAngularVelocity: Single read FMaximalAngularVelocity write SetMaximalAngularVelocity; |
|
property LinearVelocity: TVector3 read FLinearVelocity write SetLinearVelocity; |
|
property LinearVelocityDamp: Single read FLinearVelocityDamp write SetLinearVelocityDamp; |
|
property MaximalLinearVelocity: Single read FMaximalLinearVelocity write SetMaximalLinearVelocity; |
|
property InitialAngularVelocity: TVector3 read FAngularVelocity write SetAngularVelocity; deprecated 'use AngularVelocity'; |
|
Warning: this symbol is deprecated: use AngularVelocity |
property InitialLinearVelocity: TVector3 read FLinearVelocity write SetLinearVelocity; deprecated 'use LinearVelocity'; |
|
Warning: this symbol is deprecated: use LinearVelocity |
property OnCollisionEnter: TCollisionEvent read FOnCollisionEnter write SetOnCollisionEnter; |
|
Occurs when TRigidBody starts colliding with another TRigidBody. It can occur repeatedly for the same body (in the same time instant) if the collision has many points of contact. Warning: Do not free the TCastleTransform instances that collide during this event. It would free the rigid body instance, which will crash the physics engine for now. Instead, you can set TCastleTransform.Exists to |
property OnCollisionExit: TCollisionEvent read FOnCollisionExit write SetOnCollisionExit; |
|
Occurs when TRigidBody stops colliding with another TRigidBody. Warning: Do not free the TCastleTransform instances that collide during this event. It would free the rigid body instance, which will crash the physics engine for now. Instead, you can set TCastleTransform.Exists to |
property OnCollisionStay: TCollisionEvent read FOnCollisionStay write SetOnCollisionStay; |
|
Occurs when TRigidBody still collides with another TRigidBody. Warning: Do not free the TCastleTransform instances that collide during this event. It would free the rigid body instance, which will crash the physics engine for now. Instead, you can set TCastleTransform.Exists to |
property Dynamic: Boolean read FDynamic write FDynamic default true; |
|
Does the physics simulation move and rotate this object (because of gravity, or because it collides with others).
|
property Animated: Boolean read FAnimated write FAnimated default false; |
|
Is the transformation of this object updated often (relevant only when Dynamic = This property is taken into account only if Dynamic =
|
property Trigger: Boolean read FTrigger write SetTrigger default false; |
|
Triggers report when other object collides with them, but still allow the other object to pass through. In other words, colliding with a They are useful as sensors. E.g. a Triggers report collisions through the same events as other rigid bodies: (TRigidBody.OnCollisionEnter, TRigidBody.OnCollisionStay, TRigidBody.OnCollisionExit). |
property Collider: TCollider read FCollider; |
|
Shape used for collisions with this object. You cannot assign this property directly, it is automatically assigned when you create a TCollider specifying this TRigidBody as it's parent. |
property Gravity: Boolean read FGravity write FGravity default true; |
|
Is this object affected by gravity. |
property LockTranslation: T3DCoords read FLockTranslation write FLockTranslation; |
|
Disable motion (TCastleTransform.Translation change) along the particular (world) axis. For 2D games, you will usually want to disable motion along the Z axis. Instead of directly changing this property, you can achieve this by calling Setup2D. |
property LockRotation: T3DCoords read FLockRotation write FLockRotation; |
|
Disable rotation (TCastleTransform.Rotation change) along the particular (world) axis. For 2D games, you will usually want to disable rotation along the X and Y axes. Instead of directly changing this property, you can achieve this by calling Setup2D. |
Generated by PasDoc 0.16.0.