hAPI Fisica  0.1
The hAPI Fisica physics engine expands Richard Marxer's fisica for Processing. The engine wraps the jbox2d physics engine for use with the Haply Development kit and the Hapkit.
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
FRevoluteJoint Class Reference
Inheritance diagram for FRevoluteJoint:
FJoint FDrawable

Public Member Functions

 FRevoluteJoint (FBody body1, FBody body2, float x, float y)
 
 FRevoluteJoint (FBody body1, FBody body2)
 
void setLowerAngle (float a)
 
void setUpperAngle (float a)
 
void setEnableLimit (boolean value)
 
void setMotorSpeed (float a)
 
void setMaxMotorTorque (float a)
 
void setEnableMotor (boolean value)
 
void setAnchor (float x, float y)
 
float getAnchorX ()
 
float getAnchorY ()
 
void setReferenceAngle (float ang)
 
void draw (PGraphics applet)
 
void drawDebug (PGraphics applet)
 
- Public Member Functions inherited from FJoint
Joint getBox2dJoint ()
 
void addToWorld (FWorld world)
 
void removeFromWorld ()
 
FBody getBody1 ()
 
FBody getBody2 ()
 
void setCollideConnected (boolean value)
 
float getReactionForceX ()
 
float getReactionForceY ()
 
float getReactionTorque ()
 
- Public Member Functions inherited from FDrawable
void draw (PGraphics graphics)
 
void draw (PApplet applet)
 
void drawDebug (PGraphics graphics)
 
void drawDebug (PApplet applet)
 
void attachImage (PImage img)
 
void dettachImage ()
 
float getImageAlpha ()
 
void setImageAlpha (float alpha)
 
void setDrawable (boolean drawable)
 
boolean isDrawable ()
 
int getFillColor ()
 
void setFillColor (int col)
 
void setNoFill ()
 
void setFill (float g)
 
void setFill (float g, float a)
 
void setFill (float r, float g, float b)
 
void setFill (float r, float g, float b, float a)
 
void setStrokeColor (int col)
 
void setNoStroke ()
 
void setStroke (float g)
 
void setStroke (float g, float a)
 
void setStroke (float r, float g, float b)
 
void setStroke (float r, float g, float b, float a)
 
void setStrokeWeight (float weight)
 

Protected Member Functions

void updateLocalAnchors ()
 
JointDef getJointDef (FWorld world)
 
- Protected Member Functions inherited from FJoint
void processJoint (World world, JointDef jd)
 
JointDef getJointDef (FWorld world)
 
void preDraw (PGraphics applet)
 
void postDraw (PGraphics applet)
 
void preDrawDebug (PGraphics applet)
 
void postDrawDebug (PGraphics applet)
 
- Protected Member Functions inherited from FDrawable
void updateStyle (FDrawable other)
 
void appletStroke (PGraphics applet, int argb)
 
void appletFill (PGraphics applet, int argb)
 
void appletFillStroke (PGraphics applet)
 
void drawImage (PGraphics applet)
 

Protected Attributes

FBody m_body1
 
FBody m_body2
 
Vec2 m_anchor
 
Vec2 m_localAnchor1 = new Vec2(0.0f, 0.0f)
 
Vec2 m_localAnchor2 = new Vec2(0.0f, 0.0f)
 
float m_referenceAngle = 0.0f
 
boolean m_enableLimit = false
 
float m_lowerAngle = 0.0f
 
float m_upperAngle = 0.0f
 
boolean m_enableMotor = false
 
float m_motorSpeed = 0.0f
 
float m_maxMotorTorque = 0.0f
 
- Protected Attributes inherited from FJoint
Joint m_joint
 
FWorld m_world
 
boolean m_collideConnected = true
 
- Protected Attributes inherited from FDrawable
boolean m_drawable = true
 
boolean m_fill = true
 
int m_fillColor = 0xFFFFFFFF
 
boolean m_stroke = true
 
int m_strokeColor = 0xFF000000
 
float m_strokeWeight = 1.0f
 
PImage m_image = null
 
float m_imageAlpha = 255.0f
 
PImage m_mask = null
 

Detailed Description

Represents a revolute joint that restricts the movement of one body with respect to another to rotation around a given anchor. The rotation can be further limited given a lower and un upper angles. Additionally the user can enable a motor in order to apply a constant rotation force (torque) to the joint in order to reach the desired rotation speed.

Constructor & Destructor Documentation

◆ FRevoluteJoint() [1/2]

FRevoluteJoint.FRevoluteJoint ( FBody  body1,
FBody  body2,
float  x,
float  y 
)

Construct a revolute joint between two bodies given an anchor position.

Parameters
body1first body of the joint
body2second body of the joint
xhorizontal coordinate of the anchor given in global coordinates, relative to the canvas' center
yvertical coordinate of the anchor given in global coordinates, relative to the canvas' center

◆ FRevoluteJoint() [2/2]

FRevoluteJoint.FRevoluteJoint ( FBody  body1,
FBody  body2 
)

Construct a revolute joint between two bodies.

Parameters
body1first body of the joint
body2second body of the joint

Member Function Documentation

◆ getAnchorX()

float FRevoluteJoint.getAnchorX ( )

Get the horizontal coordinate of the anchor of the joint around which the bodies can rotate. This position is given global coordinates, relative to the center of the canvas.

Returns
the horizontal coordinate of the anchor in global coordinates, relative to the center of the canvas

◆ getAnchorY()

float FRevoluteJoint.getAnchorY ( )

Get the vertical coordinate of the anchor of the joint around which the bodies can rotate. This position is given global coordinates, relative to the center of the canvas.

Returns
the vertical coordinate of the anchor in global coordinates, relative to the center of the canvas

◆ setAnchor()

void FRevoluteJoint.setAnchor ( float  x,
float  y 
)

Sets the position of the anchor of the joint around which the bodies rotate. This position is given global coordinates, relative to the center of the canvas.

Parameters
xthe horizontal coordinate of the anchor in global coordinates, relative to the center of the canvas
ythe vertical coordinate of the anchor in global coordinates, relative to the center of the canvas

◆ setEnableLimit()

void FRevoluteJoint.setEnableLimit ( boolean  value)

Set limits to the allowed rotation of one body respect to the other. If set to

true

the limits imposed using setLowerAngle and setLowerAngle are enforced.

Parameters
valueif
true
the bodies will be able to rotate around the anchor only between certain limits

◆ setEnableMotor()

void FRevoluteJoint.setEnableMotor ( boolean  value)

Set the state of the motor in order to generate a rotation force (torque) on the joint. If set to

true

the desired motor speed, set using setMotorSpeed, will try to be matched using a motor with a maximum rotation force (torque) set using setMaxMotorTorque.

Parameters
valueif
true
the joint will receive the rotation force (torque) of a motor

◆ setLowerAngle()

void FRevoluteJoint.setLowerAngle ( float  a)

Set the lowest angle allowed. This property only has effect if the

enableLimit

has been set to

true

using setEnableLimit(boolean).

Parameters
alowest angle allowed in radians

◆ setMaxMotorTorque()

void FRevoluteJoint.setMaxMotorTorque ( float  a)

Set the maximum torque that the joint's motor can apply in order to acheive the desired speed. This property only has effect if the

enableMotor

has been set to

true

using setEnableMotor(boolean).

Parameters
athe maximum torque of the joint's motor

◆ setMotorSpeed()

void FRevoluteJoint.setMotorSpeed ( float  a)

Set the desired rotation speed of the joint. This property only has effect if the

enableMotor

has been set to

true

using setEnableMotor(boolean). The speed is given in radians per second.

Parameters
athe desired speed in radians per second

◆ setUpperAngle()

void FRevoluteJoint.setUpperAngle ( float  a)

Set the highest angle allowed. This property only has effect if the

enableLimit

has been set to

true

using setEnableLimit(boolean).

Parameters
ahighest angle allowed in radians

Member Data Documentation

◆ m_enableLimit

boolean FRevoluteJoint.m_enableLimit = false
protected

A flag to enable joint limits.

◆ m_enableMotor

boolean FRevoluteJoint.m_enableMotor = false
protected

A flag to enable the joint motor.

◆ m_localAnchor1

Vec2 FRevoluteJoint.m_localAnchor1 = new Vec2(0.0f, 0.0f)
protected

The local anchor point relative to body1's origin.

◆ m_localAnchor2

Vec2 FRevoluteJoint.m_localAnchor2 = new Vec2(0.0f, 0.0f)
protected

The local anchor point relative to body2's origin.

◆ m_lowerAngle

float FRevoluteJoint.m_lowerAngle = 0.0f
protected

The lower angle for the joint limit (radians).

◆ m_maxMotorTorque

float FRevoluteJoint.m_maxMotorTorque = 0.0f
protected

The maximum motor torque used to achieve the desired motor speed. Usually in N-m.

◆ m_motorSpeed

float FRevoluteJoint.m_motorSpeed = 0.0f
protected

The desired motor speed. Usually in radians per second.

◆ m_referenceAngle

float FRevoluteJoint.m_referenceAngle = 0.0f
protected

The body2 angle minus body1 angle in the reference state (radians).

◆ m_upperAngle

float FRevoluteJoint.m_upperAngle = 0.0f
protected

The upper angle for the joint limit (radians).


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