CUGL 2.5
Cornell University Game Library
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
cugl::physics2::WeldJoint Class Reference

#include <CUWeldJoint.h>

Inheritance diagram for cugl::physics2::WeldJoint:
cugl::physics2::Joint

Public Member Functions

 WeldJoint ()
 
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 Vec2getLocalAnchorA () const
 
void setLocalAnchorA (const Vec2 point)
 
void setLocalAnchorA (float x, float y)
 
const Vec2getLocalAnchorB () const
 
void setLocalAnchorB (const Vec2 point)
 
void setLocalAnchorB (float x, float y)
 
float getReferenceAngle () const
 
void setReferenceAngle (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< WeldJointalloc ()
 
static std::shared_ptr< WeldJointallocWithObstacles (const std::shared_ptr< Obstacle > &obsA, const std::shared_ptr< Obstacle > &obsB)
 
static std::shared_ptr< WeldJointallocWithObstacles (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
 

Detailed Description

The weld joint class.

This joint requires you to specify local anchor points where they are attached and the relative body angle. The position of the anchor points is important for computing the reaction torque.

Constructor & Destructor Documentation

◆ WeldJoint()

cugl::physics2::WeldJoint::WeldJoint ( )

Creates a new weld 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).

Member Function Documentation

◆ activatePhysics()

virtual bool cugl::physics2::WeldJoint::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
worldBox2D world to store the joint
Returns
true if object allocation succeeded

Reimplemented from cugl::physics2::Joint.

◆ alloc()

static std::shared_ptr< WeldJoint > cugl::physics2::WeldJoint::alloc ( )
inlinestatic

Returns a newly allocated weld joint with default values.

The joint will not have any associated obstacles and so attempting to activate it will fail.

Returns
a newly allocated weld joint with default values.

◆ allocWithObstacles() [1/2]

static std::shared_ptr< WeldJoint > cugl::physics2::WeldJoint::allocWithObstacles ( const std::shared_ptr< Obstacle > &  obsA,
const std::shared_ptr< Obstacle > &  obsB 
)
inlinestatic

Returns a newly allocated weld joint with the given obstacles.

All other attributes will be at their default values.

Parameters
obsAThe first obstacle to join
obsBThe second obstacle to join
Returns
a newly allocated weld joint with the given obstacles.

◆ allocWithObstacles() [2/2]

static std::shared_ptr< WeldJoint > cugl::physics2::WeldJoint::allocWithObstacles ( const std::shared_ptr< Obstacle > &  obsA,
const std::shared_ptr< Obstacle > &  obsB,
const Vec2  localA,
const Vec2  localB 
)
inlinestatic

Returns a newly allocated weld joint with the given obstacles and anchors

All other attributes will be at their default values.

Parameters
obsAThe first obstacle to join
obsBThe second obstacle to join
localAThe local anchor of the first obstacle
localBThe local anchor of the second obstacle
Returns
a newly allocated weld joint with the given obstacles and anchors

◆ getDamping()

float cugl::physics2::WeldJoint::getDamping ( ) const
inline

Returns the linear damping in N*s/m.

Returns
the linear damping in N*s/m.

◆ getLocalAnchorA()

const Vec2 & cugl::physics2::WeldJoint::getLocalAnchorA ( ) const
inline

Returns the local anchor point relative to obstacle A's origin.

Returns
the local anchor point relative to obstacle A's origin.

◆ getLocalAnchorB()

const Vec2 & cugl::physics2::WeldJoint::getLocalAnchorB ( ) const
inline

Returns the local anchor point relative to obstacle B's origin.

Returns
the local anchor point relative to obstacle B's origin.

◆ getReferenceAngle()

float cugl::physics2::WeldJoint::getReferenceAngle ( ) const
inline

Returns the constrained angle between the bodies.

This value is measured bodyB - bodyA in radians.

Returns
the constrained angle between the bodies.

◆ getStiffness()

float cugl::physics2::WeldJoint::getStiffness ( ) const
inline

Returns the linear stiffness in N/m.

Returns
the linear stiffness in N/m.

◆ initWithObstacles() [1/2]

bool cugl::physics2::WeldJoint::initWithObstacles ( const std::shared_ptr< Obstacle > &  obsA,
const std::shared_ptr< Obstacle > &  obsB 
)
overridevirtual

Initializes a new weld joint with the given obstacles.

All other attributes will be at their default values.

Parameters
obsAThe first obstacle to join
obsBThe second obstacle to join
Returns
true if the obstacle is initialized properly, false otherwise.

Reimplemented from cugl::physics2::Joint.

◆ initWithObstacles() [2/2]

bool cugl::physics2::WeldJoint::initWithObstacles ( const std::shared_ptr< Obstacle > &  obsA,
const std::shared_ptr< Obstacle > &  obsB,
const Vec2  localA,
const Vec2  localB 
)

Initializes a new weld joint with the given obstacles and anchors

All other attributes will be at their default values.

Parameters
obsAThe first obstacle to join
obsBThe second obstacle to join
localAThe local anchor of the first obstacle
localBThe local anchor of the second obstacle
Returns
true if the obstacle is initialized properly, false otherwise.

◆ setDamping()

void cugl::physics2::WeldJoint::setDamping ( float  value)
inline

Sets the linear damping in N*s/m.

Parameters
valuethe linear damping

◆ setLocalAnchorA() [1/2]

void cugl::physics2::WeldJoint::setLocalAnchorA ( const Vec2  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.

Parameters
pointthe local anchor point

◆ setLocalAnchorA() [2/2]

void cugl::physics2::WeldJoint::setLocalAnchorA ( float  x,
float  y 
)
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.

Parameters
xthe x-coordinate of the local anchor point
ythe y-coordinate of the local anchor point

◆ setLocalAnchorB() [1/2]

void cugl::physics2::WeldJoint::setLocalAnchorB ( const Vec2  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.

Parameters
pointthe local anchor point

◆ setLocalAnchorB() [2/2]

void cugl::physics2::WeldJoint::setLocalAnchorB ( float  x,
float  y 
)
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.

Parameters
xthe x-coordinate of the local anchor point
ythe y-coordinate of the local anchor point

◆ setReferenceAngle()

void cugl::physics2::WeldJoint::setReferenceAngle ( float  value)
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.

Parameters
valuethe constrained angle between the bodies.

◆ setStiffness()

void cugl::physics2::WeldJoint::setStiffness ( float  value)
inline

Sets the linear stiffness in N/m.

Parameters
valuethe linear stiffness

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