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 | |
FBody | getBody1 () |
FBody | getBody2 () |
float | getX () |
float | getY () |
float | getNormalX () |
float | getNormalY () |
float | getNormalImpulse () |
float | getTangentImpulse () |
FContactID | getId () |
Protected Member Functions | |
FContactResult (ContactResult contactResult) | |
Protected Attributes | |
Vec2 | m_position |
Vec2 | m_normal |
FBody | m_body1 |
FBody | m_body2 |
float | m_normalImpulse |
float | m_tangentImpulse |
FContactID | m_id |
Represents the result of the contact between two bodies. Objects of this type are not created by the users. Contact results are passed to the user when they implement the
method in the applet:
FWorld world;void setup() {world = new FWorld();world.setEdges();// Create and add bodies to the world here// ...}void draw() {world.step();world.draw();}void contactResult(FContactResult result) {// Draw an ellipse where the contact took place and as big as the normal impulse of the contact// Trigger your sound here// ...}
To know if the contact is the beggining, the continuation or the end of a contact it is better to use the other methods
,
and
.
Contacts
FBody FContactResult.getBody1 | ( | ) |
Returns the first body involved in the contact.
FBody FContactResult.getBody2 | ( | ) |
Returns the second body involved in the contact.
FContactID FContactResult.getId | ( | ) |
Get the identifier of the contact. This value is useful in order to uniquely identify a contact. A new contact ID is created whenever to bodies enter into contact at a given point. If the bodies slide against each other the contact ID is maintained even if the point of contact is modified due to the slide. As soon as the two bodies separate the contact is considered ended.
float FContactResult.getNormalImpulse | ( | ) |
Returns the normal component of the impulse of the contact. This gives an idea of the strength of the collision that took place. This represents the impulse necessary to avoid penetration of the bodies involved in the collision. The impluse is simply the force multiplied by the timestep. The result is returned in impulse units (kg * pixels / s).
float FContactResult.getNormalX | ( | ) |
Returns the horizontal component of the contact normal.
float FContactResult.getNormalY | ( | ) |
Returns the vertical component of the contact normal.
float FContactResult.getTangentImpulse | ( | ) |
Returns the tangential component of the impulse of the contact. This gives an idea of the strength of the friction between the bodies that took place. The impluse is simply the force multiplied by the timestep. The result is returned in impulse units (kg * pixels / s).
float FContactResult.getX | ( | ) |
Returns the horizontal position of the contact point.
float FContactResult.getY | ( | ) |
Returns the vertical position of the contact point.