CUGL 2.5
Cornell University Game Library
|
#include <CUWheelJoint.h>
Public Member Functions | |
WheelJoint () | |
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) |
const Vec2 & | getLocalAxisA () const |
void | setLocalAxisA (const Vec2 point) |
void | setLocalAxisA (float x, float y) |
float | getReferenceAngle () const |
void | setReferenceAngle (float value) |
bool | hasLimit () const |
void | enableLimit (bool value) |
bool | hasMotor () const |
void | enableMotor (bool value) |
float | getLowerTranslation () const |
void | setLowerTranslation (float value) |
float | getUpperTranslation () const |
void | setUpperTranslation (float value) |
float | getMaxMotorTorque () const |
void | getMaxMotorTorque (float value) |
float | getMotorSpeed () const |
void | setMotorSpeed (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< WheelJoint > | alloc () |
static std::shared_ptr< WheelJoint > | allocWithObstacles (const std::shared_ptr< Obstacle > &obsA, const std::shared_ptr< Obstacle > &obsB) |
static std::shared_ptr< WheelJoint > | 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 wheel joint class.
This joint requires defining a line of motion using an axis and an anchor point. The definition uses local anchor points and a local axis so that the initial configuration can violate the constraint slightly. The joint translation is zero when the local anchor points coincide in world space. Using local anchors and a local axis helps when saving and loading a game.
cugl::physics2::WheelJoint::WheelJoint | ( | ) |
Creates a new wheel 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 wheel 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 wheel 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 wheel 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 |
Enables/disables the joint limit.
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 | Whether to enable the joint limit |
|
inline |
Enables/disables the joint motor.
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 | Whether to enable the joint motor |
|
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 local translation unit axis.
This axis is measured with respect to bodyA.
|
inline |
Returns the lower translation limit.
This is usually measured in meters.
|
inline |
Returns the maximum motor torque, usually in N-m.
|
inline |
Sets the maximum motor torque, usually in N-m.
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 maximum motor torque |
|
inline |
Returns the desired motor speed in radians per second.
|
inline |
Returns the constrained angle between the bodies.
This value is measured bodyB - bodyA in radians.
|
inline |
Returns the linear stiffness in N/m.
|
inline |
Returns the upper translation limit.
This is usually measured in meters.
|
inline |
Returns true if the joint limit is enabled.
|
inline |
Returns true if the joint motor is enabled.
|
overridevirtual |
Initializes a new wheel 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::WheelJoint::initWithObstacles | ( | const std::shared_ptr< Obstacle > & | obsA, |
const std::shared_ptr< Obstacle > & | obsB, | ||
const Vec2 | localA, | ||
const Vec2 | localB | ||
) |
Initializes a new wheel 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 local translation unit axis.
This axis is measured with respect 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.
point | the local translation unit axis. |
|
inline |
Sets the local translation unit axis.
This axis is measured with respect 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.
x | the x-coordinate of the local translation unit axis |
y | the y-coordinate of the local translation unit axis |
|
inline |
Sets the lower translation limit.
This is usually measured in meters.
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 lower translation limit. |
|
inline |
Sets the desired motor speed in radians per second.
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 desired motor speed |
|
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 |
|
inline |
Sets the upper translation limit.
This is usually measured in meters.
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 upper translation limit. |