CUGL 3.0
Cornell University Game Library
|
#include <CUPulleyJoint.h>
Public Member Functions | |
PulleyJoint () | |
bool | initWithObstacles (const std::shared_ptr< Obstacle > &obsA, const std::shared_ptr< Obstacle > &obsB) override |
bool | initWithObstacles (const std::shared_ptr< Obstacle > &obsA, const std::shared_ptr< Obstacle > &obsB, const Vec2 groundA, const Vec2 groundB) |
const Vec2 & | getLocalAnchorA () const |
void | setLocalAnchorA (const Vec2 point) |
void | setLocalAnchorA (float x, float y) |
const Vec2 & | getLocalAnchorB () const |
void | setLocalAnchorB (const Vec2 point) |
void | setLocalAnchorB (float x, float y) |
const Vec2 & | getGroundAnchorA () const |
void | setGroundAnchorA (const Vec2 point) |
void | setGroundAnchorA (float x, float y) |
const Vec2 & | getGroundAnchorB () const |
void | setGroundAnchorB (const Vec2 point) |
void | setGroundAnchorB (float x, float y) |
float | getLengthA () const |
void | setLengthA (float value) |
float | getLengthB () const |
void | setLengthB (float value) |
float | getRatio () const |
void | setRatio (float value) |
virtual bool | activatePhysics (b2World &world) override |
Public Member Functions inherited from cugl::physics2::Joint | |
Joint () | |
virtual | ~Joint () |
bool | init () |
virtual bool | initWithObstacles (const std::shared_ptr< Obstacle > &obsA, const std::shared_ptr< Obstacle > &obsB) |
b2JointType | getType () const |
void | setObstacleA (const std::shared_ptr< Obstacle > &obs) |
std::shared_ptr< Obstacle > & | getObstacleA () |
void | setObstacleB (const std::shared_ptr< Obstacle > &obs) |
std::shared_ptr< Obstacle > & | getObstacleB () |
bool | getCollideConnected () |
void | setCollideConnected (bool flag) |
void | release () |
bool | isRemoved () const |
void | markRemoved (bool value) |
bool | isDirty () const |
void | markDirty (bool value) |
b2Joint * | getJoint () |
virtual bool | activatePhysics (b2World &world) |
void | deactivatePhysics (b2World &world) |
Static Public Member Functions | |
static std::shared_ptr< PulleyJoint > | alloc () |
static std::shared_ptr< PulleyJoint > | allocWithObstacles (const std::shared_ptr< Obstacle > &obsA, const std::shared_ptr< Obstacle > &obsB) |
static std::shared_ptr< PulleyJoint > | allocWithObstacles (const std::shared_ptr< Obstacle > &obsA, const std::shared_ptr< Obstacle > &obsB, const Vec2 groundA, const Vec2 groundB) |
Additional Inherited Members | |
Protected Attributes inherited from cugl::physics2::Joint | |
b2Joint * | _joint |
b2JointType | _type |
std::shared_ptr< Obstacle > | _bodyA |
std::shared_ptr< Obstacle > | _bodyB |
bool | _collideConnected |
bool | _remove |
Track garbage collection status. | |
bool | _dirty |
The pulley joint class.
This class requires two ground anchors, two dynamic body anchor points, and a pulley ratio.
cugl::physics2::PulleyJoint::PulleyJoint | ( | ) |
Creates a new pulley joint with no obstacles
NEVER USE A CONSTRUCTOR WITH NEW. If you want to allocate an object on the heap, use one of the static constructors instead (in this case, in one of the subclasses).
|
overridevirtual |
Creates the Box2d joint, adding it to the world.
Calling this method activates the physics of the associated obstacles, if necessary.
Implementations of this method should NOT retain ownership of the Box2D world. That is a tight coupling that we should avoid.
world | Box2D world to store the joint |
Reimplemented from cugl::physics2::Joint.
|
inlinestatic |
Returns a newly allocated pulley joint with default values.
The joint will not have any associated obstacles and so attempting to activate it will fail.
|
inlinestatic |
Returns a newly allocated pulley joint with the given obstacles.
All other attributes will be at their default values.
obsA | The first obstacle to join |
obsB | The second obstacle to join |
|
inlinestatic |
Returns a newly allocated pulley joint with the given obstacles and anchors
The ground anchors are specified in world coordinate, not local coordinates. All other attributes will be at their default values.
obsA | The first obstacle to join |
obsB | The second obstacle to join |
groundA | The ground anchor of the first obstacle |
groundB | The ground anchor of the second obstacle |
|
inline |
Returns the ground anchor point for obstacle A's in world coordinate.
|
inline |
Returns the ground anchor point for obstacle A's in world coordinate.
|
inline |
Returns the reference length for the segment attached to bodyA.
|
inline |
Returns the reference length for the segment attached to bodyB.
|
inline |
Returns the local anchor point relative to obstacle A's origin.
|
inline |
Returns the local anchor point relative to obstacle B's origin.
|
inline |
Returns the pulley ratio.
This value is used to simulate a block-and-tackle.
|
overridevirtual |
Initializes a new pulley joint with the given obstacles.
All other attributes will be at their default values.
obsA | The first obstacle to join |
obsB | The second obstacle to join |
Reimplemented from cugl::physics2::Joint.
bool cugl::physics2::PulleyJoint::initWithObstacles | ( | const std::shared_ptr< Obstacle > & | obsA, |
const std::shared_ptr< Obstacle > & | obsB, | ||
const Vec2 | groundA, | ||
const Vec2 | groundB | ||
) |
Initializes a new pulley joint with the given obstacles and anchors
The ground anchors are specified in world coordinate, not local coordinates. All other attributes will be at their default values.
obsA | The first obstacle to join |
obsB | The second obstacle to join |
groundA | The ground anchor of the first obstacle |
groundB | The ground anchor of the second obstacle |
|
inline |
Sets the ground anchor point for obstacle A's in world coordinate.
If this method is called while the joint is active, then the joint will be marked as dirty. It will need to be deactivated and reactivated to work properly.
point | the ground anchor point |
|
inline |
Sets the ground anchor point for obstacle A's in world coordinate.
If this method is called while the joint is active, then the joint will be marked as dirty. It will need to be deactivated and reactivated to work properly.
x | the x-coordinate of the ground anchor point |
y | the y-coordinate of the ground anchor point |
|
inline |
Sets the ground anchor point for obstacle A's in world coordinate.
If this method is called while the joint is active, then the joint will be marked as dirty. It will need to be deactivated and reactivated to work properly.
point | the ground anchor point |
|
inline |
Sets the ground anchor point for obstacle A's in world coordinate.
If this method is called while the joint is active, then the joint will be marked as dirty. It will need to be deactivated and reactivated to work properly.
x | the x-coordinate of the ground anchor point |
y | the y-coordinate of the ground anchor point |
|
inline |
Sets the reference length for the segment attached to bodyA.
If this method is called while the joint is active, then the joint will be marked as dirty. It will need to be deactivated and reactivated to work properly.
value | the reference length for the segment attached to bodyA. |
|
inline |
Sets the reference length for the segment attached to bodyB.
If this method is called while the joint is active, then the joint will be marked as dirty. It will need to be deactivated and reactivated to work properly.
value | the reference length for the segment attached to bodyB. |
|
inline |
Sets the local anchor point relative to obstacle A's origin.
If this method is called while the joint is active, then the joint will be marked as dirty. It will need to be deactivated and reactivated to work properly.
point | the local anchor point |
|
inline |
Sets the local anchor point relative to obstacle A's origin.
If this method is called while the joint is active, then the joint will be marked as dirty. It will need to be deactivated and reactivated to work properly.
x | the x-coordinate of the local anchor point |
y | the y-coordinate of the local anchor point |
|
inline |
Sets the local anchor point relative to obstacle B's origin.
If this method is called while the joint is active, then the joint will be marked as dirty. It will need to be deactivated and reactivated to work properly.
point | the local anchor point |
|
inline |
Sets the local anchor point relative to obstacle B's origin.
If this method is called while the joint is active, then the joint will be marked as dirty. It will need to be deactivated and reactivated to work properly.
x | the x-coordinate of the local anchor point |
y | the y-coordinate of the local anchor point |
|
inline |
Returns the pulley ratio.
This value is used to simulate a block-and-tackle.
value | the pulley ratio. |