3D Spring Physics Simulator

Physics Simulator
CMPS 160 Final Project - Spring 2001, UCSC
Dennis Bostrom

This program simulates the physics of masses and springs and the forces that act upon them and displays the results in a 3D window with user selectable camera angles.

Features

Masses are represented either as spheres or octahedrons. In sphere mode the masses are shaded, in "poly" mode the the octahedrons are scaled to according to the magnitude of the mass. The user is able to interact with mass and spring objects either by keyboard or mouse. Spring and mass models can be loaded from the file menu which resets the scene. New models can also be inserted into the current scene. Several different camera angles are available.

Technical

This project is based on Xspringies, the mass and spring simulator for the X window system, written by Douglas DeCarlo. Here are some details provided by the documentation: The physics engine of Xspringies consist of a fourth order Runge-Kutta (RK4) differential equation solver. A spring has three parameters associated with it. Kspring, Kdamp and rest length. The spring force is calculated as follows (according to Hooke's law): F = - Kspring * (length - rest length) - Kdamp * (velocity in spring direction) The calculations of forces on the springs and masses are actually performed in two dimensions it is the rendering that gives them a 3D appearance. All animation is done in realtime.

Summary of Controls


GUI Controls

The Time slider adjusts the time slice of the simulation. A smaller slice makes the simulation slower

The Grav slider adjusts the force of gravity.

The Direc slider adjusts the direction of gravity.

The rotate translate and scale sliders will move and distort the objects but using them is not recommended since they make the camera movement less accurate.


Keyboard Controls

The s key starts and stops the animation.

The t speeds up animation (at expense of smoothness).

The esc key deletes all objects.

The d key puts the camera into fixed position mode (camera stays in one place and looks at selected mass but can be relocated by the user)

The f key puts the camera into fixed follow mode (camera stays in one position relative to selected mass but can be relocated by the user)

The v key puts the camera into rotating follow mode (camera rotates relative to selected mass but can be moved by mouse or set to rotate constantly with b key)

The b key sets constant rotation

The g key toggles gravity.

The h key zooms in on object.

The n key zooms out on object.

The k key moves the camera in the positive X direction.

The , key moves the camera in the negative X direction.

The l key moves the camera in the positive Y direction.

The . key moves the camera in the negative Y direction.

The ; key moves the camera in the positive Z direction.

The / key moves the camera in the negative Z direction.

The ' key deletes the floor.

The [ key deletes the left wall.

The ] key deletes the right wall.

The 6 keypad applies force to object in the positive X direction.

The 4 keypad applies force object in the negative X direction.

The 8 keypad applies force to object in the positive Y direction.

The 2 keypad applies force object in the negative Y direction.

The 5 keypad toggles between putting force on a selected mass or on all masses.

The pg up key selects the next mass.

The pg dn key selects the previous mass.

The ins key selects the fifth next mass.

The del key selects the fifth previous mass.


Mouse Controls

Left mouse drag will rotate the camera around the selected mass if in rotate mode.

Right mouse drag will apply a force to a selected mass if in One Object Move mode or all objects if in All Objects Move mode.


Last modified: Thu May 24 23:37:01 PDT 2001