Physics Based Animation

 

 Video

This program simulates collision of spheres within a cube and is based on Chris Hecker's game developer mag article. The coefficient for damping, the time step, and the ball data are read off a configuration file.

Pseudocode (see [1]) :

while(simulating) {
DeltaTime = CurrentTime - LastTime
while(LastTime < CurrentTime) {
calculate all forces and torques
compute linear and angular accelerationsintegrate accelerations and velocities over DeltaTimeif(objects are interpenetrating) {subdivide DeltaTime} else {if(objects are colliding) {resolve collisions using Eqs. 8 and 9}LastTime = LastTime + DeltaTimeDeltaTime = CurrentTime - LastTimeupdate positions and velocities}}draw objects in current positions

}

Issues: Sometimes (towards the end) balls get struck in the corners of walls- we do not back off and reduce  the timestep as we should ideally, thus if the ball has penetrated,it gets stuck to the corner of a wall. Angular  momentum conservation has not been implemented.

To start the simulation, press a.  To start the simulation and save it to a file, press f. 500 frames are rendered  and saved.

 

References:

[1] Chris Hecker in his game developer mag article.

[2] The Book Physics for Game Developers was also used.

   

 

 

Send feedback regarding this page to [email protected]
Last Modified: 11/10/2003
Hosted by www.Geocities.ws

1