CUGL 2.5
Cornell University Game Library
|
#include <CUMouseJoint.h>
Public Member Functions | |
MouseJoint () | |
const Vec2 | getTarget () const |
void | setTarget (const Vec2 pos) |
void | setTarget (float x, float y) |
float | getMaxForce () const |
void | setMaxForce (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< MouseJoint > | alloc () |
static std::shared_ptr< MouseJoint > | allocWithObstacles (const std::shared_ptr< Obstacle > &obsA, const std::shared_ptr< Obstacle > &obsB) |
Protected Attributes | |
Vec2 | _target |
float | _maxForce |
float | _stiffness |
float | _damping |
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 mouse joint class.
This requires a world target point, tuning parameters, and the time step. The first obstacle in the mouse joint is generally ignored, except as a frame of reference.
cugl::physics2::MouseJoint::MouseJoint | ( | ) |
Creates a new mouse 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 mouse 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 mouse 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 |
|
inline |
Returns the linear damping in N*s/m.
|
inline |
Returns the maximum constraint force that can be exerted to move the body.
The body moved is the second obstacle. This force is usually expressed as some multiple of the weight (multiplier * mass * gravity).
|
inline |
Returns the linear stiffness in N/m.
|
inline |
Returns the initial world target point.
This is assumed to coincide with the body anchor initially.
|
inline |
Sets the linear damping in N*s/m.
value | the linear damping |
|
inline |
Sets the maximum constraint force that can be exerted to move the body.
The body moved is the second obstacle. This force is usually expressed as some multiple of the weight (multiplier * mass * gravity).
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 force that can be exerted |
|
inline |
Sets the linear stiffness in N/m.
value | the linear stiffness |
|
inline |
Sets the initial world target point.
This is assumed to coincide with the body anchor initially.
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.
pos | the initial world target point |
|
inline |
Sets the initial world target point.
This is assumed to coincide with the body anchor initially.
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 initial world target point |
y | the y-coordinate of the initial world target point |
|
protected |
The linear damping in N*s/m
|
protected |
The maximum constraint force that can be exerted
|
protected |
The linear stiffness in N/m
|
protected |
The initial world target point.