Fireworks Engine  v2.0
Lightweight Sandbox Game Engine using OpenGL for additional Customisation and Quick Prototyping
fireworks::physics::RigidBody2D Class Reference

RigidBody 2D Physics component to simulate real time physics. More...

#include <rigidbody2d.h>

Inheritance diagram for fireworks::physics::RigidBody2D:
Collaboration diagram for fireworks::physics::RigidBody2D:

Public Member Functions

 RigidBody2D (float density, float friction, RigidBodyType bodytype, b2World &world=World)
 Creates the rigid body. More...
 
 ~RigidBody2D ()
 
glm::vec3 GetPositionInMeters ()
 Gets the position of the rigid body in meters (M.K.S system) More...
 
glm::vec3 GetPositionInPixels ()
 Gets the position of the rigid body in pixels. More...
 
float GetRotation ()
 Gets the rotation of the rigid body in radians. More...
 
void AddForce (glm::vec2 direction, float force)
 Applies force to the rigid body. More...
 
void SetVelocity (glm::vec2 velocity)
 Sets the velocity of the rigid body. More...
 
void SetPosition (const glm::vec3 &position)
 Sets the position of the rigid body. More...
 
void SetSize (glm::vec2 &size)
 Sets the size of the rigid body. More...
 
void GenerateRigidBody (glm::vec3 pos, glm::vec2 dim)
 Generates a plane rigid body using the position and dimensions. More...
 
b2Body * GetBody ()
 Gets the box2D body of the rigid body. More...
 

Public Attributes

RigidBodyType bodyType
 Denotes whether the RigidBody2D is dynamic, static or kinematic. More...
 
float density
 The density of the rigid body. More...
 
float friction
 The friction of the rigid body surface. More...
 
float resitution
 The bounciness of the rigid body. More...
 
float gravityScale
 The effect of gravity on the rigid body. More...
 
bool fixedRotation
 Whether or not to clamp the rigid bodys rotation. More...
 
- Public Attributes inherited from fireworks::components::Component
ComponentType componentType
 Basic information about the type of the component. More...
 

Additional Inherited Members

- Protected Member Functions inherited from fireworks::components::Component
 Component (const std::string &componentName, unsigned int componentID)
 Creates the component. More...
 
virtual void Dummy ()
 A Dummy method to make the class polymorphic. More...
 

Detailed Description

RigidBody 2D Physics component to simulate real time physics.

Constructor & Destructor Documentation

◆ RigidBody2D()

fireworks::physics::RigidBody2D::RigidBody2D ( float  density,
float  friction,
RigidBodyType  bodytype,
b2World &  world = World 
)

Creates the rigid body.

Parameters
densityThe density of the body
frictionThe friction of the rigid body surface
bodytypeThe type of rigid body
See also
physics::RigidBodyType for available types of rigid bodies

◆ ~RigidBody2D()

fireworks::physics::RigidBody2D::~RigidBody2D ( )

Member Function Documentation

◆ AddForce()

void fireworks::physics::RigidBody2D::AddForce ( glm::vec2  direction,
float  force 
)

Applies force to the rigid body.

Parameters
directionThe direction in which to apply force to the rigid body
forceThe magnitude of the force to apply

◆ GenerateRigidBody()

void fireworks::physics::RigidBody2D::GenerateRigidBody ( glm::vec3  pos,
glm::vec2  dim 
)

Generates a plane rigid body using the position and dimensions.

◆ GetBody()

b2Body* fireworks::physics::RigidBody2D::GetBody ( )
inline

Gets the box2D body of the rigid body.

◆ GetPositionInMeters()

glm::vec3 fireworks::physics::RigidBody2D::GetPositionInMeters ( )

Gets the position of the rigid body in meters (M.K.S system)

◆ GetPositionInPixels()

glm::vec3 fireworks::physics::RigidBody2D::GetPositionInPixels ( )

Gets the position of the rigid body in pixels.

◆ GetRotation()

float fireworks::physics::RigidBody2D::GetRotation ( )

Gets the rotation of the rigid body in radians.

Attention
The angle is in radians by default

◆ SetPosition()

void fireworks::physics::RigidBody2D::SetPosition ( const glm::vec3 &  position)

Sets the position of the rigid body.

Warning
This method doesn't work yet

◆ SetSize()

void fireworks::physics::RigidBody2D::SetSize ( glm::vec2 &  size)

Sets the size of the rigid body.

Warning
This method doesn't work yet

◆ SetVelocity()

void fireworks::physics::RigidBody2D::SetVelocity ( glm::vec2  velocity)

Sets the velocity of the rigid body.

Parameters
velocityA 2D velocity vector

Member Data Documentation

◆ bodyType

RigidBodyType fireworks::physics::RigidBody2D::bodyType

Denotes whether the RigidBody2D is dynamic, static or kinematic.

◆ density

float fireworks::physics::RigidBody2D::density

The density of the rigid body.

◆ fixedRotation

bool fireworks::physics::RigidBody2D::fixedRotation

Whether or not to clamp the rigid bodys rotation.

◆ friction

float fireworks::physics::RigidBody2D::friction

The friction of the rigid body surface.

◆ gravityScale

float fireworks::physics::RigidBody2D::gravityScale

The effect of gravity on the rigid body.

◆ resitution

float fireworks::physics::RigidBody2D::resitution

The bounciness of the rigid body.


The documentation for this class was generated from the following files: