Quark Physics  1.0
2D Rigid and Soft Body Physics Engine
QJoint Class Reference

QJoint objects serves to apply various distance constraints between rigid bodies. Additionally, you can create a distance constraint between any object and an imaginary point in space. Instead of separate methods for all fundamental constraints in physics engines, there is a set of property sets available. For example, setting a distance constraint to a distance of 0 creates a constraint known as a pin joint. By decreasing the rigidity of a set distance constraint, you obtain another type of joint called a spring joint. Enabling the groove mode prevents the constraint from being applied as long as the set distance is not exceeded, resulting in another type of joint called a groove joint. QWorld also provides methods to manage QJoint objects. More...

#include <qjoint.h>

Public Member Functions

 QJoint (QRigidBody *bodyA, QVector anchorWorldPositionA, QVector anchorWorldPositionB, QRigidBody *bodyB=nullptr)
 
 QJoint (QRigidBody *bodyA, QVector commonAnchorWorldPosition, QRigidBody *bodyB=nullptr)
 
QRigidBodyGetBodyA ()
 
QRigidBodyGetBodyB ()
 
QVector GetAnchorAPosition ()
 
QVector GetAnchorBPosition ()
 
QVector GetAnchorAGlobalPosition ()
 
QVector GetAnchorBGlobalPosition ()
 
bool GetCollisionEnabled ()
 
float GetRigidity ()
 
float GetLength ()
 
float GetBalance ()
 
bool GetGrooveEnabled ()
 
bool GetEnabled ()
 
QJointSetBodyA (QRigidBody *body)
 
QJointSetBodyB (QRigidBody *body)
 
QJointSetAnchorAPosition (QVector worldPosition)
 
QJointSetAnchorBPosition (QVector worldPosition)
 
QJointSetRigidity (float value)
 
QJointSetLength (float value)
 
QJointSetBalance (float value)
 
QJointSetGrooveEnabled (bool value)
 
QJointSetCollisionEnabled (bool value)
 
QJointSetEnabled (bool value)
 
virtual void Update ()
 

Friends

class QWorld
 

Detailed Description

QJoint objects serves to apply various distance constraints between rigid bodies. Additionally, you can create a distance constraint between any object and an imaginary point in space. Instead of separate methods for all fundamental constraints in physics engines, there is a set of property sets available. For example, setting a distance constraint to a distance of 0 creates a constraint known as a pin joint. By decreasing the rigidity of a set distance constraint, you obtain another type of joint called a spring joint. Enabling the groove mode prevents the constraint from being applied as long as the set distance is not exceeded, resulting in another type of joint called a groove joint. QWorld also provides methods to manage QJoint objects.

Constructor & Destructor Documentation

◆ QJoint() [1/2]

QJoint::QJoint ( QRigidBody bodyA,
QVector  anchorWorldPositionA,
QVector  anchorWorldPositionB,
QRigidBody bodyB = nullptr 
)

Creates a joint between two rigid bodies. Anchor points will be locked to the corresponding position on the QRigidBody if the relevant QRigidBody is defined. If not defined, the anchor point will be assumed as a fixed point in space.

Parameters
bodyAA body in the world. If set to nullptr, anchorWorldPositionA will be a fixed point in space.
anchorWorldPositionAThe anchorA position in world coordinates.
anchorWorldPositionBThe anchorB position in world coordinates.
bodyBAnother body in the world. If set to nullptr, anchorWorldPositionB will be a fixed point in space.
Remarks
Two anchor points are defined, and the default distance value is the distance between the two points.

◆ QJoint() [2/2]

QJoint::QJoint ( QRigidBody bodyA,
QVector  commonAnchorWorldPosition,
QRigidBody bodyB = nullptr 
)
inline

Creates a joint between two rigid bodies with defined a single position to anchors. When you create a QJoint with an anchor parameter fixed to a single position, you obtain a QJoint with a constraint distance of 0, commonly known as a pin joint. If one of the QRigidBody parameters is not defined, the constraint will be applied not between two rigid body objects but between one rigid body object and an imaginary fixed point in space.

Parameters
bodyAA body in the world. If set to nullptr, anchorWorldPositionA will be a fixed point in space.
commonAnchorWorldPositionThe common anchor position to set anchors of the joint in world coordinates.
bodyBAnother body in the world. If set to nullptr, anchorWorldPositionB will be a fixed point in space.
Remarks
Two anchor points are defined, and the default distance value is the distance between the two points.

Member Function Documentation

◆ GetAnchorAGlobalPosition()

QVector QJoint::GetAnchorAGlobalPosition ( )
inline

Returns the position of anchorA of the joint in world coordinates.

◆ GetAnchorAPosition()

QVector QJoint::GetAnchorAPosition ( )
inline

Returns the position of anchorA of the joint.If bodyA is defined, it returns the relative position of the anchor according to bodyA, otherwise, it returns the position of the anchor in world coordinates.

◆ GetAnchorBGlobalPosition()

QVector QJoint::GetAnchorBGlobalPosition ( )
inline

Returns the position of anchorB of the joint in world coordinates.

◆ GetAnchorBPosition()

QVector QJoint::GetAnchorBPosition ( )
inline

Returns the position of anchorB of the joint.If bodyB is defined, it returns the relative position of the anchor according to bodyA, otherwise, it returns the position of the anchor in world coordinates.

◆ GetBalance()

float QJoint::GetBalance ( )
inline

Returns the balance value of the joint. 0.0 is the a-side, 1.0 is the b-side

◆ GetBodyA()

QRigidBody* QJoint::GetBodyA ( )
inline

Returns bodyA of the joint.

◆ GetBodyB()

QRigidBody* QJoint::GetBodyB ( )
inline

Returns bodyB of the joint.

◆ GetCollisionEnabled()

bool QJoint::GetCollisionEnabled ( )
inline

Returns whether collisions are enabled between bodies of the joint.

◆ GetEnabled()

bool QJoint::GetEnabled ( )
inline

Returns whether the joint is enabled.

◆ GetGrooveEnabled()

bool QJoint::GetGrooveEnabled ( )
inline

Returns whether the groove mode of the joint enabled or not.

◆ GetLength()

float QJoint::GetLength ( )
inline

Returns the length value of the joint.

◆ GetRigidity()

float QJoint::GetRigidity ( )
inline

Returns the rigidity of the joint.

◆ SetAnchorAPosition()

QJoint* QJoint::SetAnchorAPosition ( QVector  worldPosition)
inline

Sets anchorA position of the joint.

Parameters
worldPositionA position to set in world coordinates.
Returns
A pointer to the joint itself.

◆ SetAnchorBPosition()

QJoint* QJoint::SetAnchorBPosition ( QVector  worldPosition)
inline

Sets anchorB position of the joint.

Parameters
worldPositionA position to set in world coordinates.
Returns
A pointer to the joint itself.

◆ SetBalance()

QJoint* QJoint::SetBalance ( float  value)
inline

Sets the force balance value of the joint, it's 0.5 as a default. 0.0 is the a-side, 1.0 is the b-side.

Parameters
valueThe balance value to set. It must be a value between 0.0 and 1.0.
Returns
A pointer to the joint itself.

◆ SetBodyA()

QJoint* QJoint::SetBodyA ( QRigidBody body)
inline

Sets bodyA of the joint.

Parameters
bodyA pointer of the body to set.
Returns
A pointer to the joint itself.

◆ SetBodyB()

QJoint* QJoint::SetBodyB ( QRigidBody body)
inline

Sets bodyB of the joint.

Parameters
bodyA pointer of the body to set.
Returns
A pointer to the joint itself.

◆ SetCollisionEnabled()

QJoint * QJoint::SetCollisionEnabled ( bool  value)

Sets whether collisions are enabled between bodies of the joint.

Parameters
valueTrue or false.
Returns
A pointer to the joint itself.

◆ SetEnabled()

QJoint* QJoint::SetEnabled ( bool  value)
inline

Sets whether the joint is enabled.

Parameters
valueTrue or false.
Returns
A pointer to the joint itself.

◆ SetGrooveEnabled()

QJoint* QJoint::SetGrooveEnabled ( bool  value)
inline

Sets whether the groove mode of the joint enabled or not. When groove mode is enabled in QJoints, distance constraint will only be applied when the set distance is exceeded.

Parameters
valueTrue or false.
Returns
A pointer to the joint itself.

◆ SetLength()

QJoint* QJoint::SetLength ( float  value)
inline

Sets the length value of the joint.

Parameters
valueThe length value to set.
Returns
A pointer to the joint itself.

◆ SetRigidity()

QJoint* QJoint::SetRigidity ( float  value)
inline

Sets the rigidity of the joint.

Parameters
valueThe rigidity value to set. It must be a value between 0.0 and 1.0.
Returns
A pointer to the joint itself.

◆ Update()

void QJoint::Update ( )
virtual

Updates the constraints of the joint.


The documentation for this class was generated from the following files: