Game Development Reference
In-Depth Information
* Holds the normal restitution coefficient at the contact.
*/
real restitution;
/**
* Holds the direction of the contact in world coordinates.
*/
Vector3 contactNormal;
};
The structure holds a pointer to each object involved in the collision; a vector
representing the contact normal, from the first object's perspective; and a data mem-
ber for the coefficient of restitution for the contact. If we are dealing with a collision
between an object and the scenery (i.e., there is only one object involved), then the
pointer for the second object will be NULL .
To resolve one contact we implement the collision equations from earlier in the
section to give
Excerpt from include/cyclone/pcontacts.h
class ParticleContact
{
// ... Other ParticleContact code as before ...
protected:
/**
* Resolves this contact, for both velocity and interpenetration.
*/
void resolve(real duration);
/**
* Calculates the separating velocity at this contact.
*/
real calculateSeparatingVelocity() const;
private:
/**
* Handles the impulse calculations for this collision.
*/
void resolveVelocity(real duration);
};
Excerpt from src/pcontacts.cpp
#include <cyclone/pcontacts.h>
void ParticleContact::resolve(real duration)
Search Nedrilad ::




Custom Search