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

#include <CUFrictionJoint.h>

Inheritance diagram for cugl::physics2::FrictionJoint:
cugl::physics2::Joint

Public Member Functions

 FrictionJoint ()
 
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 getMaxForce () const
 
void setMaxForce (float value)
 
float getMaxTorque () const
 
void setMaxTorque (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< FrictionJointalloc ()
 
static std::shared_ptr< FrictionJointallocWithObstacles (const std::shared_ptr< Obstacle > &obsA, const std::shared_ptr< Obstacle > &obsB)
 
static std::shared_ptr< FrictionJointallocWithObstacles (const std::shared_ptr< Obstacle > &obsA, const std::shared_ptr< Obstacle > &obsB, const Vec2 localA, const Vec2 localB)
 

Protected Attributes

Vec2 _localAnchorA
 
Vec2 _localAnchorB
 
float _maxForce
 
float _maxTorque
 
- 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 friction joint class.

Constructor & Destructor Documentation

◆ FrictionJoint()

cugl::physics2::FrictionJoint::FrictionJoint ( )

Creates a new friction 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::FrictionJoint::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< FrictionJoint > cugl::physics2::FrictionJoint::alloc ( )
inlinestatic

Returns a newly allocated friction joint with default values.

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

Returns
a newly allocated friction joint with default values.

◆ allocWithObstacles() [1/2]

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

Returns a newly allocated friction 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 friction joint with the given obstacles.

◆ allocWithObstacles() [2/2]

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

Returns a newly allocated friction 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 friction joint with the given obstacles and anchors

◆ getLocalAnchorA()

const Vec2 & cugl::physics2::FrictionJoint::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::FrictionJoint::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.

◆ getMaxForce()

float cugl::physics2::FrictionJoint::getMaxForce ( ) const
inline

Returns the maximum friction force in N

Returns
the maximum friction force in N

◆ getMaxTorque()

float cugl::physics2::FrictionJoint::getMaxTorque ( ) const
inline

Returns the maximum friction torque in N-m.

Returns
the maximum friction torque in N-m.

◆ initWithObstacles() [1/2]

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

Initializes a new friction 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::FrictionJoint::initWithObstacles ( const std::shared_ptr< Obstacle > &  obsA,
const std::shared_ptr< Obstacle > &  obsB,
const Vec2  localA,
const Vec2  localB 
)

Initializes a new friction 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.

◆ setLocalAnchorA() [1/2]

void cugl::physics2::FrictionJoint::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::FrictionJoint::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::FrictionJoint::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::FrictionJoint::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

◆ setMaxForce()

void cugl::physics2::FrictionJoint::setMaxForce ( float  value)
inline

Sets the maximum friction force in N

Parameters
valuethe maximum friction force

◆ setMaxTorque()

void cugl::physics2::FrictionJoint::setMaxTorque ( float  value)
inline

Sets the maximum friction torque in N-m.

Parameters
valuethe maximum friction torque

Member Data Documentation

◆ _localAnchorA

Vec2 cugl::physics2::FrictionJoint::_localAnchorA
protected

The local anchor point relative to obstacle A's origin.

◆ _localAnchorB

Vec2 cugl::physics2::FrictionJoint::_localAnchorB
protected

The local anchor point relative to obstacle B's origin.

◆ _maxForce

float cugl::physics2::FrictionJoint::_maxForce
protected

The maximum friction force in N.

◆ _maxTorque

float cugl::physics2::FrictionJoint::_maxTorque
protected

The maximum friction torque in N-m.


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