#include <CUMotorJoint.h>
◆ MotorJoint()
cugl::physics2::MotorJoint::MotorJoint |
( |
| ) |
|
Creates a new motor 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).
◆ activatePhysics()
virtual bool cugl::physics2::MotorJoint::activatePhysics |
( |
b2World & |
world | ) |
|
|
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.
- Parameters
-
world | Box2D world to store the joint |
- Returns
- true if object allocation succeeded
Reimplemented from cugl::physics2::Joint.
◆ alloc()
static std::shared_ptr< MotorJoint > cugl::physics2::MotorJoint::alloc |
( |
| ) |
|
|
inlinestatic |
Returns a newly allocated motor joint with default values.
The joint will not have any associated obstacles and so attempting to activate it will fail.
- Returns
- a newly allocated motor joint with default values.
◆ allocWithObstacles()
static std::shared_ptr< MotorJoint > cugl::physics2::MotorJoint::allocWithObstacles |
( |
const std::shared_ptr< Obstacle > & |
obsA, |
|
|
const std::shared_ptr< Obstacle > & |
obsB |
|
) |
| |
|
inlinestatic |
Returns a newly allocated motor joint with the given obstacles.
All other attributes will be at their default values.
- Parameters
-
obsA | The first obstacle to join |
obsB | The second obstacle to join |
- Returns
- a newly allocated motor joint with the given obstacles.
◆ getAngularOffset()
float cugl::physics2::MotorJoint::getAngularOffset |
( |
| ) |
const |
|
inline |
Returns the bodyB angle minus bodyA angle in radians.
- Returns
- the bodyB angle minus bodyA angle in radians.
◆ getCorrectionFactor()
float cugl::physics2::MotorJoint::getCorrectionFactor |
( |
| ) |
const |
|
inline |
Returns the position correction factor in the range [0,1].
- Returns
- the position correction factor in the range [0,1].
◆ getLinearOffset()
const Vec2 cugl::physics2::MotorJoint::getLinearOffset |
( |
| ) |
const |
|
inline |
Returns the position of bodyB minus the position of bodyA.
The value is measured in meters, with respect to bodyA's frame.
- Returns
- the position of bodyB minus the position of bodyA.
◆ getMaxForce()
float cugl::physics2::MotorJoint::getMaxForce |
( |
| ) |
const |
|
inline |
Returns the maximum motor force in N.
- Returns
- the maximum motor force in N.
◆ getMaxTorque()
float cugl::physics2::MotorJoint::getMaxTorque |
( |
| ) |
const |
|
inline |
The maximum motor torque in N-m.
Returns the maximum motor torque in N-m.
- Returns
- the maximum motor torque in N-m.
◆ setAngularOffset()
void cugl::physics2::MotorJoint::setAngularOffset |
( |
float |
value | ) |
|
|
inline |
Sets the bodyB angle minus bodyA angle 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.
- Parameters
-
value | the bodyB angle minus bodyA angle in radians. |
◆ setCorrectionFactor()
void cugl::physics2::MotorJoint::setCorrectionFactor |
( |
float |
value | ) |
|
|
inline |
Sets the position correction factor in the range [0,1].
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.
- Parameters
-
value | the position correction factor |
◆ setLinearOffset() [1/2]
void cugl::physics2::MotorJoint::setLinearOffset |
( |
const Vec2 |
pos | ) |
|
|
inline |
Sets the position of bodyB minus the position of bodyA.
The value is measured in meters, with respect to bodyA's frame.
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.
- Parameters
-
pos | the position of bodyB minus the position of bodyA. |
◆ setLinearOffset() [2/2]
void cugl::physics2::MotorJoint::setLinearOffset |
( |
float |
x, |
|
|
float |
y |
|
) |
| |
|
inline |
Sets the position of bodyB minus the position of bodyA.
The value is measured in meters, with respect to bodyA's frame.
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.
- Parameters
-
x | the x-coordinate of the position of bodyB minus that of bodyA. |
y | the y-coordinate of the position of bodyB minus that of bodyA. |
◆ setMaxForce()
void cugl::physics2::MotorJoint::setMaxForce |
( |
float |
value | ) |
|
|
inline |
Sets the maximum motor force in N.
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.
- Parameters
-
value | the maximum motor force |
◆ setMaxTorque()
void cugl::physics2::MotorJoint::setMaxTorque |
( |
float |
value | ) |
|
|
inline |
Sets the maximum motor torque 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.
- Parameters
-
value | the maximum motor torque |
◆ _angularOffset
float cugl::physics2::MotorJoint::_angularOffset |
|
protected |
The bodyB angle minus bodyA angle in radians.
◆ _correctionFactor
float cugl::physics2::MotorJoint::_correctionFactor |
|
protected |
Position correction factor in the range [0,1].
◆ _linearOffset
Vec2 cugl::physics2::MotorJoint::_linearOffset |
|
protected |
The position of bodyB minus the position of bodyA, in bodyA's frame, in meters.
◆ _maxForce
float cugl::physics2::MotorJoint::_maxForce |
|
protected |
The maximum motor force in N.
◆ _maxTorque
float cugl::physics2::MotorJoint::_maxTorque |
|
protected |
The maximum motor torque in N-m.
The documentation for this class was generated from the following file: