Constrains two points on two rigid bodies to remain at a fixed distance from each other. More...
#include <DistanceJoint.h>
Public Types | |
using | Ptr = std::unique_ptr< Joint > |
Unique joint pointer. More... | |
Public Member Functions | |
std::string | getClassName () const override |
Get the name of this class. More... | |
float | setRestLength (float length) |
Set the rest length. More... | |
float | getRestLength () const |
Get the rest length. More... | |
float | setMinimumLength (float minLength) |
Set the minimum length. More... | |
float | getMinimumLength () const |
Get the minimum length. More... | |
float | setMaxLength (float maxLength) |
Set the maximum length. More... | |
float | getMaximumLength () const |
Get the maximum length. More... | |
float | getCurrentLength () const |
Get the current length. More... | |
Vector2f | getBodyALocalAnchorPoint () const |
Get the anchor point on body A in local coordinates. More... | |
Vector2f | getBodyAWorldAnchorPoint () const override |
Get the anchor point on body A in world coordinates. More... | |
Vector2f | getBodyBLocalAnchorPoint () const |
Get the anchor point on body B in local coordinates. More... | |
Vector2f | getBodyBWorldAnchorPoint () const override |
Get the anchor point on body B in world coordinates. More... | |
JointType | getType () const override |
Get the type of the joint. More... | |
RigidBody * | getBodyA () override |
Get the first body attached to ths joint. More... | |
const RigidBody * | getBodyA () const override |
RigidBody * | getBodyB () override |
Get the second body attached to ths joint. More... | |
const RigidBody * | getBodyB () const override |
Vector2f | getReactionForce (float fpsLimit) const override |
Get the reaction force on body B at the joint anchor. More... | |
float | getReactionTorque (float fpsLimit) const override |
Get the reaction torque on body B. More... | |
PropertyContainer & | getUserData () override |
Get the application specific Joint data. More... | |
const PropertyContainer & | getUserData () const override |
bool | canBodiesCollide () const override |
Check if the joint bodies can collide with each other or not. More... | |
b2Joint * | getInternalJoint () override |
const b2Joint * | getInternalJoint () const override |
~DistanceJoint () override | |
Destructor. More... | |
std::string | getClassType () const override |
Get the name of this class. More... | |
void | setTag (const std::string &tag) |
Assign the object an alias. More... | |
const std::string & | getTag () const |
Get the tag assigned to the object. More... | |
unsigned int | getObjectId () const |
Get the unique id of the object. More... | |
int | onPropertyChange (const std::string &property, const Callback< Property > &callback, bool oneTime=false) |
Add an event listener to a specific property change event. More... | |
int | onPropertyChange (const Callback< Property > &callback, bool oneTime=false) |
Add an event listener to any property change event. More... | |
void | suspendedEventListener (int id, bool suspend) |
Pause or resume execution of an event listener. More... | |
bool | isEventListenerSuspended (int id) const |
Check if an event listener is suspended or not. More... | |
bool | removeEventListener (const std::string &event, int id) |
Remove an event listener from an event. More... | |
bool | removeEventListener (int id) |
Remove an event listener. More... | |
int | onDestruction (const Callback<> &callback) |
Add a destruction listener. More... | |
bool | isSameObjectAs (const Object &other) const |
Check if another object is the same instance as this object. More... | |
Protected Member Functions | |
void | emitChange (const Property &property) |
Dispatch a property change event. More... | |
void | emitDestruction () |
Emit a destruction event. More... | |
Protected Attributes | |
EventEmitter | eventEmitter_ |
Event dispatcher. More... | |
Friends | |
class | PhysicsEngine |
Needs access to constructor. More... | |
Constrains two points on two rigid bodies to remain at a fixed distance from each other.
When you specify a distance joint the two bodies should already be in place. Then you specify the two anchor points in world coordinates. The first anchor point is connected to body 1, and the second anchor point is connected to body 2. These points imply the length of the distance constraint
Definition at line 79 of file DistanceJoint.h.
using ime::DistanceJoint::Ptr = std::unique_ptr<Joint> |
Unique joint pointer.
Definition at line 81 of file DistanceJoint.h.
|
override |
Destructor.
|
overridevirtual |
Check if the joint bodies can collide with each other or not.
Implements ime::Joint.
|
protectedinherited |
Dispatch a property change event.
property | The property that changed |
This function will invoke all the event listeners of the specified property
|
protectedinherited |
Emit a destruction event.
|
overridevirtual |
Implements ime::Joint.
|
overridevirtual |
Get the first body attached to ths joint.
Implements ime::Joint.
Vector2f ime::DistanceJoint::getBodyALocalAnchorPoint | ( | ) | const |
Get the anchor point on body A in local coordinates.
|
overridevirtual |
Get the anchor point on body A in world coordinates.
Implements ime::Joint.
|
overridevirtual |
Implements ime::Joint.
|
overridevirtual |
Get the second body attached to ths joint.
Implements ime::Joint.
Vector2f ime::DistanceJoint::getBodyBLocalAnchorPoint | ( | ) | const |
Get the anchor point on body B in local coordinates.
|
overridevirtual |
Get the anchor point on body B in world coordinates.
Implements ime::Joint.
|
overridevirtual |
|
overridevirtualinherited |
Get the name of this class.
Note that this function is only implemented by child classes of Object which also serve as a base class for other classes
Reimplemented from ime::Object.
float ime::DistanceJoint::getCurrentLength | ( | ) | const |
Get the current length.
|
overridevirtual |
Implements ime::Joint.
|
overridevirtual |
Implements ime::Joint.
float ime::DistanceJoint::getMaximumLength | ( | ) | const |
Get the maximum length.
By default the maximum length is
float ime::DistanceJoint::getMinimumLength | ( | ) | const |
Get the minimum length.
By default, the maximum length is the maximum float value on your computer (Very large number)
|
inherited |
Get the unique id of the object.
Note that each instance of ime::Object has a unique id
|
overridevirtual |
Get the reaction force on body B at the joint anchor.
fpsLimit | The games Frames Per Second limit |
Implements ime::Joint.
|
overridevirtual |
Get the reaction torque on body B.
fpsLimit | The games Frames Per Second limit |
Implements ime::Joint.
float ime::DistanceJoint::getRestLength | ( | ) | const |
Get the rest length.
|
inherited |
|
overridevirtual |
|
overridevirtual |
Implements ime::Joint.
|
overridevirtual |
Get the application specific Joint data.
This data is extracted from the JointDefinition
Implements ime::Joint.
|
inherited |
Check if an event listener is suspended or not.
id | The identification number of the listener to be checked |
This function also returns false if the specified event listener does not exist
|
inherited |
Check if another object is the same instance as this object.
other | The object to compare against this object |
|
inherited |
Add a destruction listener.
callback | Function to be executed when the object is destroyed |
The destruction listener is called when the object reaches the end of its lifetime. Note that an object may have multiple destruction listeners registered to it
|
inherited |
Add an event listener to any property change event.
callback | The function to be executed when any property changes |
oneTime | True to execute the callback one-time or false to execute it every time the event is triggered |
When unsubscribing the any property change event handler, you must pass "propertyChange" as the name of the event
|
inherited |
Add an event listener to a specific property change event.
property | The name of the property to add an event listener to |
oneTime | True to execute the callback one-time or false to execute it every time the event is triggered |
callback | The function to be executed when the property changes |
A property change event is triggered by any function that begins with set, where the the text after set is the name of the property. For example, the setTag() function, modifies the tag property of the object, thus will generate a "tag" change event each time it is called
Note that multiple event listeners may be registered to the same property change event. In addition, when adding a property change event listener, the name of the property must be in lowercase.
|
inherited |
Remove an event listener from an event.
event | The name of the event to remove an event listener from |
id | The unique id of the event listener to be removed |
|
inherited |
Remove an event listener.
id | The id of the event listener to be removed |
float ime::DistanceJoint::setMaxLength | ( | float | maxLength | ) |
Set the maximum length.
maxLength | The new maximum length |
float ime::DistanceJoint::setMinimumLength | ( | float | minLength | ) |
Set the minimum length.
minLength | The new minimum length |
By default the minimum length is 0.0f
float ime::DistanceJoint::setRestLength | ( | float | length | ) |
Set the rest length.
length | The rest length to set |
|
inherited |
Assign the object an alias.
tag | The alias of the object |
This function is useful if you want to refer to the object by a tag instead of its object id. Unlike an object id, multiple objects may have the same tag
By default, the tag is an empty string
|
inherited |
Pause or resume execution of an event listener.
id | The event listeners unique identification number |
suspend | True to suspend/pause or false to unsuspend/resume |
|
friend |
Needs access to constructor.
Definition at line 250 of file DistanceJoint.h.
|
protectedinherited |