Video Game Programming
Lab 5 : Collision Detection

 Abstract: In any decent game, there are hundreds of objects that move (enemies, obstacles, the player, etc). What we are going to do in this lab is come up with a class that all these objects can derive from -> Any basic object has a few common properties. Mass, velocity, acceleration, position and orientation. We need to come up with a class encapsulating all these basic properties (you can thank me for the physics readings later [;)] ). It is not required that you perform all your movement according to the laws of physics, but you are going to find out that learning the physics required is much easier than coming up with your own formulas.

 Topics Covered : A class for movable objects Implementing realistic motion in 3 dimensions Geometric principles in collision detection Collision Response Physics Collision Detection Collision between a sphere and a plane

 Assignment: Your assignment is to come up with a class that encapsulates the above mentioned properties. You will need to instantiate this class in the form of a simple sphere. The initial motion of the sphere should be upward. After an amount of time it should slow down, stop and come back down (gravity). On its downward path, cause it to collide with a plane (N = <1,5,0> passing through the origin). The ball should then come to a stop. Remember, in order to display the plane on screen, you will need to rotate a cube so that it represents a plane with the normal defined above. Extra credit:Implement realistic physics using the principle of reflection -> when the ball collides with the plane, make it rebound with the appropriate velocity. Remember, the angle of reflection equals the angle of incidence. In this case, we can find out the angle of incidence using the old velocity vector and the plane normal. We then need to construct the new velocity using the principle of reflection. The angle of reflection is the angle between the plane normal and the new velocity. You are required to come up with your own vector class to perform all the operations required.

 Prequisites: Completion of Lab 4 A basic understanding of college level physics and geometry including: Vector math (multiplication, cross and dot product) Matrix Math (matrix / scalar multiplication) A basic knowledge of computer graphics including: Coordinate Systems (Right and Left Handed) Affine Transformations (Translations, Rotations, Scaling) Object to World Transformations Projections The View Matrix World to View Transforms

 Readings: Any college level physics textbook (Force, mass, acceleration) Foley, Van Dam, Feiner, Hughes, Computer Graphics, 2002, Second Edition in C Pgs 1-283 Collision Detection Presentation Click Here