3 #include <box2d/box2d.h> 5 #include <glm/gtc/matrix_transform.hpp> 6 #include "../components/component.h" 9 static const b2Vec2 gravity(0.0f, -10.0f);
10 static b2World World(gravity);
46 b2PolygonShape m_Shape;
47 b2FixtureDef m_Fixture;
73 void AddForce(glm::vec2 direction,
float force);
90 inline b2Body*
GetBody() {
return m_Body; }
~RigidBody2D()
Definition: rigidbody2d.cpp:8
bool fixedRotation
Whether or not to clamp the rigid bodys rotation.
Definition: rigidbody2d.h:41
float resitution
The bounciness of the rigid body.
Definition: rigidbody2d.h:37
float density
The density of the rigid body.
Definition: rigidbody2d.h:33
Definition: rigidbody2d.h:23
RigidBody 2D Physics component to simulate real time physics.
Definition: rigidbody2d.h:27
glm::vec3 GetPositionInPixels()
Gets the position of the rigid body in pixels.
Definition: rigidbody2d.cpp:19
void SetPosition(const glm::vec3 &position)
Sets the position of the rigid body.
Definition: rigidbody2d.cpp:41
const float P2MX
Definition: rigidbody2d.h:16
float GetRotation()
Gets the rotation of the rigid body in radians.
Definition: rigidbody2d.cpp:25
Class for creating components.
Definition: component.h:22
void SetVelocity(glm::vec2 velocity)
Sets the velocity of the rigid body.
Definition: rigidbody2d.cpp:35
float gravityScale
The effect of gravity on the rigid body.
Definition: rigidbody2d.h:39
const float P2MY
Definition: rigidbody2d.h:16
Definition: audioclip.cpp:3
Definition: rigidbody2d.h:22
RigidBodyType bodyType
Denotes whether the RigidBody2D is dynamic, static or kinematic.
Definition: rigidbody2d.h:31
const float M2PX
Box2D scaling factors (set these up dynamically using the projections matrix's Aspect Ratio and Scree...
Definition: rigidbody2d.h:15
glm::vec3 GetPositionInMeters()
Gets the position of the rigid body in meters (M.K.S system)
Definition: rigidbody2d.cpp:13
RigidBodyType
The type of the rigid body.
Definition: rigidbody2d.h:19
const float M2PY
Definition: rigidbody2d.h:15
float friction
The friction of the rigid body surface.
Definition: rigidbody2d.h:35
void AddForce(glm::vec2 direction, float force)
Applies force to the rigid body.
Definition: rigidbody2d.cpp:30
Definition: rigidbody2d.h:21
void GenerateRigidBody(glm::vec3 pos, glm::vec2 dim)
Generates a plane rigid body using the position and dimensions.
Definition: rigidbody2d.cpp:53
RigidBody2D(float density, float friction, RigidBodyType bodytype, b2World &world=World)
Creates the rigid body.
Definition: rigidbody2d.cpp:3
b2Body * GetBody()
Gets the box2D body of the rigid body.
Definition: rigidbody2d.h:90
void SetSize(glm::vec2 &size)
Sets the size of the rigid body.
Definition: rigidbody2d.cpp:47