Project 1 for CS4496, instructor Jarek Rossignac

Welcome to the Project 1 turn in page for Matthias Grundmann and Amro Mousa.

Team Information (Names, Pictures, Emails):

Project Purpose:

The purpose of Project 1 is to use all of the knowledge from the previous projects to form a simple accident simulation software. The software makes use of keyframing and other techniques to animate vehicles in either 2D or 3D, depending on user preference.

Usage Instructions:

Note: Because we respect all Mac-Users, everytime when we are talking about the right-mouse button, you can achieve the same result with your one mouse-button and simultanousely pressing CTRL.

Creating new Car curves

To create a new car simply click on the "Create new car" button. Toggle the "Adjust Car" button and drag the car around when you select the number. Press 's' to create a new keyframe. You can adjust the little tangent handle to control the tangents of the curve. If you want to hide the cars press 'c' at any time.
Alternativly you can create a new curve. Select the "Create curve" button and click and drag the control points. In this mode when you drag with the right mouse button you can adjust the tangent of the last control point. Windows users can also press a key while draging and adjust the length of tangent. When you like the result press ENTER and it will be saved, BACKSPACE to discard.
When you toggle "Adjust Curve", you can drag all the curve points and adjust their tangents. Using the right mouse-button just change the magnitude but not the direction of a tangent.
Please note, that adjusting the curve will not change the keyframe positions of the cars, on the other hand, changing the keyframe position always reset the path back. So adjusting is a fine-tuning step.
When you are done save your work with 'w', load it with 'l'.

Adding velocity

In the bottom window you see a curve with horizontal axis representing time, the vertical the relative postion of the curve with respect to arc length. Simply select a curve in any mode (create or adjust) and the corresponding curve will be displayed. To switch to a bigger view and back press 'e'.
With the left mouse button you can adjust the time value of a control point, the right mouse-button changes the positonon the curve. While draging a car will be shown, that shows the exact position.

Animation

Press 'g' to start animation, and adjust the speed with '+' and '-'. Pause every time you want with SPACE and stop animation by pressing 'g' once more. Animation is online available when all adjust buttons are off.
With 't' you turn off and on the collision detection and reaction. When you press 'd' you can detach the cars from the curve and let them animate with current velocity and angular velocity. This is just a testing feature and looks nice.
For convenience when you press 'G' the curvature driven animation is shown. However this does not work with collision detection.

3D view

The 3D view is only implemented in this applet, cause openGL in applet mode might not work for all people.
Press '3' to switch to 3D mode and see the cars moving. When the rendering is too slow on your computer press 'b' to display only boxes instead of the car model. Change the view by moving the mouse.
When you have a car selected in 2D view, i.e. you see the corresponding time-distance curve at the bottom, pressing 'f' in 3D mode will switch to first person perspective and back

Project 1 Applet:

To view this content, you need to install Java from java.com

Source code: P1dnoGL IO bezier button car collision crashanim distance gaussianquad geo2D newton resample uniform

Keyboard shortcuts

In Create Curve mode:
ENTER to accept curve
BACKSPACE to delete curve
In Create Car Mode:
's' to insert new keframe
When nothing is selected:
'g' to start animation
SPACE to pause animation
'+' to increase animation speed
'-' to decrease animation speed
'c' to show keyframe position on/off
't' to toggle collision detection and reaction on/off
'd' to detach cars from curve (they will drift away)
'e' to make the time-distance curve bigger/smaller
'3' to switch to 3D mode
In 3D mode
'f' to switch to first person (note: car must be selected!)
'b' to display boxes instead of cars

Implementation details

Curves and motion

We used piecewise Bezier-Curves with an additional G1 constraint. Drawing is done by Processing. The curve is reparametrized w.r.t. arc length, which is obtained by adaptive Gaussian integration. Between two intervals of the integration, solving for the zero crossing of the objective by Newton-Raphson iterations is done. This results in smoother behavior compared to our earlier approaches, where we used only linear interpolation, especially when you model straight Bezier-Curves with a huge different tangents.
For the curvature driven velocity we used the exact formula.
The Bezier-curves can be sampled at any time, the tangent and position is calculated by the deCasteljau-algorithm.
To determine the position of the car at a specific time, the s-t bezier curve is evaluated via a bisection algorithm at the given time t, and the position s is obtained. One can follow this process by examining the mangenta cross moving over the curve.

Collision detection and reaction

The collision detection is actually a collision prediction. The moment of collision is determined via a binary search, so it is independent from the current animation velocity. After collision the specific cars are detached from their curves and animated by their current speed and rotation.
For detection, the cars are modelled as convex polygons. Collision occurs when there exits no line strictly sperating two convex cars. This can be tested very fast, cause when there exits a seperating line, it must be one the cars edges.
The actual collision point is calculated via edge intersection, adapted from Geometric tools for Computer Graphics. The calculation is stable and can also deal with edge-edge intersection. The collision reaction is implemented by the appraoch ByounMoon. We also tried out the one from the Parent book, but despite the fact that the formulas contain some mistakes, it uses the normal of the collision plane, which is hard to determine correctly, specifically when two point meet.
After collision a permanent force against the current velocity is applied to simulate friction.

3D view

We have written an obj-file importer and display the scene in 3D via usual openGL commands. Note that the rendering of the car model is pretty slow, cause it was not possible to call glGenLists command from processing, so all vertex have to be specified every frame. This is very slow of course.