Game Development Reference
In-Depth Information
Vector vCollisionTangent;
} Collision, *pCollision;
The first two properties are indices to the two bodies involved in the collision. The next
property, vCollisionNormal , stores the normal vector at the point of contact of the
collision with the vector pointing outward from body2 . The next property, vCollision
Point , stores the coordinates of the point of contact in global coordinates. Since we're
dealing with spheres (billiard balls), the collision manifold will always consist of a single
point for each ball-ball or ball-table collision. The next two properties store the relative
velocity and acceleration between the two bodies at the point of collision. The data is
stored in vRelativeVelocity and vRelativeAcceleration , respectively. To capture
friction at the point of contact, we need to know the tangent vector to the bodies at the
point of contact. This tangent is stored in vCollisionTangent .
We set up several global define s to hold key data, allowing us to easily tune the simu‐
lation:
#define BALLDIAMETER 0.05715f
#define BALLWEIGHT 1.612f
#define GRAVITY −9.87f
#define LINEARDRAGCOEFFICIENT 0.5f
#define ANGULARDRAGCOEFFICIENT 0.05f
#define FRICTIONFACTOR 0.5f
#define COEFFICIENTOFRESTITUTION 0.8f
#define COEFFICIENTOFRESTITUTIONGROUND 0.1f
#define FRICTIONCOEFFICIENTBALLS 0.1f
#define FRICTIONCOEFFICIENTGROUND 0.1f
#define ROLLINGRESISTANCECOEFFICIENT 0.025f
The first three define s represent the billiard ball diameter in meters, the ball weight in
newtons, and the acceleration due to gravity in m/s 2 . The ball diameter and weight are
typical values for American-style billiard balls (i.e., 2.25 inches and 5.8 oz on average).
The remaining defines are self-explanatory and represent nondimensional coefficients
such as drag coefficients and coefficients of restitution. The values you see are what we
came up with after tuning the simulation. You'll surely tune these yourself if you develop