Skip to main content
GameDev.net gamedev.net
🔒 Locked

ODE collision problem

Started by indieboy Jul 13, 2004 at 3:49 PM 10 replies 3.5k views
Original Post
indieboy
indieboy
Hi, i am using ODE for physics and collision detection.. but i am not getting any luck with the later. I made a simple box dropping upon a static plane (no dBodyID, just dGeomID). but when it is almost touching it .. it deaccelerates, and passes by.. with some slow velocity towards infinity does anyone have had this problem before? any clues? thanks a lot =)
leandro.
ogracian
ogracian
Hello

Well about ODE I use it and some times that kind of collision trouble is not exactly a collision trouble but a collision response trouble, first make sure you are using same metrics in your data, I mean your vel in m/s, mass en kg, etc.

Also try to check if your collision detection routine (dCollide?) is working, I mean if it return a contact, then the trouble is as said above a collision response trouble.

Other thing that you could try is use dWorldQuickStep instead of dWorldStep.

Well hope this could help you,
Oscar
indieboy
indieboy
Thanks for the quick reply.. i am using dCollide and one weird thing is that it always returns true ... (even when the box is far far away from the plane =(

i think every step one contact joint is being created... aargh
is there any place with a good beginner tutorial about ODE?

its manual is very unfriendly and confusing.. i've been playing with it about two days and still can't throw a box on the floor hhaehehaehaeh =P

thanks a lot
leandro.
Squirm
Squirm
I found the ODE manual surprisingly helpful and well written :/

It sounds to me as though your box is hitting the surface and the collision response is insufficiently strong to prevent it passing through. Another favourite for things going through a plane is having the planes normal the wrong way up - in which case it will hit the "inside" of the plane and try to get out...

The best place to learn from is the examples - especially the one that lets you drop various shapes onto a plane - "box drop" or something I think it's called ;) I suggest comparing various parts of that code to your own and looking for differences. Especially the bit where the contact joint is added.
indieboy
indieboy
box_stack example? yeah.. i took parts of its code..

but one thing i am a bit confused.. what is the plane object for? i couldn't figure out.. in the box_stack example.. they create a plane object with this command:

dCreatePlane (space,0,0,1,0);

what does it mean? why one would create a plane if it is non-moveable..

i am using to boxes actually.. one regular one.. and a big one that acts as the floor. I made it static so it won't fall down too.. i will try to see this 'normal' thing.. the answer seems to be related to that.. thanks a lot..
leandro.
indieboy
indieboy
well i made several tests and this is what i've found out so far:

the box deaccelerates when it reaches the plane i had created with:
ground = dCreatePlane (spacePhy,0,1,0,-10);
i commented it and now the box falls with the ascending velocity as if there was nothing on the bottom

when the box reaches the floor i've made with other box.. the dCollide function returns true .. but it passes through anyway.. =(
leandro.
hplus0603
hplus0603
How big is your gravity? Time step? Mass?

You said you're using no dBody -- how then does the box move? Do you move it yourself? If so, you are also responsible for collision respose.

Do you create contact joints for the collision you get? Do you erase all contact joints after stepping?
enum Bool { True, False, FileNotFound };
indieboy
indieboy
Gravity: -9.81
Time step: 0.01
Mass density: 5.0


One box as a dBodyID and a dGeomID.. (the box that falls)
the other one hasn't .. only a dGeomID (the floor)

the dCollide function returns true when they collide and then i create the contact joint (just like the box_stack example does):
if (int numc = dCollide (o1,o2,4,&contact[0].geom,			   sizeof(dContact))) {    dMatrix3 RI;    dRSetIdentity (RI);    for (i=0; i<numc; i++) {      dJointID c = dJointCreateContact (worldPhy,contactgroupPhy,contact+i);      dJointAttach (c,b1,b2);          }  }

and in the draw loop.. i call, in this order:
if(!paused)    {         dSpaceCollide (spacePhy,this,&nearCallback);                    dWorldStep (worldPhy, 0.01);               dJointGroupEmpty (contactgroupPhy);    }    
leandro.
teamonkey
teamonkey
Which step routine are you using (WorldStep, Quickstep, Faststep)?

Try fiddling with the CFM values (explanation in the manual).
[teamonkey] [blog] [tinyminions]
indieboy
indieboy
ok.. i think i solved the problem.. the CFM was activated and because the floor was soh thin (1.0 unit).. the box was trespassing it =)

but now i can't make the box rotate properly.. is this code correct?
const dReal *b = dGeomGetRotation (current->PHYgeom[0]);
glRotatef(b[0],1.0f,0,0);
glRotatef(b[1],0,1.0f,0);
glRotatef(b[2],0,0,1.0f);

the box falls without rotating.. but if i multiply it by 100..

const dReal *b = dGeomGetRotation (current->PHYgeom[0]);
glRotatef(b[0]*100,1.0f,0,0);
glRotatef(b[1]*100,0,1.0f,0);
glRotatef(b[2]*100,0,0,1.0f);

it spins a lot hehe ... so what am i doing wrong?
leandro.
Squirm
Squirm
Most computer stuff works in radians. OpenGL, for reasons best known to its creators, works in degrees. I assume you know, but 360 degrees = 2*PI radians :o)
indieboy
indieboy
oh of course i knew that . .eheheh =P

thank you! it now works perfectly =)
leandro.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.