15-462 Programming Lab 4: Physics Simulation

Due Tuesday, December 6th, 11:59 PM


Overview

In this assignment, you will be implementing a simple physics simulation. You will implement physically-correct motion of simple geometrical objects in an environment. For this, you will need to know how to handle physical object properties that cannot be directly observed, such as mass and momentum. Your code will be required to model sphere/plane and sphere/sphere collisions, but you can do more if you wish. As with the previous starter codes, the code you are provided with will extend the ray tracer starter code so that you will be able to combine any part(s) of the previous three labs if you wish.

Briefing of Tasks

Basic Physics

Rigid body movements rely on mainly on a few formulas

Force: F = ma

Momentum: p = mv

Conservation of Momentum: p1 = -p2 (remember that this is per-axis)

Implementation

Starter Code

The starter code [1] has been set up to be able to built in both Visual Studio 2005 and with the Makefile in Linux. As mentioned before, the starter code should be familiar to you from the previous projects, and so objects are loaded in the same way that they are in the ray tracer with modifications to load in other attributes such as mass and initial velocity.

A good starting point will be to understand how the various objects work in the normal renderer. The Scene loads a Gravity Vector and each SceneObject loads with a mass, initialVelocity, and initialTransform. The two parts you will need to update on the Scene will be the Matrix currentTransform and Vector currentVelocity in the SceneObject classes. The currentVelocity variable is there only as a placeholder for you to use to be able to update the objects' transformation matrix. As a side note, a mass of 0.0 or less should mean infinite-mass or one that is not affected by forces such as gravity.

The transformation matrices are ordered such that the member variables are accessed as _RowColumn. e.g. matrix._14 gives the element at row-1, column-4. There are a couple of additional functions that have been added in Utils.h for your convenience also: BuildTranslation, BuildRotationX, BuildRotationY, BuildRotationZ, BuildScale, and finally BuildTransform which combines all together.

Grading Criteria

Your program must:

Submission

Please submit your project to /afs/andrew/scs/cs/15-462/turnin/your_andrew_id/. Copy your modified src directory into that directory. When we run "make" in the src directory it should compile your program successfully. Also within asst4, make a sub-directory called scenes and images, and place your representative XML scene files and JPEG snapshots into the respectively sub-directory.

Tips

Extras

Here are some suggestions for extra credit ideas:

Other cool things will get extra credit as well (talk to the TAs before you actually implement it).

Please note that the amount of extra credit awarded will not exceed 10% of this assignment's total value.

Links

[1] Starter code