Here's the code for those interested (very ugly, tried to make it fast without any particular object-orientation as I am learning ODE).
I have marked the lines that causes warnings and errors.
#include <windows.h>#include "gl/gl.h"#include "glut.h"#include "ode/ode.h"// SimpleObject structure.struct SimpleObject{ dBodyID body; dGeomID geom;};// Globals.float GeomMatrix[12]; // Our geometry matrix.SimpleObject object; // Our simple object.dWorldID world; // Our world.dSpaceID space; // Our space.dJointGroupID contactgroup; // Our contact group.// Prototypes.void InitOde(void);void CloseOde(void);void SimLoop(void);void nearCallback(void *data, dGeomID o1, dGeomID o2);void DrawGeom(dGeomID g, const dReal *pos, const dReal *R, int show_aabb);void DrawBox(dReal sides[3], const dReal *pos, const dReal *R);void Display(void);void main(int argc, char **argv){ glutInit(&argc, argv); glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA); glutInitWindowPosition(100, 100); glutInitWindowSize(320, 320); glutCreateWindow("Open Dynamics Engine Test"); InitOde(); glPointSize(5.0f); glutDisplayFunc(Display); glutMainLoop();}void Display(void){ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); SimLoop(); glFlush();}void InitOde(void){ // World settings. world = dWorldCreate(); // Create world. space = dSimpleSpaceCreate(0); // Create space. contactgroup = dJointGroupCreate(0); // Create contact joint group. dCreatePlane(space, 0, 1, 0, 0); // Create a simple plane. dWorldSetGravity(world, 0, -1, 0); // Setup gravity. dWorldSetERP(world, 0.2); // Setup Error Reduction Parameter. dWorldSetCFM(world, 1e-5); // Setup Constraint Force Mixing. dWorldSetContactMaxCorrectingVel(world, 0.9); // Set max velocity for when joints are broken. dWorldSetContactSurfaceLayer(world, 0.001); // Set depth of surface collision between objects. dWorldSetAutoDisableFlag(world, 1); // Enable auto-disable of resting objects. // Body settings. // Create new body for object and attach to world. object.body = dBodyCreate(world); // Set position of body. dBodySetPosition(object.body, 0, 10, -5); // Set initial linear velocity of object. dReal tempVect[3] = {0.0, 0.0, 0.0}; dBodySetLinearVel(object.body, tempVect[0], tempVect[1], tempVect[2]); // Set a random rotation angle for the object. dMatrix3 R; dRFromAxisAndAngle(R, dRandReal() * 2.0 - 1.0, dRandReal() * 2.0 - 1.0, dRandReal() * 2.0 - 1.0, dRandReal() * 10.0 - 5.0); dBodySetRotation(object.body, R); // Set user data to something insignificant. size_t i = 0; dBodySetData(object.body, (void*)i); // Geometry settings. dReal sides[3]; sides[0] = 2.0; sides[1] = 2.0; sides[2] = 2.0; // Create a box geometry for the object. object.geom = dCreateBox(space, sides[0], sides[1], sides[2]); // Associate geometry with body. dGeomSetBody(object.geom, object.body); // Set the mass of the body. dMass m; dMassSetBox(&m, 0.5, sides[0], sides[1], sides[2]); // <-- CAUSES A WARNING: says Mass must be > 0. dBodySetMass(object.body, &m); // <-- CAUSES A WARNING: says something about inertia.}void CloseOde(void){ // Destroy joint group. dJointGroupDestroy(contactgroup); // Destroy collision space. dSpaceDestroy(space); // Destroy world!!! MUAHAHAHAHHA!! dWorldDestroy(world);}void SimLoop(void){ // Perform per-frame updates of the physics simulation and calculate collisions. // Determine what geometries in the space may be potentially intersecting. dSpaceCollide(space, 0, &nearCallback); // Pass this on to nearCallback(). // Advance the simulation with a faster, less accurate stepping function. dWorldQuickStep(world, 0.05); // CAUSES AN ERROR AND CRASH: says stepsize must be > 0. // Remove all temporary collision joints. dJointGroupEmpty(contactgroup); // Draw geometry. DrawGeom(object.geom, 0, 0, 0);}#define MAX_CONTACTS 6static void nearCallback(void *data, dGeomID o1, dGeomID o2){ int i; // Get bodies for both objects. dBodyID b1 = dGeomGetBody(o1); dBodyID b2 = dGeomGetBody(o2); // Create an array of contact joints. dContact contact[MAX_CONTACTS]; // Go through all contact joints and set their properties. for (i = 0; i < MAX_CONTACTS; i++) { contact.surface.mode = dContactBounce | dContactSoftCFM; // Set bounce and soft contraints (soft material). contact.surface.mu = dInfinity; // Set friction. contact.surface.mu2 = 0; // Set additional friction. contact.surface.bounce = 0.01; // Set bounciness. contact.surface.bounce_vel = 0.1; // Set bounce velocity. contact.surface.soft_cfm = 0.01; // Set soft constraint value. } // Perform collision test. if (int numcollisions = dCollide(o1, o2, MAX_CONTACTS, &contact[0].geom, sizeof(dContact))) { // Add each contact point. for (i = 0; i < numcollisions; i++) { dJointID c = dJointCreateContact(world, contactgroup, contact + i); dJointAttach(c, b1, b2); // Attach joints. } }}void DrawGeom(dGeomID g, const dReal *pos, const dReal *R, int show_aabb){ if (!g) return; if (!pos) pos = dGeomGetPosition(g); if (!R) R = dGeomGetRotation(g); int type = dGeomGetClass(g); if (type == dBoxClass) { dReal sides[3]; dGeomBoxGetLengths(g, sides); DrawBox(sides, pos, R); }}void DrawBox(dReal sides[3], const dReal *pos, const dReal *R){ glPushMatrix(); glBegin(GL_POINTS); glTranslatef(pos[0], pos[1], pos[2]); glEnd(); glPopMatrix();}