Game Development Reference
In-Depth Information
Figure 8-5. Particle-to-ground collision
To prevent such penetration of the ground plane, we need to do two things. First, we
must reposition the particle so that it is just touching the ground plane, as shown on
the right side of Figure 8-5 . Second, we must apply some impact force resulting from
the collision in order to force the particle to either stop moving down into the ground
plane or to move away from the ground plane. All these steps make up collision detection
and response.
There are several changes and additions that we must make to the example code in order
to implement particle-to-ground collision detection and response. Let's begin with the
Particle class.
We've added three new properties to Particle , as follows:
class Particle {
.
.
.
Vector vPreviousPosition;
Vector vImpactForces;
bool bCollision;
.
.
.
};
vPreviousPosition is used to store the particle's position at the previous time step—
that is, at time t-dt . vImpactForces is used to aggregate all of the impact forces acting
 
Search Nedrilad ::




Custom Search