description
Objective: The main point of this project was create a gravitational orbit simulation. Objects would be created in space with a mass, radius, initial velocity, and rotation. These Objects would interact with eachother and enact gravitational force upon and collide with eachother.
Interaction: Users are able to interact in this program both with viewing and manipulation. Users can move the eye position to view the objects from different angles and zoom in and out. In addition, they can interact with the objects by picking an object to modifying it's velocity, and click and dragging objects to change its position.
features
The forces acting upon an object are calculated by iterating across all the objects and calculating the gravity each object will act upon the current object.
a = GMm/r^2
- Collision detectionObject's relative distance to eachother is checked after changing its position based on velocity. If the distance between two objects is less than the sum of its two radii, then it flags the objects as collided.
- Ellastic collisionsOnce two objects are flagged as collided, their new velocities are calculated while conserving kinetic energy and momentum of the two objects.
v1 = ( u1(m1-m2) + 2(m2u2) )/( m1+m2 )
v2 = ( u2(m2-m1) + 2(m1u1) )/( m1+m2 )
- Proportional rotational movement and zoomingMovement around the center and zooming in/out is scaled to the view vector
- Texture MappingObjects are texture mapped to planet textures
- Time ManipulationTime can be multipled by 2 from 1x and up
- 3D PickingUsers can select objects in perspective mode and the closest object is picked
- Dynamic skybox and viewspaceThe skybox and viewspace is scaled depending on the distance of the eye
instructions
To use this you...
Keyboard
d : toggles the display of FPS and each object's velocity vector, mass, velocity and radius
m : toggles the mouse mode look/interact
arrow keys : with an object selected in look mode, modify the object's velocity
+/- : speed up/down
p : pause
q : quit
Modes
look - Users can click and drag with the left mouse button to rotate, and left mouse button to zoom in and out. They can also select objects to view their information and modify its velocity with the arrow keys
interact - Users can click and drag objects with the left mouse button to change its position
resources
elastic collisions - wikipedia: elastic collision
bitmap characters - O'Reilly: OpenGL Rendering and Drawing