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
FContactResult Class Reference

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
 

Detailed Description

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

contactResult(FContactResult){ }

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
ellipse(result.getX(), result.getY(), result.getNormalImpulse(), result.getNormalImpulse());
// 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

contactStarted(FContact){ }

,

contactPersisted(FContact){ }

and

contactEnded(FContact){ }

.

Contacts

See also
FContact

Member Function Documentation

◆ getBody1()

FBody FContactResult.getBody1 ( )

Returns the first body involved in the contact.

Returns
first of the bodies involved in the contact

◆ getBody2()

FBody FContactResult.getBody2 ( )

Returns the second body involved in the contact.

Returns
second of the bodies involved in the contact

◆ getId()

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.

Returns
a unique identifier representing the contact

◆ getNormalImpulse()

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).

Returns
the normal component of the contact's impulse
See also
getTangentImpulse

◆ getNormalX()

float FContactResult.getNormalX ( )

Returns the horizontal component of the contact normal.

Returns
the horizontal component of the contact normal
See also
getNormalY

◆ getNormalY()

float FContactResult.getNormalY ( )

Returns the vertical component of the contact normal.

Returns
the vertical component of the contact normal
See also
getNormalX

◆ getTangentImpulse()

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).

Returns
the tangent component of the contact's impulse
See also
getNormalImpulse

◆ getX()

float FContactResult.getX ( )

Returns the horizontal position of the contact point.

Returns
the horizontal position of the contact point in simulation world units
See also
getY

◆ getY()

float FContactResult.getY ( )

Returns the vertical position of the contact point.

Returns
the vertical position of the contact point in simulation world units
See also
getX

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