Jopnal Engine  alpha 0.4
Simple Component Based 2D/3D Game Engine
Public Member Functions | List of all members
jop::PulleyJoint2D Class Reference

#include <PulleyJoint2D.hpp>

Inheritance diagram for jop::PulleyJoint2D:
jop::Joint2D

Public Member Functions

 PulleyJoint2D (World2D &worldRef, RigidBody2D &bodyA, RigidBody2D &bodyB, const bool collide, const float ratio, const glm::vec2 &groundAnchorA, const glm::vec2 &groundAnchorB, const glm::vec2 &localAnchorA=glm::vec2(0.f, 0.f), const glm::vec2 &localAnchorB=glm::vec2(0.f, 0.f))
 PulleyJoint2D constructor. More...
 
std::pair< float, float > getRopeLengths () const
 
- Public Member Functions inherited from jop::Joint2D
 Joint2D (World2D &worldRef, RigidBody2D &bodyA, RigidBody2D &bodyB, const bool collide)
 Joint2D constructor. More...
 
virtual ~Joint2D ()=0
 
unsigned int getID () const
 Get joint ID. More...
 
Joint2DsetID (const unsigned int id)
 Set new ID for the joint. More...
 

Additional Inherited Members

- Public Attributes inherited from jop::Joint2D
World2Dm_worldRef
 Pointer to the world. More...
 
RigidBody2Dm_bodyA
 Pointer to bodyA. More...
 
RigidBody2Dm_bodyB
 Pointer to bodyB. More...
 
- Static Protected Member Functions inherited from jop::Joint2D
static b2Body * getBody (RigidBody2D &body)
 Return engine internal pointer to body. More...
 
- Protected Attributes inherited from jop::Joint2D
bool m_collide
 Should the linked bodies collide. More...
 
b2Joint * m_joint
 Pointer to Box2D joint. More...
 
unsigned int m_ID
 Joint ID. More...
 

Detailed Description

Definition at line 38 of file PulleyJoint2D.hpp.

Constructor & Destructor Documentation

jop::PulleyJoint2D::PulleyJoint2D ( World2D worldRef,
RigidBody2D bodyA,
RigidBody2D bodyB,
const bool  collide,
const float  ratio,
const glm::vec2 &  groundAnchorA,
const glm::vec2 &  groundAnchorB,
const glm::vec2 &  localAnchorA = glm::vec2(0.f, 0.f),
const glm::vec2 &  localAnchorB = glm::vec2(0.f, 0.f) 
)

PulleyJoint2D constructor.

Note
These pulleys have the other end as a static attachment to the world. If the user wishes to create a pulley that also moves sideways, the user can create one in the following way: Create four RigidBody2Ds. Attach two of them with WeldJoint2D. Attach a free body to either welded body via PulleyJoint2D. Attach final body to the other welded body via PulleyJoint2D. Create logic between the PulleyJoint2Ds and apply forces to a welded body.
Parameters
ratioRatio for which the ropes move in relation to each other.
groundAnchorAWorld coordinates for attachment point of the second end of the rope for body A.
groundAnchorBWorld coordinates for attachment point of the second end of the rope for body B.
localAnchorALocal coordinates of body A to attach the rope to. Uses local center of the object if left empty. Please use values between -1.f and 1.f.
localAnchorBLocal coordinates of body B to attach the rope to. Uses local center of the object if left empty. Please use values between -1.f and 1.f.
Returns
PulleyJoint2D

Member Function Documentation

std::pair<float, float> jop::PulleyJoint2D::getRopeLengths ( ) const
Returns
Returns current rope lengths: first = bodyA, second = bodyB

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