' test of: cube,box,sphere,cylinder and capsule

#include once "InitGL.bi"
#define USEDEBUG ' "optional" enable debug rendering and report in file "debug.txt"
#include once "TrueAxis.bi"

InitGL()
PhysicsCreateInstance()

' create a static ground plane
PhysicsAddStaticGround()

' create sone dynamic objects

' create a dynamic cube
dim as DynamicObject ptr cube = DynamicObjectCreateNew()
DynamicObjectInitialiseAsACube(cube,0,0,0, 2)
DynamicObjectSetPosition(cube,0,20,0)
DynamicObjectSetRotationD(cube,15,20,30)

' create a dynamic box
dim as DynamicObject ptr box = DynamicObjectCreateNew()
DynamicObjectInitialiseAsABox(box,0,0,0, 8,0.2,10)
DynamicObjectSetPosition(box,0,25,0)

' create a dynamic sphere
dim as DynamicObject ptr sphere = DynamicObjectCreateNew()
DynamicObjectInitialiseAsASphere(sphere,-2,0,0, 1)
DynamicObjectSetPosition(sphere,0,30,0)

' create a dynamic cylinder
dim as DynamicObject ptr cylinder = DynamicObjectCreateNew()
DynamicObjectInitialiseAsACylinder(cylinder, 0,-1,0, 0,1,0, 1)
DynamicObjectSetPosition(cylinder,0,35,0)

' create a dynamic capsule
dim as DynamicObject ptr capsule = DynamicObjectCreateNew()
DynamicObjectInitialiseAsACapsule(capsule, 0,-1,0, 0,1,0, 1)
DynamicObjectSetPosition(capsule,0,40,0)

' add the objects to the simulation 
PhysicsAddDynamicObject cube
PhysicsAddDynamicObject box
PhysicsAddDynamicObject sphere
PhysicsAddDynamicObject cylinder
PhysicsAddDynamicObject capsule

' render and simualtion loop
dim as integer frames
while inkey=""
  ' one step in simulation
  PhysicsUpdate(1.0/75.0)
  if frames mod 3=0 then
    glClear GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT
    glLoadIdentity
    glTranslatef 0,-5,-25
    ' draw all objects (only in debug mode) 
    PhysicsRender()
    flip 
  end if
  Sleep(10)
  frames+=1
wend

