• The previous version of the gravitational simulation produced rather abstract results. The lists of coordinates did not say much and the import for 3DsMax was not very handy.

    To overcome this problem I looked into openGL and found it quite easy to integrate.
    The glut-Package for DevC++ includes all necessary files and an example project.

    The whole initzalizing stuff was just copied from the example and the code from the earlier version adapted to produce the coordinates in the corrent form.

    All the objects are stored in a linked list. For each frame the list is traversed and the new coordinates displayed.

    Gravitational Simulation 3D

    Gravitational Simulation 3D

    I also added a linked list to each object that stores all past coordinates. When this list ist used to plot lines between each two adjacent points the trace of the object is displayed. Currently only the trace of 2 selected objects can be displayed at a time. Those two objects also get marked with little triangles and a 3d-crosshair. Their parameters are displayed in the upper left edge of the screen, along with some additional info. To visualize the forces, accelerations and velocities the corresponding vectors can be displayed.

    Velocity- and forcevectors displayed

    Velocity- and forcevectors displayed

    Code can be downloaded here (Executable included).

    Rotating the view is done by holding a mousbutton down and moving the cursor.

    Other commands:
    i    Toggle  Info
    x   Calculate Step
    z   Reset viewcenter to [0,0,0]
    o   Center blue object
    k   Center yellow object
    t   Toggle trace
    p  Select blue object
    L    Select yellow object

    f    Toggle force vectors
    b   Toggle acceleration vectors
    v   Toggle velocity and force vectors

    +-  Increase / decrease step size

    n   Reset world and generate 50 new objects randomly

    */  Increase / decrease gravitational constant

    5 and 0  zoom in and out

    Numblock to move viewcenter

    Tags: , , ,