![]() |
Skylicht Engine
|
Represents a physical rigid body in the physics simulation. More...
#include <RigidBody/CRigidbody.h>
Public Types | |
| enum | EActivationState { Activate , Sleep , Alway , Disable } |
| Activation states for the rigid body. More... | |
| Public Types inherited from Skylicht::Physics::ICollisionObject | |
| enum | ECollisionType { Unknown , RigidBody , Character } |
| Types of collision objects. | |
Public Member Functions | |
| virtual void | initComponent () |
| virtual void | startComponent () |
| virtual void | updateComponent () |
| virtual CObjectSerializable * | createSerializable () |
| virtual void | loadSerializable (CObjectSerializable *object) |
| virtual void | setCollisionGroupAndFilter (int group, int filter) |
| Sets the collision group and filter mask. | |
| void | setTag (int i) |
| Sets a custom tag for the rigid body. | |
| int | getTag () |
| Gets the custom tag of the rigid body. | |
| void | setDynamic (bool b) |
| Sets whether the body is dynamic. | |
| bool | isDynamic () |
| Checks if the body is dynamic. | |
| void | setFriction (float f) |
| Sets the friction coefficient. | |
| float | getFriction () |
| Gets the friction coefficient. | |
| void | setRollingFriction (float f) |
| Sets the rolling friction coefficient. | |
| float | getRollingFriction () |
| Gets the rolling friction coefficient. | |
| void | setSpinningFriction (float f) |
| Sets the spinning friction coefficient. | |
| float | getSpinningFriction () |
| Gets the spinning friction coefficient. | |
| void | setMass (float m) |
| Sets the mass of the rigid body. | |
| float | getMass () |
| Gets the mass of the rigid body. | |
| void | setRestitution (float s) |
| Sets the restitution (bounciness) coefficient. | |
| float | getRestitution () |
| Gets the restitution coefficient. | |
| void | setSleepingThresholds (float linear, float angular) |
| Sets the thresholds for linear and angular velocity to enter sleep mode. | |
| void | setCcdSweptSphereRadius (float r=0.0f) |
| Sets the radius for Continuous Collision Detection (CCD). | |
| void | setCcdMotionThreshold (float m=0.0f) |
| Sets the motion threshold for Continuous Collision Detection (CCD). | |
| bool | initRigidbody () |
| Initializes the rigid body in the physics world. | |
| void | releaseRigidbody () |
| Releases the rigid body from the physics world. | |
| void | setLocalScale (const core::vector3df &scale) |
| Sets the local scale of the collision shape. | |
| core::vector3df | getLocalScale () |
| Gets the local scale of the collision shape. | |
| core::vector3df | getPosition () |
| Gets the world position of the rigid body. | |
| void | setPosition (const core::vector3df &pos) |
| Sets the world position of the rigid body. | |
| core::vector3df | getRotationEuler () |
| Gets the world rotation as Euler angles. | |
| core::quaternion | getRotation () |
| Gets the world rotation as a quaternion. | |
| void | setRotation (const core::vector3df &eulerDeg) |
| Sets the world rotation using Euler angles. | |
| void | setRotation (const core::quaternion &q) |
| Sets the world rotation using a quaternion. | |
| void | syncTransform () |
| Synchronizes the GameObject's transform with the physics body's transform. | |
| void | setState (EActivationState state) |
| Sets the activation state of the rigid body. | |
| void | activate () |
| Manually activates the rigid body (wakes it up). | |
| EActivationState | getState () |
| Gets the current activation state. | |
| const char * | getStateName () |
| Gets the name of the current activation state as a string. | |
| void | applyCenterForce (const core::vector3df &force) |
| Applies a force at the center of mass. | |
| void | applyForce (const core::vector3df &force, const core::vector3df &localPosition) |
| Applies a force at a specific local position. | |
| void | applyTorque (const core::vector3df &torque) |
| Applies a torque (rotational force). | |
| void | clearForce () |
| Clears all active forces and torques. | |
| void | applyCenterImpulse (const core::vector3df &impulse) |
| Applies an instantaneous impulse at the center of mass. | |
| void | applyImpulse (const core::vector3df &impulse, const core::vector3df &localPosition) |
| Applies an instantaneous impulse at a specific local position. | |
| void | applyTorqueImpulse (const core::vector3df &torqueImpulse) |
| Applies a torque impulse (instantaneous rotation). | |
| void | applyCenterPushImpulse (const core::vector3df &impulse) |
| Applies a push impulse at the center of mass. | |
| void | applyPushImpulse (const core::vector3df &impulse, const core::vector3df &localPosition) |
| Applies a push impulse at a specific local position. | |
| void | applyTorqueTurnImpulse (const core::vector3df &torqueImpulse) |
| Applies a torque turn impulse. | |
| core::vector3df | getLinearVelocity () |
| Gets the current linear velocity. | |
| core::vector3df | getAngularVelocity () |
| Gets the current angular velocity. | |
| void | setLinearVelocity (const core::vector3df &v) |
| Sets the linear velocity. | |
| void | setAngularVelocity (const core::vector3df &v) |
| Sets the angular velocity. | |
| bool | needUpdateTransform () |
| Checks if the transform needs updating. | |
| void | notifyUpdateTransform (bool b) |
| Notifies the component about transform update status. | |
| void | setDrawDebug (bool b) |
| Enables or disables debug drawing for this specific rigid body. | |
| bool | enableDrawDebug () |
| Checks if debug drawing is enabled for this body. | |
| core::matrix4 | getWorldTransform () |
| Gets the current world transform matrix. | |
| Public Member Functions inherited from Skylicht::Physics::ICollisionObject | |
| ECollisionType | getCollisionType () |
| Gets the collision type. | |
| int | getCollisionGroup () |
| Gets the collision group bitmask. | |
| int | getCollisionFilter () |
| Gets the collision filter bitmask. | |
| Public Member Functions inherited from Skylicht::CComponentSystem | |
| const char * | getName () |
| virtual void | reset () |
| virtual void | endUpdate () |
| virtual void | onEnable (bool b) |
| virtual void | onUpdateCullingLayer (u32 mask) |
| void | setEnable (bool b) |
| bool | isEnable () |
| CGameObject * | getGameObject () |
| void | setEnableSerializable (bool b) |
| bool | isSerializable () |
| void | addLinkComponent (CComponentSystem *comp) |
| void | removeAllLink () |
| Public Member Functions inherited from Skylicht::IActivatorObject | |
| virtual | ~IActivatorObject () |
| Virtual destructor for polymorphic activator objects. | |
Protected Attributes | |
| bool | m_isDynamic |
| float | m_mass |
| float | m_restitution |
| float | m_friction |
| float | m_rollingFriction |
| float | m_spinningFriction |
| bool | m_needUpdateTransform |
| bool | m_drawDebug |
| int | m_tag |
| Protected Attributes inherited from Skylicht::Physics::ICollisionObject | |
| ECollisionType | m_collisionType |
| int | m_group |
| int | m_filter |
| Protected Attributes inherited from Skylicht::CComponentSystem | |
| CGameObject * | m_gameObject |
| bool | m_enable |
| bool | m_serializable |
| std::vector< CComponentSystem * > | m_linkComponent |
Friends | |
| class | CPhysicsEngine |
Additional Inherited Members | |
| Static Public Member Functions inherited from Skylicht::CComponentSystem | |
| static int | useComponent (CComponentSystem *used) |
| Public Attributes inherited from Skylicht::Physics::ICollisionObject | |
| std::function< void(ICollisionObject *, ICollisionObject *, SCollisionContactPoint *, int)> | OnCollision |
| Callback function triggered when a collision occurs. | |
| Protected Member Functions inherited from Skylicht::CComponentSystem | |
| void | setOwner (CGameObject *obj) |
Represents a physical rigid body in the physics simulation.
A rigid body can be dynamic (affected by forces and gravity) or static/kinematic. It must be attached to a GameObject that also has a CCollider component.
Example: Creating a dynamic box
Example: Creating a static/kinematic floor
| void Skylicht::Physics::CRigidbody::applyCenterForce | ( | const core::vector3df & | force | ) |
Applies a force at the center of mass.
| force | Force vector. |
| void Skylicht::Physics::CRigidbody::applyCenterImpulse | ( | const core::vector3df & | impulse | ) |
Applies an instantaneous impulse at the center of mass.
| impulse | Impulse vector. |
| void Skylicht::Physics::CRigidbody::applyCenterPushImpulse | ( | const core::vector3df & | impulse | ) |
Applies a push impulse at the center of mass.
| impulse | Push impulse vector. |
| void Skylicht::Physics::CRigidbody::applyForce | ( | const core::vector3df & | force, |
| const core::vector3df & | localPosition ) |
Applies a force at a specific local position.
| force | Force vector. |
| localPosition | Local offset from the center of mass. |
| void Skylicht::Physics::CRigidbody::applyImpulse | ( | const core::vector3df & | impulse, |
| const core::vector3df & | localPosition ) |
Applies an instantaneous impulse at a specific local position.
| impulse | Impulse vector. |
| localPosition | Local offset from the center of mass. |
| void Skylicht::Physics::CRigidbody::applyPushImpulse | ( | const core::vector3df & | impulse, |
| const core::vector3df & | localPosition ) |
Applies a push impulse at a specific local position.
| impulse | Push impulse vector. |
| localPosition | Local offset from the center of mass. |
| void Skylicht::Physics::CRigidbody::applyTorque | ( | const core::vector3df & | torque | ) |
Applies a torque (rotational force).
| torque | Torque vector. |
| void Skylicht::Physics::CRigidbody::applyTorqueImpulse | ( | const core::vector3df & | torqueImpulse | ) |
Applies a torque impulse (instantaneous rotation).
| torqueImpulse | Torque impulse vector. |
| void Skylicht::Physics::CRigidbody::applyTorqueTurnImpulse | ( | const core::vector3df & | torqueImpulse | ) |
Applies a torque turn impulse.
| torqueImpulse | Torque impulse vector. |
|
virtual |
Reimplemented from Skylicht::CComponentSystem.
|
inline |
Checks if debug drawing is enabled for this body.
| core::vector3df Skylicht::Physics::CRigidbody::getAngularVelocity | ( | ) |
Gets the current angular velocity.
|
inline |
Gets the friction coefficient.
| core::vector3df Skylicht::Physics::CRigidbody::getLinearVelocity | ( | ) |
Gets the current linear velocity.
| core::vector3df Skylicht::Physics::CRigidbody::getLocalScale | ( | ) |
Gets the local scale of the collision shape.
|
inline |
Gets the mass of the rigid body.
| core::vector3df Skylicht::Physics::CRigidbody::getPosition | ( | ) |
Gets the world position of the rigid body.
|
inline |
Gets the restitution coefficient.
|
inline |
Gets the rolling friction coefficient.
| core::quaternion Skylicht::Physics::CRigidbody::getRotation | ( | ) |
Gets the world rotation as a quaternion.
| core::vector3df Skylicht::Physics::CRigidbody::getRotationEuler | ( | ) |
Gets the world rotation as Euler angles.
|
inline |
Gets the spinning friction coefficient.
| EActivationState Skylicht::Physics::CRigidbody::getState | ( | ) |
Gets the current activation state.
| const char * Skylicht::Physics::CRigidbody::getStateName | ( | ) |
Gets the name of the current activation state as a string.
|
inline |
Gets the custom tag of the rigid body.
| core::matrix4 Skylicht::Physics::CRigidbody::getWorldTransform | ( | ) |
Gets the current world transform matrix.
|
virtual |
Implements Skylicht::CComponentSystem.
| bool Skylicht::Physics::CRigidbody::initRigidbody | ( | ) |
Initializes the rigid body in the physics world.
|
inline |
Checks if the body is dynamic.
|
virtual |
Reimplemented from Skylicht::CComponentSystem.
|
inline |
Checks if the transform needs updating.
|
inline |
Notifies the component about transform update status.
| b | Update status. |
| void Skylicht::Physics::CRigidbody::setAngularVelocity | ( | const core::vector3df & | v | ) |
Sets the angular velocity.
| v | Angular velocity vector. |
| void Skylicht::Physics::CRigidbody::setCcdMotionThreshold | ( | float | m = 0.0f | ) |
Sets the motion threshold for Continuous Collision Detection (CCD).
| m | Motion threshold value. |
| void Skylicht::Physics::CRigidbody::setCcdSweptSphereRadius | ( | float | r = 0.0f | ) |
Sets the radius for Continuous Collision Detection (CCD).
| r | Radius value. |
|
virtual |
Sets the collision group and filter mask.
| group | Bitmask representing the collision group. |
| filter | Bitmask representing which groups this object should collide with. |
Reimplemented from Skylicht::Physics::ICollisionObject.
|
inline |
Enables or disables debug drawing for this specific rigid body.
| b | True to enable, false to disable. |
| void Skylicht::Physics::CRigidbody::setDynamic | ( | bool | b | ) |
Sets whether the body is dynamic.
| b | True for dynamic, false for static/kinematic. |
| void Skylicht::Physics::CRigidbody::setFriction | ( | float | f | ) |
Sets the friction coefficient.
| f | Friction value. |
| void Skylicht::Physics::CRigidbody::setLinearVelocity | ( | const core::vector3df & | v | ) |
Sets the linear velocity.
| v | Velocity vector. |
| void Skylicht::Physics::CRigidbody::setLocalScale | ( | const core::vector3df & | scale | ) |
Sets the local scale of the collision shape.
| scale | Scale vector. |
| void Skylicht::Physics::CRigidbody::setMass | ( | float | m | ) |
Sets the mass of the rigid body.
| m | Mass value. |
| void Skylicht::Physics::CRigidbody::setPosition | ( | const core::vector3df & | pos | ) |
Sets the world position of the rigid body.
| pos | Position vector. |
| void Skylicht::Physics::CRigidbody::setRestitution | ( | float | s | ) |
Sets the restitution (bounciness) coefficient.
| s | Restitution value. |
| void Skylicht::Physics::CRigidbody::setRollingFriction | ( | float | f | ) |
Sets the rolling friction coefficient.
| f | Rolling friction value. |
| void Skylicht::Physics::CRigidbody::setRotation | ( | const core::quaternion & | q | ) |
Sets the world rotation using a quaternion.
| q | Rotation quaternion. |
| void Skylicht::Physics::CRigidbody::setRotation | ( | const core::vector3df & | eulerDeg | ) |
Sets the world rotation using Euler angles.
| eulerDeg | Euler angles in degrees. |
| void Skylicht::Physics::CRigidbody::setSleepingThresholds | ( | float | linear, |
| float | angular ) |
Sets the thresholds for linear and angular velocity to enter sleep mode.
| linear | Linear velocity threshold. |
| angular | Angular velocity threshold. |
| void Skylicht::Physics::CRigidbody::setSpinningFriction | ( | float | f | ) |
Sets the spinning friction coefficient.
| f | Spinning friction value. |
| void Skylicht::Physics::CRigidbody::setState | ( | EActivationState | state | ) |
Sets the activation state of the rigid body.
| state | New activation state. |
|
inline |
Sets a custom tag for the rigid body.
| i | Tag value. |
|
virtual |
Reimplemented from Skylicht::CComponentSystem.
|
virtual |
Implements Skylicht::CComponentSystem.