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 | |
Body | getBox2dBody () |
int | getGroupIndex () |
void | addToWorld (FWorld world) |
void | setState (FBody b) |
void | setStateFromWorld () |
void | recreateInWorld () |
void | removeFromWorld () |
void | setGroupIndex (int index) |
void | setFilterBits (int mask) |
void | setCategoryBits (int mask) |
int | getCategoryBits () |
int | getFilterBits () |
void | setParent (FBody b) |
FBody | getParent () |
void | setGrabbable (boolean value) |
void | setForce (float fx, float fy) |
float | getForceX () |
float | getForceY () |
void | addTorque (float torque) |
void | addForce (float fx, float fy) |
void | addImpulse (float fx, float fy) |
void | addForce (float fx, float fy, float px, float py) |
void | addImpulse (float fx, float fy, float px, float py) |
void | resetForces () |
float | getVelocityX () |
float | getVelocityY () |
void | setVelocity (float vx, float vy) |
void | adjustVelocity (float dvx, float dvy) |
float | getX () |
float | getY () |
void | setPosition (float x, float y) |
void | adjustPosition (float dx, float dy) |
float | getRotation () |
float | getHapticStiffness () |
float | getHapticDamping () |
void | setRotation (float w) |
void | adjustRotation (float dw) |
boolean | isResting () |
boolean | isSleeping () |
void | wakeUp () |
float | getAngularVelocity () |
void | setAngularVelocity (float w) |
void | adjustAngularVelocity (float dw) |
void | setAngularDamping (float damping) |
void | setDamping (float damping) |
void | setName (String name) |
String | getName () |
void | setDensity (float density) |
float | getDensity () |
void | setSensor (boolean value) |
boolean | isSensor () |
void | setHaptic (boolean value) |
void | setHaptic (boolean value, float stiffness, float damping) |
boolean | isHaptic () |
void | setHapticStiffness (float stiffness) |
void | setHapticDamping (float damping) |
void | setStaticBody (boolean value) |
void | setStatic (boolean value) |
float | getMass () |
boolean | isStatic () |
void | setBullet (boolean value) |
void | setRestitution (float restitution) |
void | setFriction (float friction) |
void | setRotatable (boolean rotatable) |
void | setAllowSleeping (boolean allowSleep) |
ArrayList | getTouching () |
ArrayList | getContacts () |
ArrayList | getJoints () |
boolean | isConnected (FBody other) |
boolean | isTouchingBody (FBody b) |
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 | processBody (Body bd, ShapeDef sd) |
ShapeDef | getShapeDef () |
ShapeDef | getTransformedShapeDef () |
ShapeDef | getProcessedShapeDef () |
ArrayList | getShapeDefs () |
ArrayList | getBodies () |
ShapeDef | processShapeDef (ShapeDef sd) |
void | preDraw (PGraphics applet) |
void | postDraw (PGraphics applet) |
void | preDrawDebug (PGraphics applet) |
void | postDrawDebug (PGraphics applet) |
AABB | getAABB () |
AABB | getBB () |
void | applyMatrix (PGraphics applet) |
void | setPosition (Vec2 position) |
void | updateMass () |
Vec2 | getLocalWorldPoint (Vec2 p) |
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 | |
float | m_density = 1.0f |
float | m_restitution = 0.1f |
float | m_friction = 0.1f |
boolean | m_bullet = false |
boolean | m_sensor = false |
boolean | m_static = false |
float | m_linearDamping = 0.5f |
float | m_gravityScale = 1.0f |
float | m_angularDamping = 0.5f |
boolean | m_rotatable = true |
boolean | m_allowSleep = true |
boolean | m_isSleeping = false |
int | m_groupIndex = 0 |
int | m_filterBits = 0xffff |
int | m_categoryBits = 0x0001 |
Vec2 | m_linearVelocity = new Vec2(0.0f, 0.0f) |
float | m_angularVelocity = 0.0f |
Vec2 | m_force = new Vec2(0.0f, 0.0f) |
float | m_torque = 0.0f |
Vec2 | m_position = new Vec2(0.0f, 0.0f) |
float | m_angle = 0.0f |
String | m_name |
Body | m_body |
FWorld | m_world |
FBody | m_parent |
boolean | m_grabbable = true |
boolean | h_isHaptic = true |
float | h_damping = 0.0f |
float | h_stiffness =0.0f |
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 |
Represents a body in the world.
A body is an object which may collide and react to forces in the world. The bodies have many properties such as density, velocity, position, etc... with which we can control their behavior. This class cannot be be instantiated, instead use one of the derived classes.
void FBody.addForce | ( | float | fx, |
float | fy | ||
) |
Aply a force on the center of the body.
fx | the x coordinate of the force |
fy | the y coordinate of the force |
void FBody.addForce | ( | float | fx, |
float | fy, | ||
float | px, | ||
float | py | ||
) |
Apply a force to a given point of the body. If the force is not applied on the center of the body this force might induce a rotation change. It would be as applying a force on the center of the body and a torque.
fx | the x coordinate of the force |
fy | the y coordinate of the force |
px | the x position relative to the body's center, where to apply the force |
py | the y position relative to the body's center, where to apply the force |
void FBody.addImpulse | ( | float | fx, |
float | fy | ||
) |
Apply an impulse on the center of the body.
fx | the x coordinate of the force |
fy | the y coordinate of the force |
void FBody.addImpulse | ( | float | fx, |
float | fy, | ||
float | px, | ||
float | py | ||
) |
Apply an impulse to a given point of the body. If the impulse is not applied on the center of the body this force might induce a rotation change. It would be as applying a force on the center of the body and a torque.
fx | the x coordinate of the force |
fy | the y coordinate of the force |
px | the x position relative to the body's center, where to apply the force |
py | the y position relative to the body's center, where to apply the force |
void FBody.addTorque | ( | float | torque | ) |
Add a rotation force (a torque) to the body.
torque | the value of the torque |
void FBody.adjustAngularVelocity | ( | float | dw | ) |
Adjust the rotation velocity of the body.
dw | the rotation velocity to be added to the body in radians per second |
void FBody.adjustPosition | ( | float | dx, |
float | dy | ||
) |
Adjust the position of the body.
dx | the horizontal position to be added to the body in simulation world units |
dy | the vertical position to be added to the body in simulation world units |
void FBody.adjustRotation | ( | float | dw | ) |
Adjust the rotation of the body.
dw | the rotation to be added to the body in radians |
void FBody.adjustVelocity | ( | float | dvx, |
float | dvy | ||
) |
Adjust the velocity of the body.
dvx | the horizontal velocity to be added to the body in simulation world units per second |
dvy | the vertical velocity to be added to the body in simulation world units per second |
float FBody.getAngularVelocity | ( | ) |
Returns the rotation velocity of the body.
Body FBody.getBox2dBody | ( | ) |
WARNING: This method is internal only and may change someday. If you are using this method please contact the developer since there should be a better way or we may add something to the library.
ArrayList FBody.getContacts | ( | ) |
Return a list of contacts currently involving the body.
float FBody.getDensity | ( | ) |
Get the density of the body. The density determines the total mass of the body and thus it's behavior with respect to collisions, bounces, inertia, joints,...
Note that a density of 0.0 corresponds to a mass of 0.0 independently of the area and the body will be considered static.
float FBody.getForceX | ( | ) |
Get the x coordinate of the force applied to the center of the body.
float FBody.getForceY | ( | ) |
Get the y coordinate of the force applied to the center of the body.
int FBody.getGroupIndex | ( | ) |
Get the group to which this body belongs. Groups allow to select the bodies that may collide together or with others. If the group index is negative then they will not collide with each other but they will collide with all the bodies of the other groups.
float FBody.getHapticDamping | ( | ) |
Returns the haptic damping of the body.
float FBody.getHapticStiffness | ( | ) |
Returns the haptic stiffness of the body.
ArrayList FBody.getJoints | ( | ) |
Returns a list with all the joints with a connection to the body
float FBody.getMass | ( | ) |
Returns the mass of the body. Static bodies or bodies not added to the world return 0.
String FBody.getName | ( | ) |
Get the name of the body.
float FBody.getRotation | ( | ) |
Returns the rotation of the body.
ArrayList FBody.getTouching | ( | ) |
Return a list of bodies currently touching the body.
float FBody.getVelocityX | ( | ) |
Returns the horizontal velocity of the body.
float FBody.getVelocityY | ( | ) |
Returns the vertical velocity of the body.
float FBody.getX | ( | ) |
Returns the horizontal position of the body.
float FBody.getY | ( | ) |
Returns the vertical position of the body.
boolean FBody.isConnected | ( | FBody | other | ) |
Returns true if the body is joint to the body passed as argument
other | the other body |
boolean FBody.isHaptic | ( | ) |
Returns whether the body is a haptic body. Haptic bodies act as normal bodies in the sense that they notify about contacts, however they allow for penalty based force calculation that resut from colliding with other bodies. This can be used for direct contact rendering using penalty forumations.
boolean FBody.isResting | ( | ) |
Deprecated. Please use isSleeping().
boolean FBody.isSensor | ( | ) |
Returns whether the body is a sensor. Sensor bodies act as normal bodies in the sense that they notify about contacts, however they do not collide with other bodies (they act like ghost bodies).
boolean FBody.isSleeping | ( | ) |
Indicates whether the body is in a sleeping state.
The sleeping state of a body is reached when it has not moved or has not received any forces nor collisions for some time.
boolean FBody.isStatic | ( | ) |
Returns whether the body is static. Static bodies do not move or rotate, unless done manually using setPosition or setRotation.
boolean FBody.isTouchingBody | ( | FBody | b | ) |
Return whether the body is currently touching the body passed as argument.
b | the body for which we want to know if there is contact |
void FBody.resetForces | ( | ) |
Remove all the forces that are applied to the body.
void FBody.setAllowSleeping | ( | boolean | allowSleep | ) |
Set whether the body can sleep.
allowSleep | if true |
void FBody.setAngularDamping | ( | float | damping | ) |
Set the damping of the rotation movement of the body. The damping constantly reduces the rotation velocity of the body.
damping | the damping of the rotation movement of the body |
void FBody.setAngularVelocity | ( | float | w | ) |
Set the rotation velocity of the body.
w | the rotation velocity of the body in radians per second |
void FBody.setBullet | ( | boolean | value | ) |
Set whether the body is a bullet. Bullet bodies are computationally more expensive but more accurate in their movement. Use this only with fast objects.
value | if true |
void FBody.setDamping | ( | float | damping | ) |
Set the damping of the translation movement of the body. The damping constantly reduces the translation velocity of the body.
damping | the damping of the translation movement of the body |
void FBody.setDensity | ( | float | density | ) |
Set the density of the body. The density will determine the total mass of the body and thus it's behavior with respect to collisions, bounces, inertia, joints,... When the density is set, the mass of the body is recalculated automatically given it's area.
Note that a density of 0.0 corresponds to a mass of 0.0 independently of the area and the body will be considered static.
density | the density of the body |
void FBody.setForce | ( | float | fx, |
float | fy | ||
) |
Set the force applied to the center of the body.
fx | the x coordinate of the force |
fy | the y coordinate of the force |
void FBody.setFriction | ( | float | friction | ) |
Set the friction of the body. The friction determines the ratio of the reaction force tangent to a contact, when the body collides with another body. Basically it can be seen as a coefficient that will control how the body gets slown down when the body slides against another body. The friction of a contact of two bodies in a collision is calculated from the friction values of the 2 bodies involved.
friction | a positive value. A value of 0 means no friction and thus the body will not be slown down if no other forces are applied |
void FBody.setGrabbable | ( | boolean | value | ) |
Control if this body can be grabbed by the mouse, when clicked on. This property only has effect if the world is grabbable. If a body is grabbable, then it can be dragged around by the mouse.
value | if true |
void FBody.setGroupIndex | ( | int | index | ) |
Control the group to which this body belongs. Groups allow to select the bodies that may collide together or with others. If the group index is negative then they will not collide with each other but they will collide with all the bodies of the other groups.
index | the index of the group |
void FBody.setHaptic | ( | boolean | value | ) |
Set whether the body is a haptic body. Haptic bodies act as normal bodies in the sense that they notify about contacts, however they allow for collision with other bodies using a penalty based method. This allows us to render haptic contacts to a device.
value | if true false |
void FBody.setHaptic | ( | boolean | value, |
float | stiffness, | ||
float | damping | ||
) |
Set whether the body is a haptic body. Haptic bodies act as normal bodies in the sense that they notify about contacts, however they allow for collision with other bodies using a penalty based method. This allows us to render haptic contacts to a device.
value | if true false |
stiffness | sets the stiffness of the haptic body for direct collision rendering |
damping | sets the damping coefficent of the haptic body for direct collision rendering |
void FBody.setHapticDamping | ( | float | damping | ) |
Sets the damping of a haptic body for penalty based contact rendering.
damping | The damping of the haptic body. Resultant forces are proportional to the amount of penetration between bodies |
void FBody.setHapticStiffness | ( | float | stiffness | ) |
Sets the stiffness of a haptic body for penalty based contact rendering.
stiffness | The stiffness of the haptic body. Resultant forces are proportional to the amount of penetration between bodies |
void FBody.setName | ( | String | name | ) |
Set the name of the body.
name | the name of the body |
void FBody.setPosition | ( | float | x, |
float | y | ||
) |
Set the position of the body.
x | the horizontal position of the body in simulation world units |
y | the vertical position of the body in simulation world units |
void FBody.setRestitution | ( | float | restitution | ) |
Set the restitution of the body. The restitution determines the ratio of the reaction force normal to a contact, when the body collides with another body. Basically it can be seen as a coefficient that will control the strength with which the body bounces back from a collision. The resititution of a contact of two bodies in a collision is calculated as the maximum of the restitution values of the 2 bodies involved.
restitution | a positive value. A value of 0 means no bounce after a collision, and a value of 1 means bounce with it's full speed from a collision |
void FBody.setRotatable | ( | boolean | rotatable | ) |
Set whether the body can rotate.
rotatable | if true |
void FBody.setRotation | ( | float | w | ) |
void FBody.setSensor | ( | boolean | value | ) |
Set whether the body is a sensor. Sensor bodies act as normal bodies in the sense that they notify about contacts, however they do not collide with other bodies (they act like ghost bodies).
value | if true |
void FBody.setStatic | ( | boolean | value | ) |
Set whether the body is static. Static bodies do not move or rotate, unless done manually using setPosition or setRotation.
value | if true |
void FBody.setStaticBody | ( | boolean | value | ) |
Set whether the body is static. Static bodies do not move or rotate, unless done manually using setPosition or setRotation.
value | if true |
void FBody.setVelocity | ( | float | vx, |
float | vy | ||
) |
Set the velocity of the body.
vx | the horizontal velocity of the body in simulation world units per second |
vy | the vertical velocity of the body in simulation world units per second |
void FBody.wakeUp | ( | ) |
Wake up the body from a sleeping state.