CUGL 2.5
Cornell University Game Library
|
#include <CUWeldJoint.h>
Public Member Functions | |
WeldJoint () | |
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 localA, const Vec2 localB) |
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) |
float | getReferenceAngle () const |
void | setReferenceAngle (float value) |
float | getStiffness () const |
void | setStiffness (float value) |
float | getDamping () const |
void | setDamping (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< WeldJoint > | alloc () |
static std::shared_ptr< WeldJoint > | allocWithObstacles (const std::shared_ptr< Obstacle > &obsA, const std::shared_ptr< Obstacle > &obsB) |
static std::shared_ptr< WeldJoint > | allocWithObstacles (const std::shared_ptr< Obstacle > &obsA, const std::shared_ptr< Obstacle > &obsB, const Vec2 localA, const Vec2 localB) |
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 weld joint class.
This joint requires you to specify local anchor points where they are attached and the relative body angle. The position of the anchor points is important for computing the reaction torque.
cugl::physics2::WeldJoint::WeldJoint | ( | ) |
Creates a new weld 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 weld 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 weld 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 weld joint with the given obstacles and anchors
All other attributes will be at their default values.
obsA | The first obstacle to join |
obsB | The second obstacle to join |
localA | The local anchor of the first obstacle |
localB | The local anchor of the second obstacle |
|
inline |
Returns the linear damping in N*s/m.
|
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 constrained angle between the bodies.
This value is measured bodyB - bodyA in radians.
|
inline |
Returns the linear stiffness in N/m.
|
overridevirtual |
Initializes a new weld 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::WeldJoint::initWithObstacles | ( | const std::shared_ptr< Obstacle > & | obsA, |
const std::shared_ptr< Obstacle > & | obsB, | ||
const Vec2 | localA, | ||
const Vec2 | localB | ||
) |
Initializes a new weld joint with the given obstacles and anchors
All other attributes will be at their default values.
obsA | The first obstacle to join |
obsB | The second obstacle to join |
localA | The local anchor of the first obstacle |
localB | The local anchor of the second obstacle |
|
inline |
Sets the linear damping in N*s/m.
value | the linear damping |
|
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 |
Sets the constrained angle between the bodies.
This value is measured bodyB - bodyA in radians.
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 constrained angle between the bodies. |
|
inline |
Sets the linear stiffness in N/m.
value | the linear stiffness |