Box2D 3.1.0
A 2D physics engine for games
Loading...
Searching...
No Matches
Mouse Joint

Functions for the mouse joint. More...

Collaboration diagram for Mouse Joint:

Data Structures

struct  b2MouseJointDef
 A mouse joint is used to make a point on a body track a specified world point. More...
 

Functions

b2JointId b2CreateMouseJoint (b2WorldId worldId, const b2MouseJointDef *def)
 Create a mouse joint.
 
void b2MouseJoint_SetTarget (b2JointId jointId, b2Vec2 target)
 Set the mouse joint target.
 
b2Vec2 b2MouseJoint_GetTarget (b2JointId jointId)
 Get the mouse joint target.
 
void b2MouseJoint_SetSpringHertz (b2JointId jointId, float hertz)
 Set the mouse joint spring stiffness in Hertz.
 
float b2MouseJoint_GetSpringHertz (b2JointId jointId)
 Get the mouse joint spring stiffness in Hertz.
 
void b2MouseJoint_SetSpringDampingRatio (b2JointId jointId, float dampingRatio)
 Set the mouse joint spring damping ratio, non-dimensional.
 
float b2MouseJoint_GetSpringDampingRatio (b2JointId jointId)
 Get the mouse joint damping ratio, non-dimensional.
 
void b2MouseJoint_SetMaxForce (b2JointId jointId, float maxForce)
 Set the mouse joint maximum force, typically in newtons.
 
float b2MouseJoint_GetMaxForce (b2JointId jointId)
 Get the mouse joint maximum force, typically in newtons.
 
b2MouseJointDef b2DefaultMouseJointDef (void)
 Use this to initialize your joint definition.
 

Detailed Description

Functions for the mouse joint.

The mouse joint is designed for use in the samples application, but you may find it useful in applications where the user moves a rigid body with a cursor.


Data Structure Documentation

◆ b2MouseJointDef

struct b2MouseJointDef

A mouse joint is used to make a point on a body track a specified world point.

This a soft constraint and allows the constraint to stretch without applying huge forces. This also applies rotation constraint heuristic to improve control.

Collaboration diagram for b2MouseJointDef:
Data Fields
b2BodyId bodyIdA The first attached body.
b2BodyId bodyIdB The second attached body.
bool collideConnected Set this flag to true if the attached bodies should collide.
float dampingRatio Damping ratio, non-dimensional.
float hertz Stiffness in hertz.
int32_t internalValue Used internally to detect a valid definition. DO NOT SET.
float maxForce Maximum force, typically in newtons.
b2Vec2 target The initial target point in world space.
void * userData User data pointer.

Function Documentation

◆ b2CreateMouseJoint()

b2JointId b2CreateMouseJoint ( b2WorldId worldId,
const b2MouseJointDef * def )

Create a mouse joint.

See also
b2MouseJointDef for details