|
Dura2D
v0.1.0
An educational 2D game physics library
|
A class representing a 2D rigid body. More...
#include <d2Body.h>
Public Member Functions | |
| d2Body (const d2Shape &shape, real x, real y, real mass, d2World *world) | |
| Constructor for the d2Body class. | |
| ~d2Body () | |
| Destructor for the d2Body class. | |
| void | ComputeAABB () |
| Computes the Axis-Aligned Bounding Box of the body. | |
| void | AddForce (const d2Vec2 &force) |
| Adds a force to the body. | |
| void | AddTorque (real torque) |
| Adds a torque to the body. | |
| void | ClearForces () |
| Clears all forces applied to the body. | |
| void | ClearTorque () |
| Clears all torques applied to the body. | |
| d2Vec2 | LocalSpaceToWorldSpace (const d2Vec2 &point) const |
| Converts a point from local space to world space. | |
| d2Vec2 | WorldSpaceToLocalSpace (const d2Vec2 &point) const |
| Converts a point from world space to local space. | |
| void | ApplyImpulseLinear (const d2Vec2 &j) |
| Applies a linear impulse to the body. | |
| void | ApplyImpulseAngular (const real j) |
| Applies an angular impulse to the body. | |
| void | ApplyImpulseAtPoint (const d2Vec2 &j, const d2Vec2 &r) |
| Applies an impulse at a specific point on the body. | |
| void | IntegrateLinear (real dt) |
| Integrates the linear motion of the body over a time step. | |
| void | IntegrateAngular (real dt) |
| Integrates the angular motion of the body over a time step. | |
| void | IntegrateForces (const real dt) |
| Integrates the forces applied to the body over a time step. | |
| void | IntegrateVelocities (const real dt) |
| Integrates the velocities of the body over a time step. | |
| const d2Vec2 & | GetPosition () const |
| Gets the position of the body. | |
| void | SetPosition (const d2Vec2 &position) |
| Sets the position of the body. | |
| const d2Vec2 & | GetVelocity () const |
| Gets the velocity of the body. | |
| void | SetAcceleration (const d2Vec2 &acceleration) |
| Set acceleration of the body. | |
| void | SetAngularVelocity (real angularVelocity) |
| Sets the angular velocity of the body. | |
| real | GetAngularVelocity () const |
| Gets the angular velocity of the body. | |
| real | GetRotation () const |
| Gets the rotation angle of the body. | |
| real | GetMass () const |
| Gets the mass of the body. | |
| real | GetInvMass () const |
| Gets the inverse mass of the body. | |
| real | GetI () const |
| Gets the moment of inertia of the body. | |
| real | GetInvI () const |
| Gets the inverse moment of inertia of the body. | |
| void | SetFriction (real friction) |
| Sets the coefficient of friction of the body. | |
| real | GetFriction () const |
| Gets the coefficient of friction of the body. | |
| void | SetRestitution (real restitution) |
| Sets the coefficient of restitution of the body. | |
| real | GetRestitution () const |
| Gets the coefficient of restitution of the body. | |
| d2Shape * | GetShape () const |
| Gets the shape/geometry of the body. | |
| d2AABB * | GetAABB () const |
| Gets the Axis-Aligned Bounding Box of the body. | |
| d2Body * | GetNext () |
| Gets the next body in a linked list of bodies. | |
| const d2Body * | GetNext () const |
| d2Body * | GetPrev () |
| Gets the previous body in a linked list of bodies. | |
| const d2Body * | GetPrev () const |
| real | GetSleepTime () const |
| Gets wake-up time of the body. | |
| bool | IsAwake () const |
| Gets the wake state of the body. | |
| void | SetAwake (bool awake) |
| Sets the wake state of the body. | |
| real | GetGravityScale () const |
| Gets the gravity scale of the body. | |
| void | SetGravityScale (real gravityScale) |
| Sets the gravity scale of the body. | |
Friends | |
| class | d2World |
A class representing a 2D rigid body.
This class encapsulates the properties and behaviors of a 2D rigid body.
Constructor for the d2Body class.
| shape | The shape/geometry of the body. |
| x | The initial x-coordinate of the body. |
| y | The initial y-coordinate of the body. |
| mass | The mass of the body. |
| d2Body::~d2Body | ( | ) |
Destructor for the d2Body class.
| void d2Body::AddForce | ( | const d2Vec2 & | force | ) |
Adds a force to the body.
| force | The force to be added. |
| void d2Body::AddTorque | ( | real | torque | ) |
Adds a torque to the body.
| torque | The torque to be added. |
| void d2Body::ApplyImpulseAngular | ( | const real | j | ) |
Applies an angular impulse to the body.
| j | The impulse to be applied. |
Applies an impulse at a specific point on the body.
| j | The impulse to be applied. |
| r | The point at which the impulse is applied. |
| void d2Body::ApplyImpulseLinear | ( | const d2Vec2 & | j | ) |
Applies a linear impulse to the body.
| j | The impulse to be applied. |
| void d2Body::ClearForces | ( | ) |
Clears all forces applied to the body.
| void d2Body::ClearTorque | ( | ) |
Clears all torques applied to the body.
| void d2Body::ComputeAABB | ( | ) |
Computes the Axis-Aligned Bounding Box of the body.
|
inline |
Gets the Axis-Aligned Bounding Box of the body.
|
inline |
Gets the angular velocity of the body.
|
inline |
Gets the coefficient of friction of the body.
|
inline |
Gets the gravity scale of the body.
|
inline |
Gets the moment of inertia of the body.
|
inline |
Gets the inverse moment of inertia of the body.
|
inline |
Gets the inverse mass of the body.
|
inline |
Gets the mass of the body.
|
inline |
Gets the next body in a linked list of bodies.
|
inline |
|
inline |
Gets the position of the body.
|
inline |
Gets the previous body in a linked list of bodies.
|
inline |
|
inline |
Gets the coefficient of restitution of the body.
|
inline |
Gets the rotation angle of the body.
|
inline |
Gets the shape/geometry of the body.
|
inline |
Gets wake-up time of the body.
|
inline |
Gets the velocity of the body.
| void d2Body::IntegrateAngular | ( | real | dt | ) |
Integrates the angular motion of the body over a time step.
| dt | The time step. |
| void d2Body::IntegrateForces | ( | const real | dt | ) |
Integrates the forces applied to the body over a time step.
| dt | The time step. |
| void d2Body::IntegrateLinear | ( | real | dt | ) |
Integrates the linear motion of the body over a time step.
| dt | The time step. |
| void d2Body::IntegrateVelocities | ( | const real | dt | ) |
Integrates the velocities of the body over a time step.
| dt | The time step. |
|
inline |
Gets the wake state of the body.
Converts a point from local space to world space.
| point | The point in local space. |
|
inline |
Set acceleration of the body.
|
inline |
Sets the angular velocity of the body.
|
inline |
Sets the wake state of the body.
| awake | The wake state of the body. |
|
inline |
Sets the coefficient of friction of the body.
|
inline |
Sets the gravity scale of the body.
|
inline |
Sets the position of the body.
| position | The position of the body. |
|
inline |
Sets the coefficient of restitution of the body.
Converts a point from world space to local space.
| point | The point in world space. |
|
friend |