![]() |
Rune Engine
Version 0.2.7-alpha
Documentation for how to make games using the Rune Engine.
|
Game object component that allows a game object to have collisions with other objects. More...
#include <rigidBody.h>
Public Member Functions | |
virtual void | start () |
Initialize the physics::RigidBody to be approximately the same size as the rune::GameObject. | |
RigidBody (double mass=0, rune::Vec2 gravity=rune::Vec2(0, 0)) | |
Constructor to set up mass data of the RigidBody. More... | |
void | setUpObject (int width, int height, double mass, bool rotation) |
Set up the object. Identical to the constructor but can be used to set up an object after it's been created. More... | |
void | updateAABB () |
Recalculate the AABB based on the rigid body position. | |
void | setMass (float newMass) |
Set the mass of the object, more massive objects will react more slowly to collisions. More... | |
AABB | getBoundingBox (void) |
Return an AABB containing the information about the rigid body bounding box. More... | |
void | addAngularVelocity (double angularVel) |
Adds to the rigid body angular velocity making it spin faster or slower. More... | |
void | setRotation (double angle) |
Overwrite the orientation of the rigid body to be something new. More... | |
void | setPosition (rune::Vec2) |
Overwrite the position of the rigid body to be something new. More... | |
void | addPosition (rune::Vec2 newPos) |
Add some vector to the current position. More... | |
rune::Vec2 | getPosition (void) |
Get the current rigid body position. More... | |
void | addVelocity (rune::Vec2) |
Add to the objects current velocity vector. More... | |
void | updatePosition (double dT) |
Update the position of the object based on collisions and velocities. More... | |
void | interpolatePosition (double alpha) |
Linearly interpolate the position of the rune::RigidBody for editing to transform of the parent object. More... | |
rune::Vec2 | getGravity (void) |
Get the gravity vector of the object. More... | |
rune::Vec2 | getVelocity (void) |
Get the current velocity of the rigid body. More... | |
void | setVelocity (rune::Vec2) |
Set the current velocity of the rigid body. More... | |
rune::Vec2 | getVertex (int) |
Return the current position of a vertex in world coordinates. More... | |
double | getInvMass (void) |
Get the inverse mass of the rigid body. More... | |
double | getInvIntertia (void) |
Get the inverse inertia of the rigid body. More... | |
double | getRestitution (void) |
Return the restitution (bounciness) of the rigid body. More... | |
void | setRestitution (double) |
Set the restitution (bounciness) of the rigid body. More... | |
double | getStaticFriction (void) |
Get the coefficient of static friction. More... | |
void | setStaticFriction (float friction) |
Set the coefficient of static friction. | |
double | getDynamicFriction (void) |
Get the coefficient of dynamic friction. More... | |
void | setDynamicFriction (float friction) |
Set the coefficient of dynamic friction. | |
double | getOrientation (void) |
Get the current orientation of the rigid body. More... | |
double | getWidth (void) |
Get the width of the AABB. More... | |
double | getHeight (void) |
Get the height of the AABB. More... | |
rune::Vec2 | getPreviousPosition (void) |
Get the position that the rigid body was in last frame. More... | |
void | setPreviousPosition (rune::Vec2) |
Set the position that the rigid body was in last frame. More... | |
void | clearCollisions (void) |
Clear the list of collisions that rigid body is involved with. | |
void | addCollision (collision) |
Add a collision to the list of collisions the rigid body was involved in. More... | |
std::vector< collision > | getCollisions (void) |
Get the list of collisions the rigid body was involved in. More... | |
body * | getBodyStruct (void) |
Get the rigidBody struct for modification. More... | |
![]() | |
Component ()=default | |
Default constructor to set up. | |
virtual void | awake () |
A function that will be called before all other start functions but after the component has been assigned to a GameObject. | |
virtual void | update () |
A function for each component that is called every frame. | |
virtual void | fixedUpdate () |
A function for each component that is called once every physics update. | |
void | setParent (GameObject *newParent) |
A function to set the pointer to the parent rune::GameObject for each component. More... | |
void | setEnable (bool newEnable) |
Enable or disable the component. More... | |
bool | isComponentEnabled (void) |
Gets whether or not the current component is enabled. | |
void | onNotify (Signal const &signal) override |
A virtual method to be overridden by a concrete implementation of the observer class. | |
Additional Inherited Members | |
![]() | |
GameObject * | parentObject = nullptr |
The rune::GameObject that this component is attached to. If not attached to a rune::GameObject this will equal nullptr. | |
bool | isEnabled = true |
Whether or not the component is currently enabled. If not enabled, update function will not be called. | |
Game object component that allows a game object to have collisions with other objects.
physics::RigidBody::RigidBody | ( | double | mass = 0 , |
rune::Vec2 | gravity = rune::Vec2(0,0) |
||
) |
void physics::RigidBody::addAngularVelocity | ( | double | angularVel | ) |
Adds to the rigid body angular velocity making it spin faster or slower.
angularVel | Angular velocity to be added to the RigidBody. |
void physics::RigidBody::addCollision | ( | collision | newCollision | ) |
Add a collision to the list of collisions the rigid body was involved in.
newCollision | Collision manifold to be stored in the GameObject associated with the RigidBody. |
void physics::RigidBody::addPosition | ( | rune::Vec2 | newPos | ) |
Add some vector to the current position.
newPos | Position vector to be added to the object's current position. |
void physics::RigidBody::addVelocity | ( | rune::Vec2 | velocity | ) |
Add to the objects current velocity vector.
velocity | Velocity vector to be added to the current object velocity. |
physics::body * physics::RigidBody::getBodyStruct | ( | void | ) |
Get the rigidBody struct for modification.
physics::AABB physics::RigidBody::getBoundingBox | ( | void | ) |
std::vector< physics::collision > physics::RigidBody::getCollisions | ( | void | ) |
Get the list of collisions the rigid body was involved in.
double physics::RigidBody::getDynamicFriction | ( | void | ) |
Get the coefficient of dynamic friction.
rune::Vec2 physics::RigidBody::getGravity | ( | void | ) |
Get the gravity vector of the object.
double physics::RigidBody::getHeight | ( | void | ) |
double physics::RigidBody::getInvIntertia | ( | void | ) |
Get the inverse inertia of the rigid body.
double physics::RigidBody::getInvMass | ( | void | ) |
Get the inverse mass of the rigid body.
double physics::RigidBody::getOrientation | ( | void | ) |
Get the current orientation of the rigid body.
rune::Vec2 physics::RigidBody::getPosition | ( | void | ) |
Get the current rigid body position.
rune::Vec2 physics::RigidBody::getPreviousPosition | ( | void | ) |
Get the position that the rigid body was in last frame.
double physics::RigidBody::getRestitution | ( | void | ) |
Return the restitution (bounciness) of the rigid body.
double physics::RigidBody::getStaticFriction | ( | void | ) |
Get the coefficient of static friction.
rune::Vec2 physics::RigidBody::getVelocity | ( | void | ) |
Get the current velocity of the rigid body.
rune::Vec2 physics::RigidBody::getVertex | ( | int | i | ) |
Return the current position of a vertex in world coordinates.
i | The index of the RigidBody vertex starting in the top left and going counter clockwise around. |
double physics::RigidBody::getWidth | ( | void | ) |
void physics::RigidBody::interpolatePosition | ( | double | alpha | ) |
Linearly interpolate the position of the rune::RigidBody for editing to transform of the parent object.
alpha | linear interpolation factor. |
void physics::RigidBody::setMass | ( | float | newMass | ) |
Set the mass of the object, more massive objects will react more slowly to collisions.
newMass | The new mass of the object. |
void physics::RigidBody::setPosition | ( | rune::Vec2 | newPos | ) |
Overwrite the position of the rigid body to be something new.
newPos | Set the position of the RigidBody in world coordinates. |
void physics::RigidBody::setPreviousPosition | ( | rune::Vec2 | newPos | ) |
Set the position that the rigid body was in last frame.
newPos | The position that the RigidBody was last frame. |
void physics::RigidBody::setRestitution | ( | double | newRest | ) |
Set the restitution (bounciness) of the rigid body.
newRest | Override the restitution of the RigidBody. |
void physics::RigidBody::setRotation | ( | double | angle | ) |
Overwrite the orientation of the rigid body to be something new.
angle | New orientation for the RigidBody to be set to. |
void physics::RigidBody::setUpObject | ( | int | width, |
int | height, | ||
double | mass, | ||
bool | rotation | ||
) |
Set up the object. Identical to the constructor but can be used to set up an object after it's been created.
width | Width of the rigid body in pixels, should be the same as the GameObject sprite. |
height | Height of the rigid body in pixels, should be the same as the GameObject sprite. |
mass | Mass of the RigidBody to be used for physical simulations. |
rotation | Whether or not the RigidBody is allowed to rotate in 2D space. |
void physics::RigidBody::setVelocity | ( | rune::Vec2 | newVel | ) |
Set the current velocity of the rigid body.
newVel | Velocity vector that will override the current object velocity. |
void physics::RigidBody::updatePosition | ( | double | dT | ) |
Update the position of the object based on collisions and velocities.
dT | Amount of time in seconds that has passed since the last update. Used to calculate change in position based on velocity. |