I'm trying to get a basic OBB/OBB Collision System working. For this I use ODE.

My problem is: Whenever I use the dSpaceCollide and pass in my Space and my Callback, my Callback shows me, that a collision happened. But the contact-point is far away (or even in X/Y/Z-(Near-)Infinite) from my OBB's.

Here a pic:

enter image description here

I did this:

  • In the Constructor: Box with dCreateBox
  • Every frame: Position with dGeomSetPosition and
  • Rotation with dGeomSetRotation
  • Also every frame: Check per dSpaceCollide

What could I've missed? Thanks in advance!

PS: I'm using DirectX9!


My Collision-Code:

In my Game-Loop:

dSpaceCollide(space, 0, &nearCallback); // space is my dSpaceID

My NearCallback:

static void nearCallback(void *data, dGeomID o1, dGeomID o2)


dContact contact;

contact.surface.mode = dContactBounce | dContactSoftCFM;
contact.surface.mu = dInfinity;
contact.surface.mu2 = 0;
contact.surface.bounce = 0.01;
contact.surface.bounce_vel = 0.1;
contact.surface.soft_cfm = 0.01;

if (int numc = dCollide(o1, o2, 1, &contact.geom, sizeof(dContact)))
    // DrawTextOnScreen is a function to Draw things on my Screen (obviously)
    DrawTextOnScreen("Collision", D3DCOLOR_XRGB(0, 255, 0), 2, 200, 270, 20);
    DrawTextOnScreen(std::to_string(numc).c_str(), D3DCOLOR_XRGB(0, 0, 0), 2, 220, 270, 20);
    // etc...

    DrawTextOnScreen("No Collision", D3DCOLOR_XRGB(255, 0, 0), 2, 200, 270, 20);


After some trying I got to a point where the Collision not not works. :-P

I changed it this way:

The Rotation is made by Quaternions instead of Matrices. And I update the Box-Length every Frame.

Now it showes me, that there is no collision when there is no collision. (Fine) The problem is, that when there is a collision, it doesn't show it to me:

enter image description here

But (!) when I Spawn myself at the exact same position of the "Enemy", it detects a collision. I can rotate around the X-Axis and the Point where the collision occurs changes. The collision-point is in a weird Position.

enter image description here

The Box in ODE is declared with the same dimensions as I declared for the Box, which is rendered!


I just want to show you how I define my Space!

// Initialization
dSpaceID space;
space = dSimpleSpaceCreate(space);

// In the Loop  
dSpaceCollide(space, 0, &nearCallback);

I really hope, that you can help! And apologise my english, it's kind of shitty! :-)

EDIT-4 After a week of so doing other stuff, I looked back on the problem and found the issue: In the beginning you have to declare


instead of



Makes me a little bit sad :-( Somthing boring as an error... :-)

  • \$\begingroup\$ Could you post your actual collision code? Spaces are axis aligned and are used for quick rejection tests, you must then perform the actual collision tests to find the collisions. The documentation is quite good over that subject. \$\endgroup\$ – Vaillancourt Apr 23 '16 at 18:02
  • \$\begingroup\$ Are you sure the box that represents the geom is at the same place that it is visually? \$\endgroup\$ – Vaillancourt Apr 25 '16 at 22:20
  • \$\begingroup\$ I think, every frame I set the position to exact the same position where my character is! \$\endgroup\$ – Anonymous Anonymous Apr 26 '16 at 4:38
  • \$\begingroup\$ I first set the Render-Position with 'D3DXMatrixTranslate(&rotMat, coordinate.x, coordinate.y coordinate.z)' and the the collision-box with 'dGeomSetPosition(obb, coordinate.x, coordinate.y, coordinate.z)'. When the collision works I will reverse this, but for now... \$\endgroup\$ – Anonymous Anonymous Apr 26 '16 at 14:55
  • \$\begingroup\$ And you have only one space? \$\endgroup\$ – Vaillancourt Apr 26 '16 at 14:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.