![]() |
Jopnal Engine
alpha 0.4
Simple Component Based 2D/3D Game Engine
|
#include <RigidBody.hpp>
Classes | |
class | ConstructInfo |
Public Types | |
enum | Type { Type::Static, Type::Dynamic, Type::Kinematic, Type::StaticSensor, Type::KinematicSensor } |
Public Member Functions | |
RigidBody (Object &object, World &world, const ConstructInfo &info) | |
Constructor. More... | |
virtual | ~RigidBody () override |
Destructor. More... | |
RigidBody & | setGravityScale (const glm::vec3 &acceleration) |
Set gravity to the rigid body object. More... | |
glm::vec3 | getGravityScale () const |
Get the gravity. More... | |
RigidBody & | setFixedMovement (const glm::bvec3 &fixed) |
Sets the linear factor for rigid body. More... | |
glm::bvec3 | hasFixedMovement () const |
Check if the movement is fixed. More... | |
RigidBody & | setFixedRotation (const glm::bvec3 &axis) |
Sets/unsets the body to constantly rotate. More... | |
glm::bvec3 | hasFixedRotation () const |
Check if the rotation is fixed. More... | |
RigidBody & | applyForce (const glm::vec3 &force, const glm::vec3 &rel_pos) |
Applies constant force to rigid bodies relative position. More... | |
RigidBody & | applyImpulse (const glm::vec3 &impulse, const glm::vec3 &rel_pos) |
Applies an impulse to rigid bodies relative position. More... | |
RigidBody & | applyTorque (const glm::vec3 &torque) |
Applies torque to the rigid body. More... | |
RigidBody & | applyTorqueImpulse (const glm::vec3 &torque) |
Applies torque impulse to the rigid body. More... | |
RigidBody & | setLinearVelocity (const glm::vec3 &linearVelocity) |
Sets linear velocity to the rigid body. More... | |
glm::vec3 | getLinearVelocity () const |
Get the linear (movement) velocity. More... | |
RigidBody & | setAngularVelocity (const glm::vec3 &angularVelocity) |
Sets angular velocity to the rigid body. More... | |
glm::vec3 | getAngularVelocity () const |
Get the angular (rotational) velocity. More... | |
RigidBody & | applyCentralForce (const glm::vec3 &force) |
Applies force to the rigid body's center. More... | |
RigidBody & | applyCentralImpulse (const glm::vec3 &impulse) |
Applies impulse to the rigid body's center. More... | |
RigidBody & | clearForces () |
Clear all the forces affecting this body. More... | |
std::pair< glm::vec3, glm::vec3 > | getLocalBounds () const |
Get the local bounds of this body. More... | |
RigidBody & | synchronizeTransform () |
Sets the RigidBody position to be same as the objects' transform. More... | |
template<typename T > | |
T * | getJoint (unsigned int id=0) |
Returns a pointer to a joint on the RigidBody whence called from. More... | |
template<typename T > | |
bool | breakJoint (RigidBody &other, unsigned int IDthis=0, unsigned int IDother=0) |
Breaks a joint from the RigidBody whence called from. More... | |
template<typename T , typename... Args> | |
T & | link (RigidBody &body, Args &&...args) |
Creates a joint between this RigidBody and another RigidBody. More... | |
![]() | |
bool | checkOverlap (const Collider &other) const |
Check if this collider overlaps with another. More... | |
bool | checkContact (const Collider &other) const |
Check if this collider is in contact with another. More... | |
bool | checkRay (const glm::vec3 &start, const glm::vec3 &ray) const |
Check if a ray pierces this collider. More... | |
void | registerListener (ContactListener &listener) |
Register a listener for this collider. More... | |
World & | getWorld () |
Get the world this collider belongs to. More... | |
const World & | getWorld () const |
Get the world this collider belongs to. More... | |
void | detachFromWorld () |
Detach this body from its world. More... | |
void | attachToWorld () |
Attach this body to its world if it was previously detached. More... | |
bool | isDetachedFromWorld () const |
Check if this body is currently detached from its world. More... | |
void | updateWorldBounds () |
Force update of the world space bounds. More... | |
void | setCollisionShape (CollisionShape &shape) |
Set the collision shape. More... | |
const CollisionShape * | getCollisionShape () const |
Get the collision shape. More... | |
![]() | |
virtual | ~Component ()=0 |
Virtual destructor. More... | |
Message::Result | sendMessage (const Message &message) |
Send a message to this component. More... | |
uint32 | getID () const |
Get the identifier. More... | |
void | setID (const uint32 ID) |
Set the identifier. More... | |
WeakReference< Object > | getObject () |
Get the object this component is bound to. More... | |
WeakReference< const Object > | getObject () const |
Get the object this component is bound to. More... | |
bool | isActive () const |
Check if this component is active. More... | |
void | removeSelf () |
Remove this component from its object. More... | |
![]() | |
WeakReference< Collider > | getReference () const |
Get a weak reference to the bound object. More... | |
Protected Member Functions | |
Message::Result | receiveMessage (const Message &message) override |
Receive a message. More... | |
![]() | |
Collider (Object &object, World &world, const uint32 ID) | |
Constructor. More... | |
Collider (const Collider &other, Object &newObj) | |
Copy constructor. More... | |
virtual | ~Collider () override=0 |
Virtual destructor. More... | |
void | update (const float deltaTime) override |
Update. More... | |
void | setAllowSleep (const bool allow) |
Set whether the collider is allowed to sleep. More... | |
bool | isSleepAllowed () const |
Check if sleep is allowed. More... | |
![]() | |
Component (Object &object, const uint32 ID) | |
Constructor. More... | |
Component (const Component &other, Object &newObj) | |
Copy constructor. More... | |
![]() | |
SafeReferenceable (Collider *ref) | |
Constructor. More... | |
SafeReferenceable (SafeReferenceable< Collider > &&other) | |
Move constructor. More... | |
SafeReferenceable & | operator= (SafeReferenceable< Collider > &&other) |
Move assignment operator. More... | |
~SafeReferenceable () | |
Protected destructor. More... | |
Protected Attributes | |
std::unique_ptr< detail::MotionState > | m_motionState |
The motion state. More... | |
const Type | m_type |
The body type. More... | |
const float | m_mass |
The mass. More... | |
btRigidBody * | m_rigidBody |
Pointer to derived rigid body pointer for convenience. More... | |
std::unordered_set< std::shared_ptr< Joint > > | m_joints |
Joints. More... | |
![]() | |
std::unique_ptr< btCollisionObject > | m_body |
Body data. More... | |
World & | m_worldRef |
Reference to the world. More... | |
std::set< ContactListener * > | m_listeners |
Listeners registered for this collider. More... | |
bool | m_detached |
Is this body detached from the world? More... | |
bool | m_allowSleep |
Is sleep allowed? More... | |
Friends | |
class | Joint |
Definition at line 44 of file RigidBody.hpp.
|
strong |
Rigid body type
Enumerator | |
---|---|
Static |
Non-moving body. |
Dynamic |
Moving body. |
Kinematic |
User-animated body. |
StaticSensor |
Non-moving. |
KinematicSensor |
User-animated. |
Definition at line 56 of file RigidBody.hpp.
jop::RigidBody::RigidBody | ( | Object & | object, |
World & | world, | ||
const ConstructInfo & | info | ||
) |
Constructor.
object | Reference to the object |
world | The physics world |
info | Construction info |
|
overridevirtual |
Destructor.
RigidBody& jop::RigidBody::applyCentralForce | ( | const glm::vec3 & | force | ) |
Applies force to the rigid body's center.
force | Amount and direction of the applied force |
RigidBody& jop::RigidBody::applyCentralImpulse | ( | const glm::vec3 & | impulse | ) |
Applies impulse to the rigid body's center.
impulse | Amount and direction of the applies impulse |
RigidBody& jop::RigidBody::applyForce | ( | const glm::vec3 & | force, |
const glm::vec3 & | rel_pos | ||
) |
Applies constant force to rigid bodies relative position.
force | Amount and direction of the force |
rel_pos | Vector for the relative position on rigid body that the force applies on |
RigidBody& jop::RigidBody::applyImpulse | ( | const glm::vec3 & | impulse, |
const glm::vec3 & | rel_pos | ||
) |
Applies an impulse to rigid bodies relative position.
impulse | Amount and direction of the impulse |
rel_pos | Vector for the relative position on rigid body that the impulse applies on |
RigidBody& jop::RigidBody::applyTorque | ( | const glm::vec3 & | torque | ) |
Applies torque to the rigid body.
torque | Amount and direction as vector of the applied torque |
RigidBody& jop::RigidBody::applyTorqueImpulse | ( | const glm::vec3 & | torque | ) |
Applies torque impulse to the rigid body.
torque | Amount and direction as vector of the applied torque |
bool jop::RigidBody::breakJoint | ( | RigidBody & | other, |
unsigned int | IDthis = 0 , |
||
unsigned int | IDother = 0 |
||
) |
RigidBody& jop::RigidBody::clearForces | ( | ) |
Clear all the forces affecting this body.
glm::vec3 jop::RigidBody::getAngularVelocity | ( | ) | const |
Get the angular (rotational) velocity.
glm::vec3 jop::RigidBody::getGravityScale | ( | ) | const |
Get the gravity.
T* jop::RigidBody::getJoint | ( | unsigned int | id = 0 | ) |
glm::vec3 jop::RigidBody::getLinearVelocity | ( | ) | const |
Get the linear (movement) velocity.
std::pair<glm::vec3, glm::vec3> jop::RigidBody::getLocalBounds | ( | ) | const |
Get the local bounds of this body.
glm::bvec3 jop::RigidBody::hasFixedMovement | ( | ) | const |
Check if the movement is fixed.
glm::bvec3 jop::RigidBody::hasFixedRotation | ( | ) | const |
Check if the rotation is fixed.
T& jop::RigidBody::link | ( | RigidBody & | body, |
Args &&... | args | ||
) |
Creates a joint between this RigidBody and another RigidBody.
T is the type of the joint to create. Applicable joints are derived from Joint.
body | The other body to link with |
args | The arguments to pass to the joint's constructor |
|
overrideprotectedvirtual |
Receive a message.
Override this to handle messages sent to this. Don't forget to call the base class' method as well to ensure that the message gets forwarded correctly.
message | The message |
Reimplemented from jop::Component.
RigidBody& jop::RigidBody::setAngularVelocity | ( | const glm::vec3 & | angularVelocity | ) |
Sets angular velocity to the rigid body.
angularVelocity | Amount and direction of the angular velocity |
RigidBody& jop::RigidBody::setFixedMovement | ( | const glm::bvec3 & | fixed | ) |
Sets the linear factor for rigid body.
fixed | Axes to disable movement |
RigidBody& jop::RigidBody::setFixedRotation | ( | const glm::bvec3 & | axis | ) |
Sets/unsets the body to constantly rotate.
axis | Axes to disable rotations |
RigidBody& jop::RigidBody::setGravityScale | ( | const glm::vec3 & | acceleration | ) |
Set gravity to the rigid body object.
acceleration | Amount of the gravity to be applied as vector |
RigidBody& jop::RigidBody::setLinearVelocity | ( | const glm::vec3 & | linearVelocity | ) |
Sets linear velocity to the rigid body.
linearVelocity | Amount and direction of the linear velocity |
RigidBody& jop::RigidBody::synchronizeTransform | ( | ) |
Sets the RigidBody position to be same as the objects' transform.
|
friend |
Definition at line 50 of file RigidBody.hpp.
|
protected |
Joints.
Definition at line 317 of file RigidBody.hpp.
|
protected |
The mass.
Definition at line 314 of file RigidBody.hpp.
|
protected |
The motion state.
Definition at line 312 of file RigidBody.hpp.
|
protected |
Pointer to derived rigid body pointer for convenience.
Definition at line 315 of file RigidBody.hpp.
|
protected |
The body type.
Definition at line 313 of file RigidBody.hpp.