Gorilla.Physics
Unit Gorilla.Physics.pasClasses
- TGorillaContactListener = class ( TQ3ContactListener )
- TGorillaPhysicsSystem = class ( TGorillaControl )
Records
- record TGorillaColliderSettings
Enumerations
- enum TGorillaPhysicsBodyType = ( eStaticBody, eDynamicBody, eKinematicBody ) ;
TGorillaPhysicsBodyType
Type of body
Remarks
A body is defined by one of these 3 kinds. static bodies - will not move or influenced by mass and impulses Use this type for defining a plane / floor dynamic bodies - will move, handle forces influenced by mass and impulses Use this type by default for any kind of physics-engine handled instances. kinematic bodies - will move but will not be influenced by mass and impulses Use this type as an alternative to dynamic bodies.TGorillaContactListener
A ContactListener is a callback instance for collision detection. Use this component to react individually on collision. By default a contact listener is created inside of the physics system.
Ancestors
Members
TGorillaPhysicsSystem
User component for physics computation. The Gorilla physics system uses internally the Q3 Physics Engine.
Ancestors
Members
Fields
- protected FEngine :
TQ3Scene
- protected FListener :
TGorillaContactListener
- protected FOnBeginContact :
TOnGorillaPhysicsNotifyContact
- protected FOnEndContact :
TOnGorillaPhysicsNotifyContact
Methods
- public constructor Create ( AOwner : TComponent ) ;
- public destructor Destroy ( ) ;
- protected procedure DoOnQ3BodyUpdate ( ASender : TObject; const ACollider : TQ3Collider ) ;
- protected function GetActive ( ) : Boolean ;
- protected procedure SetActive ( const AValue : Boolean ) ;
- protected procedure DoAddBoxCollider ( const AData : Pointer; const AType : PTypeInfo; const APrefab : TGorillaColliderSettings; const AAbsoluteMatrix : TMatrix3D; const ASize : TPoint3D; out ABody : TQ3Body ) ; virtual;
- protected procedure DoAddSphereCollider ( const AData : Pointer; const AType : PTypeInfo; const APrefab : TGorillaColliderSettings; const AAbsoluteMatrix : TMatrix3D; const ARadius : Single; out ABody : TQ3Body ) ; virtual;
- protected procedure DoAddTerrainCollider ( const AData : Pointer; const AType : PTypeInfo; const APrefab : TGorillaColliderSettings; const AAbsoluteMatrix : TMatrix3D; const AMeshMatrix : TMatrix3D; const ASize : TPoint3D; const AMeshData : TMeshData; out ABody : TQ3Body ) ; virtual;
- protected procedure DoAddMeshCollider ( const AData : Pointer; const AType : PTypeInfo; const APrefab : TGorillaColliderSettings; const AAbsoluteMatrix : TMatrix3D; const AMeshMatrix : TMatrix3D; const ASize : TPoint3D; const AMeshData : TMeshData; out ABody : TQ3Body ) ; virtual;
- public procedure AddBoxCollider
(
const
AMesh :
TCustomMesh; const
APrefab :
TGorillaColliderSettings
)
;
overload;
Add a box collider for a specific TCustomMesh instance to the physics system. At first you will need to create a TGorillaColliderSettings structure where to define the body type (static, dynamic, kinematic)
- public procedure AddBoxCollider
(
const
AControl :
TGorillaControl; const
APrefab :
TGorillaColliderSettings
)
;
overload;
Add a box collider for a specific TGorillaControl instance to the physics system. At first you will need to create a TGorillaColliderSettings structure where to define the body type (static, dynamic, kinematic)
- public procedure AddSphereCollider
(
const
AMesh :
TCustomMesh; const
APrefab :
TGorillaColliderSettings
)
;
overload;
Add a spherical collider for a specific TCustomMesh instance to the physics system. At first you will need to create a TGorillaColliderSettings structure where to define the body type (static, dynamic, kinematic)
- public procedure AddSphereCollider
(
const
AControl :
TGorillaControl; const
APrefab :
TGorillaColliderSettings
)
;
overload;
Add a spherical collider for a specific TGorillaControl instance to the physics system. At first you will need to create a TGorillaColliderSettings structure where to define the body type (static, dynamic, kinematic)
- public procedure AddParticleCollider
(
const
AData :
Pointer; const
AType :
PTypeInfo; const
APrefab :
TGorillaColliderSettings; const
ATransformation :
TMatrix3D; const
ARadius :
Single; out
ABody :
TQ3Body
)
;
Add a particle collider for a specific pointer value to the physics system. At first you will need to create a TGorillaColliderSettings structure where to define the body type (static, dynamic, kinematic). Also provide a starting transformation matrix and a radius of the particle. The procedure will return a TQ3Body instance as pointer which should be linked with your particle structure (AParticle). This method is automatically used by the physics particle influencer class.
- public procedure AddTerrainCollider
(
const
AMesh :
TCustomMesh; const
APrefab :
TGorillaColliderSettings
)
;
overload;
Add a terrain collider for a specific TCustomMesh (terrain) instance to the physics system. At first you will need to create a TGorillaColliderSettings structure where to define the body type (static, dynamic, kinematic). Of course the body type is flexible, but for terrains you should use the static body type.
- public procedure AddTerrainCollider
(
const
ATerrain :
TGorillaTerrain; const
APrefab :
TGorillaColliderSettings
)
;
overload;
Add a terrain collider for a specific TGorillaTerrain instance to the physics system. At first you will need to create a TGorillaColliderSettings structure where to define the body type (static, dynamic, kinematic). Of course the body type is flexible, but for terrains you should use the static body type.
- public procedure AddCapsuleCollider
(
const
AMesh :
TCustomMesh; const
APrefab :
TGorillaColliderSettings
)
;
Add a capsule collider for a specific TCustomMesh instance to the physics system. At first you will need to create a TGorillaColliderSettings structure where to define the body type (static, dynamic, kinematic)
- public procedure AddMeshCollider
(
const
AMesh :
TCustomMesh; const
APrefab :
TGorillaColliderSettings
)
;
overload;
Add a capsule collider for a specific TCustomMesh instance to the physics system. At first you will need to create a TGorillaColliderSettings structure where to define the body type (static, dynamic, kinematic)
- public procedure AddMeshCollider
(
const
AMesh :
TGorillaMesh; const
APrefab :
TGorillaColliderSettings
)
;
overload;
Add a capsule collider for a specific TGorillaMesh instance to the physics system. At first you will need to create a TGorillaColliderSettings structure where to define the body type (static, dynamic, kinematic)
- public procedure RemoveCollider
(
const
AMesh :
TControl3D
)
;
overload;
Remove an existing collider for a specific TControl3D object. The method will automatically request the TQ3Body and remove it from physics system.
- public procedure RemoveCollider
(
const
ABody :
TQ3Body
)
;
overload;
Remove an existing collider. The method expects the specific body instance to be removed. This method will be used by the particle system. But of course you can use this method in case you handled the TQ3Body instances anywhere else.
- public procedure RemoteMeshTransform
(
const
ACtrl :
TControl3D
)
;
overload;
The method allows to modify position and rotation for a specific TControl3D in the physics system from external. This may be useful when there are external influences the physics system do not know of.
- public procedure RemoteBodyTransform
(
const
ABody :
TQ3Body; const
ATranslation :
TPoint3D; const
ARotationAngle :
TPoint3D
)
;
overload;
The method allows to modify position and rotation for a specific TQ3Body in the physics system from external by a translation and rotation value. This may be useful when there are external influences the physics system do not know of.
- public procedure RemoteBodyTransform
(
const
ACtrl :
TControl3D; const
ATranslation :
TPoint3D; const
ARotationAngle :
TPoint3D
)
;
overload;
The method allows to modify position and rotation for a specific control in the physics system from external by a translation and rotation value. This may be useful when there are external influences the physics system do not know of.
- public procedure RemoteBodyImpulse
(
const
ABody :
TQ3Body; const
AImpulse :
TPoint3D
)
;
overload;
Applies an impulse on a specific body. Use this method to push a physics controlled body, f.e. for third person models.
- public procedure RemoteBodyImpulse
(
const
ACtrl :
TControl3D; const
AImpulse :
TPoint3D
)
;
overload;
Applies an impulse on a specific control. Use this method to push a physics controlled body, f.e. for third person models.
- public procedure RemoteBodyForce
(
const
ABody :
TQ3Body; const
AForce :
TPoint3D
)
;
overload;
Applies a force on a specific body. Use this method to push a physics controlled body, f.e. for third person models.
- public procedure RemoteBodyForce
(
const
ACtrl :
TControl3D; const
AForce :
TPoint3D
)
;
overload;
Applies a force on a specific control. Use this method to push a physics controlled body, f.e. for third person models.
- public function GetDeltaTime
(
)
: Single
;
Returns the delta time, which is the time since the last step. The value returned is computed in milliseconds.
- public procedure Step
(
const
ADeltaTime :
Single
)
;
Use this method to execute physics calculation. This method needs to be called in constant interval. We recommend to use a 33ms interval, f.e. by a TTimer component. Submit the deltatime since the last step. You can use an individual value or simple request the auto computed value of the engine: <TGorillaPhysicsSystem>.GetDeltaTime()
Properties
- public Engine : TQ3Scene
TGorillaPhysicsEngine is just a wrapper component. This property is the currently available internal physics engine. At the current development state we provide physics by the Q3 physics engine.
read FEngine - published Active : Boolean