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 | getVelocityX () |
float | getVelocityY () |
float | getNormalX () |
float | getNormalY () |
float | getSeparation () |
float | getFriction () |
float | getRestitution () |
FContactID | getId () |
boolean | contains (String n1, String n2) |
boolean | contains (FBody n1, FBody n2) |
boolean | contains (String n1) |
boolean | contains (FBody n1) |
Protected Member Functions | |
FContact (ContactPoint contactPoint) | |
Protected Attributes | |
FBody | m_body1 |
FBody | m_body2 |
Vec2 | m_position |
Vec2 | m_velocity |
Vec2 | m_normal |
float | m_separation |
float | m_friction |
float | m_restitution |
FContactID | m_id |
Represents a contact between two bodies. Objects of this type are not created by the users. Contacts are passed to the user when they implement the
,
and
methods 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 contactStarted(FContact contact) {// Draw in green an ellipse where the contact took placefill(0, 170, 0);}void contactPersisted(FContact contact) {// Draw in blue an ellipse where the contact took placefill(0, 0, 170);}void contactStarted(FContact contact) {// Draw in red an ellipse where the contact took placefill(170, 0, 0);ellipse(contact.getX(), result.getY(), 20, 20);}
To know if the contact is the beggining, the continuation or the end of a contact it is better to use the other method
.
Contacts
boolean FContact.contains | ( | String | n1, |
String | n2 | ||
) |
Returns true if the contact contains the two bodies. If one of the bodies does not have a name this function returns false.
n1 | the name of one of the bodies |
n2 | the name of another one of the bodies |
Returns true if the contact contains the two bodies.
n1 | one of the bodies |
n2 | another one of the bodies |
boolean FContact.contains | ( | String | n1 | ) |
Returns true if the contact contains the body.
boolean FContact.contains | ( | FBody | n1 | ) |
Returns true if the contact contains the body.
FBody FContact.getBody1 | ( | ) |
Returns the first body involved in the contact.
FBody FContact.getBody2 | ( | ) |
Returns the second body involved in the contact.
float FContact.getFriction | ( | ) |
Get the friction coefficient of the contact. The friction determines the ratio of the reaction force tangent to a contact that the two bodies will recieve. Basically it can be seen as a coefficient that will control how the bodies get slown down when they slide against each other. This value depends on the friction coefficients of the two bodies involved in the contact.
FContactID FContact.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 FContact.getNormalX | ( | ) |
Returns the horizontal component of the contact normal.
float FContact.getNormalY | ( | ) |
Returns the vertical component of the contact normal.
float FContact.getRestitution | ( | ) |
Get the restitution coefficient of the contact. The restitution determines the ratio of the reaction force normal to a contact that the two bodies will recieve. Basically it can be seen as a coefficient that will control the strength with which the bodies bounce back from the collision. This value depends on the resititution coefficients of the two bodies involved in the contact.
float FContact.getSeparation | ( | ) |
Get the separation between the bodies.
float FContact.getVelocityX | ( | ) |
Returns the horizontal component of the contact velocity.
float FContact.getVelocityY | ( | ) |
Returns the vertical component of the contact velocity.
float FContact.getX | ( | ) |
Returns the horizontal position of the contact point.
float FContact.getY | ( | ) |
Returns the vertical position of the contact point.