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.
|
Classes | |
class | ConcreteContactListener |
Public Member Functions | |
void | addBody (FBody body) |
void | removeBody (FBody body) |
void | addJoint (FJoint joint) |
void | removeJoint (FJoint joint) |
void | setContactListener (final FContactListener listener) |
void | grabBody (float x, float y) |
void | dragBody (float x, float y) |
void | releaseBody () |
void | mouseEvent (MouseEvent event) |
FWorld (float topLeftX, float topLeftY, float bottomRightX, float bottomRightY) | |
FMouseJoint | getMouseJoint () |
void | setGrabbable (boolean value) |
void | processActions () |
void | draw (PApplet applet) |
void | draw (PGraphics graphics) |
void | drawDebug (PApplet applet) |
void | drawDebug (PGraphics graphics) |
void | draw () |
void | drawDebug () |
void | add (FBody body) |
void | remove (FBody body) |
void | add (FJoint joint) |
void | remove (FJoint joint) |
void | clear () |
void | setEdges (float topLeftX, float topLeftY, float bottomRightX, float bottomRightY, int color) |
void | setEdges (float topLeftX, float topLeftY, float bottomRightX, float bottomRightY) |
void | setEdges (PApplet applet, int color) |
void | setEdges (int color) |
void | setEdges () |
void | setEdgesFriction (float friction) |
void | setEdgesRestitution (float restitution) |
void | setGravity (float gx, float gy) |
void | step () |
void | step (float dt) |
void | step (float dt, int iterationCount) |
FBody | getBody (float x, float y) |
FBody | getBody (float x, float y, boolean getStatic) |
ArrayList | getBodies () |
ArrayList | getBodies (float x, float y) |
ArrayList | getBodies (float x, float y, boolean getStatic) |
ArrayList | getBodies (float x, float y, boolean getStatic, int count) |
int | raycast (float x1, float y1, float x2, float y2, FBody[] bodies, int maxCount, boolean solidShapes) |
FBody | raycastOne (float x1, float y1, float x2, float y2, FRaycastResult result, boolean solidShapes) |
Public Attributes | |
FBox | left |
FBox | right |
FBox | top |
FBox | bottom |
Protected Attributes | |
float | m_topLeftX |
float | m_topLeftY |
float | m_bottomRightX |
float | m_bottomRightY |
float | m_edgesFriction = 0.1f |
float | m_edgesRestitution = 0.1f |
boolean | m_grabbable = true |
float | m_grabPositionX = 0.0f |
float | m_grabPositionY = 0.0f |
int | m_mouseButton = PConstants.LEFT |
HashMap | m_contacts |
ArrayList | m_contactResults |
LinkedList | m_actions |
ArrayList | m_fbodies = new ArrayList() |
FMouseJoint | m_mouseJoint = new FMouseJoint((FBody)null, 0.0f, 0.0f) |
Represents the world where all the bodies live in. When we create a world it will have the size of the applet that it is created in. Once the world is created we can add bodies to it or remove bodies we have added.
Once the world is created we may add or remove bodies to it using add and remove. We may also call step to advance one step the simulation. Finally we can draw the world and all the bodies living in it by using draw.
World
FWorld.FWorld | ( | float | topLeftX, |
float | topLeftY, | ||
float | bottomRightX, | ||
float | bottomRightY | ||
) |
Constructs the world where all the bodies live in. We usually want to build the world larger than the actual screen, because when bodies exit the world they will appear stuck since they do not get update anymore. By default the world's width and height are three times larger than those of the Processing canvas.
World
topLeftX | the horizontal coordinate of the top left corner of the world |
topLeftY | the vertical coordinate of the top left corner of the world |
bottomRightX | the horizontal coordinate of the bottom right corner of the world |
bottomRightY | the vertical coordinate of the bottom right corner of the world |
void FWorld.add | ( | FBody | body | ) |
void FWorld.add | ( | FJoint | joint | ) |
void FWorld.clear | ( | ) |
Clear all bodies and joints from the world. NOT IMPLEMENTED YET.
void FWorld.draw | ( | PApplet | applet | ) |
Draws all the bodies in the world. This method is often called in the draw method of the applet.
applet | applet to which to draw the world. Useful when trying to draw the world on other Processing backends, such as PDF |
void FWorld.draw | ( | PGraphics | graphics | ) |
Draws all the bodies in the world. This method is often called in the draw method of the applet.
graphics | graphics to which to draw the world. Useful when trying to draw the world on other buffers, such as when using createGraphics |
void FWorld.draw | ( | ) |
Draws all the bodies in the world on the applet canvas. This method is often called in the draw method of the applet.
void FWorld.drawDebug | ( | PApplet | applet | ) |
Draws the debug version of all the bodies in the world. This method is often called in the draw method of the applet.
applet | applet to which to draw the world. Useful when trying to draw the world on other Processing backends, such as PDF |
void FWorld.drawDebug | ( | PGraphics | graphics | ) |
Draws the debug version of all the bodies in the world. This method is often called in the draw method of the applet.
graphics | graphics to which to draw the world. Useful when trying to draw the world on other buffers, such as when using createGraphics |
void FWorld.drawDebug | ( | ) |
Draws the debug version of all the bodies in the world on the applet canvas. This method is often called in the draw method of the applet.
ArrayList FWorld.getBodies | ( | ) |
Returns a list with all the bodies in the world
ArrayList FWorld.getBodies | ( | float | x, |
float | y | ||
) |
Returns a list with the 10 first bodies found at the given position.
x | the horizontal component of the position |
y | the vertical component of the position |
ArrayList FWorld.getBodies | ( | float | x, |
float | y, | ||
boolean | getStatic | ||
) |
Returns a list with the 10 first bodies found at the given position.
x | the horizontal component of the position |
y | the vertical component of the position |
getStatic | if true |
ArrayList FWorld.getBodies | ( | float | x, |
float | y, | ||
boolean | getStatic, | ||
int | count | ||
) |
Returns a list with all the bodies found at the given position.
x | the horizontal component of the position |
y | the vertical component of the position |
getStatic | if true |
count | the maximum number of bodies to be retrieved |
FBody FWorld.getBody | ( | float | x, |
float | y | ||
) |
Returns the first object found at the given position.
x | the horizontal component of the position |
y | the vertical component of the position |
FBody FWorld.getBody | ( | float | x, |
float | y, | ||
boolean | getStatic | ||
) |
Returns the first object found at the given position.
x | the horizontal component of the position |
y | the vertical component of the position |
getStatic | if true |
FMouseJoint FWorld.getMouseJoint | ( | ) |
Returns the mouse joint that is used for interaction with the bodies in the world.
void FWorld.mouseEvent | ( | MouseEvent | event | ) |
This is an internal method to handle mouse interaction and should not be used.
void FWorld.remove | ( | FBody | body | ) |
void FWorld.remove | ( | FJoint | joint | ) |
Remove a joint from the world.
joint | joint to be removed from the world |
void FWorld.setEdges | ( | float | topLeftX, |
float | topLeftY, | ||
float | bottomRightX, | ||
float | bottomRightY, | ||
int | color | ||
) |
Add edges of given dimensions to the world. This will create the bodies for left, right, bottom and top.
topLeftX | the horizontal coordinate of the top left corner of the edges |
topLeftY | the vertical coordinate of the top left corner of the edges |
bottomRightX | the horizontal coordinate of the bottom right corner of the edges |
bottomRightY | the vertical coordinate of the bottom right corner of the edges |
color | the color of the edges. This color must be passed using Processing's color() function |
void FWorld.setEdges | ( | float | topLeftX, |
float | topLeftY, | ||
float | bottomRightX, | ||
float | bottomRightY | ||
) |
Add black edges of given dimensions to the world. This will create the bodies for left, right, bottom and top.
topLeftX | the horizontal coordinate of the top left corner of the edges |
topLeftY | the vertical coordinate of the top left corner of the edges |
bottomRightX | the horizontal coordinate of the bottom right corner of the edges |
bottomRightY | the vertical coordinate of the bottom right corner of the edges |
color | the color of the edges. This color must be passed using Processing's color() function |
void FWorld.setEdges | ( | PApplet | applet, |
int | color | ||
) |
void FWorld.setEdges | ( | int | color | ) |
void FWorld.setEdges | ( | ) |
void FWorld.setEdgesFriction | ( | float | friction | ) |
Set the friction of all the edges.
friction | the friction of the edges |
void FWorld.setEdgesRestitution | ( | float | restitution | ) |
Set the restitution of all the edges.
restitution | the restitution of the edges |
void FWorld.setGrabbable | ( | boolean | value | ) |
Controls whether the bodies in the world can be grabbed by the mouse or not. By default the world bodies' are grabbable and draggable.
World
value | if true the bodies that live in this world can be grabbed and dragged using the mouse |
void FWorld.setGravity | ( | float | gx, |
float | gy | ||
) |
Set the gravity of the world. Use
to have a world without gravity.
gx | the horizontal component of the gravity |
gy | the vertical component of the gravity |
void FWorld.step | ( | ) |
Advance the world simulation of 1/60th of a second.
void FWorld.step | ( | float | dt | ) |
Advance the world simulation of given time.
dt | the time to advance the world simulation |
void FWorld.step | ( | float | dt, |
int | iterationCount | ||
) |
Advance the world simulation of given time, with a given number of iterations. The larger the number of iterations, the more computationally expensive and precise it will be. The default is 10 iterations.
dt | the time to advance the world simulation |
iterationCount | the number of iterations for the world simulation step |
FBox FWorld.bottom |
The bottom edge of the world. For this edge to exist, the edges must have been created by calling setEdges().
FBox FWorld.left |
The left edge of the world. For this edge to exist, the edges must have been created by calling setEdges().
FBox FWorld.right |
The right edge of the world. For this edge to exist, the edges must have been created by calling setEdges().
FBox FWorld.top |
The top edge of the world. For this edge to exist, the edges must have been created by calling setEdges().