Simulation and Event Modeling For Game Development (Thomson Course Technology) and ODE Ground Plane not stopping objects from falling through

8 views
Skip to first unread message

rsreynolds

unread,
Nov 2, 2009, 10:33:41 PM11/2/09
to ode-users
I purchased this book to get my feet wet with basic sim/modeling. It
uses Visual Studio C++ (2008), DirectX9, and ODE. I've ran into small
problems, such as dInitODE() not being called in in the sample code
and have managed to figure out most things I've encountered so far.

I'm stuck on a Ground Plane that seems to be detecting collisions from
objects falling on it, but the objects just keep on trucking right
through it as if it wasn't there. I've poked around in the ODE doc and
tried a few changes and changed Ground Plane parameters to match those
in some of the ODE 'demos' with no joy.

The book was put out in 2005 so I'm guessing that it was using an
earlier version of ODE and I'm hoping there is a parameter I've missed
that the 0.11.1 version may require that I haven't picked up on yet.

I'd appreciate any ideas or a push in the right direction. I can
include source files if needed, but I was hoping that this particular
book title may have had other folks looking for similar answers. I
poked oround in this oup and a few other places trying some of the
things that seemed to help folks with similar problems (stuff falling
though ground instead of bouncing off) but so far nothing has worked
for me. I've been screwing with it long enough that I'm sure I can't
see the cows for the trees (or something like that).

I'd definitely appreciate any ideas that may help me unsscramble my
head enogh to move on to my next challenge.

Thanks,

Steve Reynolds

Daniel K. O.

unread,
Nov 2, 2009, 11:43:05 PM11/2/09
to ode-...@googlegroups.com
rsreynolds wrote:
> I'm stuck on a Ground Plane that seems to be detecting collisions from
> objects falling on it, but the objects just keep on trucking right
> through it as if it wasn't there.

Some things to check, in this order:

1. Is the collision callback being called?
2. Does dCollide return any contact?
3. Are you creating the contact joints properly?

Consider posting your code on pastebin.com and sending us the link so we
can test it.


> The book was put out in 2005 so I'm guessing that it was using an
> earlier version of ODE and I'm hoping there is a parameter I've missed
> that the 0.11.1 version may require that I haven't picked up on yet.

Other than library initialization, everything should still work the same
as in 0.5 (for your simple test case, that is).


--
Daniel K. O.
"The only way to succeed is to build success yourself"

wb4

unread,
Nov 3, 2009, 8:31:08 AM11/3/09
to ode-users
> I'm stuck on a Ground Plane that seems to be detecting collisions from
> objects falling on it, but the objects just keep on trucking right
> through it as if it wasn't there.

I take "seems to be detecting collisions" to mean that dCollide() is
generating contacts between the plane and the objects. Some things to
check:
- Are you creating contact joints from those contacts with
dJointCreateContact()?
- Are you attaching those joints to the objects and the static
environment with dJointAttach()?
- Are you setting the contact surface parameters (especially
surface.mode) before calling dJointCreateContact() ?

rsreynolds

unread,
Nov 3, 2009, 11:30:17 PM11/3/09
to ode-users
Thanks for the info. I'll definitely check the areas suggested. The
last "- Are you setting the contact surface parameters (especially
surface.mode) before calling dJointCreateContact() ? " may be culprit
as I don't remember anything about surface mode. Will check it out and
respond with results and post source files to pastebin.com and provide
link.

Thanks guys,

Steve Reynolds

rsreynolds

unread,
Nov 4, 2009, 2:07:19 PM11/4/09
to ode-users
I believe this is section of code that your asking about:

...
dContact contact[CWorld::MAX_CONTACTS];
for (i=0; i<CWorld::MAX_CONTACTS; i++)
{
contact[i].surface.mode = dContactBounce | dContactSoftCFM;
contact[i].surface.mu = dInfinity;
contact[i].surface.mu2 = 0;
contact[i].surface.bounce = 1.5;
contact[i].surface.bounce_vel = 1.6;
contact[i].surface.soft_cfm = 0.01;
}
if (int numc = dCollide (o1, o2, CWorld::MAX_CONTACTS, &contact
[0].geom, sizeof(dContact)))
{
for (i=0; i<numc; i++)
{
dJointID c = dJointCreateContact ( GetWorld()->GetWorldID(),
GetWorld()->GetJointGroupID(),
&contact[i]);
dJointAttach (c,b1,b2);
}
}
...

wb4

unread,
Nov 4, 2009, 6:37:27 PM11/4/09
to ode-users
On Nov 4, 2:07 pm, rsreynolds <skypigtw...@gmail.com> wrote:
> I believe this is section of code that your asking about:
>
> ...
> dContact contact[CWorld::MAX_CONTACTS];
> for (i=0; i<CWorld::MAX_CONTACTS; i++)
> {
> contact[i].surface.mode = dContactBounce | dContactSoftCFM;
> contact[i].surface.mu = dInfinity;
> contact[i].surface.mu2 = 0;
> contact[i].surface.bounce = 1.5;
> contact[i].surface.bounce_vel = 1.6;
> contact[i].surface.soft_cfm = 0.01;
> }
> if (int numc = dCollide (o1, o2, CWorld::MAX_CONTACTS, &contact
> [0].geom, sizeof(dContact)))
> {
> for (i=0; i<numc; i++)
> {
> dJointID c = dJointCreateContact ( GetWorld()->GetWorldID(),
> GetWorld()->GetJointGroupID(),
> &contact[i]);
> dJointAttach (c,b1,b2);
> }
> }
> ...

Yes, and it looks okay to me, assuming that b1 and b2 are being set
properly before dJointAttach() is called.

Can you verify that numc > 0 when your objects intersect the plane?

rsreynolds

unread,
Nov 4, 2009, 9:42:25 PM11/4/09
to ode-users
Numc is 1 at collision. Full NearCallback() below:

// NearCallback(...)
// this is called by dSpaceCollide when two objects in space are
// potentially colliding. This function was taken from the ODE library
// examples.
//////////////////////////////////////////////////////////////////////
static void NearCallback (void *data, dGeomID o1, dGeomID o2)
{
int i;

// exit without doing anything if the two bodies are connected by a
joint
dBodyID b1 = dGeomGetBody(o1);
dBodyID b2 = dGeomGetBody(o2);
if (b1 && b2 &&
dAreConnectedExcluding (b1, b2, dJointTypeContact)) return;

dContact contact[CWorld::MAX_CONTACTS];
for (i=0; i<CWorld::MAX_CONTACTS; i++)
{
contact[i].surface.mode = dContactBounce | dContactSoftCFM;
contact[i].surface.mu = dInfinity;
contact[i].surface.mu2 = 0;
contact[i].surface.bounce = 1.5;
contact[i].surface.bounce_vel = 1.6;
contact[i].surface.soft_cfm = 0.01;
}
if (int numc = dCollide (o1, o2, CWorld::MAX_CONTACTS, &contact
[0].geom, sizeof(dContact)))
{
for (i=0; i<numc; i++)
{
dJointID c = dJointCreateContact ( GetWorld()->GetWorldID(),
GetWorld()->GetJointGroupID(),
&contact[i]);
dJointAttach (c,b1,b2);
}
}
}

If we don't get it sorted out in the next few days I'll post VS2008
solution/source/libs/includes and anything else I think it needs to be
built at pastebin.com and provide link.

rsreynolds

rsreynolds

unread,
Nov 4, 2009, 9:54:33 PM11/4/09
to ode-users
As an after-thought, I figured I'd throw in the code where the ground
plane is created - maybe something is hosed there...

...
// Create the ground plane
CEntity *pGround = GetWorld()->CreateEntity(L"Ground", 5, .2, 5,
D3DCOLOR_XRGB(128,128,255),
m_pGraphics->GetDevice());

// Prevent the ground from falling
pGround->SetEnabled(false);


// To make the ground fall when the first ball hits it,
//uncomment this code:
// pGround->SetEnabled(true);
// pGround->SetGravity(false);
...

Jon Watte

unread,
Nov 5, 2009, 11:31:58 AM11/5/09
to ode-...@googlegroups.com
rsreynolds wrote:
> contact[i].surface.mode = dContactBounce | dContactSoftCFM;
> contact[i].surface.mu = dInfinity;
> contact[i].surface.mu2 = 0;
> contact[i].surface.bounce = 1.5;
> contact[i].surface.bounce_vel = 1.6;
> contact[i].surface.soft_cfm = 0.01;
>

A bounce restitution of 1.5 will add energy to the system. Try something
much smaller, like 0.1, to begin with.
A CFM of 0.01 is really high, and will make the system very squishy. For
a very heavy ball, the system may actually not be able to push it out.
A mu of "dInfinity" might be too much for some of the internal math; I
don't know. The problem is that, if you don't turn on dContactApprox1,
"mu" is a force limit, not a coefficient of friction. I would turn on
dContactApprox1, and set mu and mu2 to some high cof, like 2.0 or so, to
start with.

On a general code cleanliness topic: It would be more efficient to move
this assignment into the loop where you actually create the contact
joint, so you only do the assignments for dContacts you will actually
use. The dCollide function doesn't use those fields at all.

Sincerely,

jw


--

Revenge is the most pointless and damaging of human desires.

rsreynolds

unread,
Nov 5, 2009, 8:02:54 PM11/5/09
to ode-users
Thanks for info Jon. Made suggested changes and played with values a
little but still get no bounce.

rsreynolds

Bill Sellers

unread,
Nov 6, 2009, 2:40:47 AM11/6/09
to ode-...@googlegroups.com
In my experience 'bounce' often doesn't give you the results you
expect. I think it interacts with the chosen CFM and ERP of the
contacts (and if these generate a relatively large amount of damping
then you will lose energy from the system and you won't get much if
any bouncing - similarly you can get bouncing with a bounce of zero if
the contact is soft since you get quite a bit of energy store and
recovery from the penetration). Try using the default values for CFM
and ERP which are very stiff with very little damping (think dropping
a pool ball onto a slate table - it still bounces).

Cheers
Bill

rsreynolds

unread,
Nov 6, 2009, 9:13:38 PM11/6/09
to ode-users
Full source code and VS2008 config is not going to be easy to post.
Link to the publisher's site where code can be downloaded is:
http://www.courseptr.com/ptr_downloads.cfm?searchTerm=simulation+and+event+modeling+for+game+developers&submit=Search+Downloads

Chapter 8, section 2 is where I encountered the ground plane not
stopping items dropped on it. If anyone wants to take a look, the
things I encountered and had to fix were a problem with with deleting
vector iterators and still trying to use them. I think the fix was
something like "i = m_lstEvents.erase(i); vice "m_lstEvents.erase
(i);". Also had to add dInitODE(): to main.cpp. I'm thinking it has to
be in how the tutorial application is setting up the Ground Plane, but
ain't having much luck figuring out why entities fall though after
collision.

rsr

Neeti Wagle

unread,
Nov 16, 2009, 3:36:51 AM11/16/09
to ode-users
I had the same problem. Here is what was wrong :

dSpaceCollide (space,0,&nearCallback);
if (!pause)dWorldQuickStep (world,0.02);

This is the order in which these 2 function calls should appear. I had
the order reversed and that was making the objects fall through the
ground.

Im not sure if this would fix your problem, but its definitely one of
the causes.

--Neeti



On Nov 6, 7:13 pm, rsreynolds <skypigtw...@gmail.com> wrote:
> Full source code and VS2008 config is not going to be easy to post.
> Link to the publisher's site where code can be downloaded is:http://www.courseptr.com/ptr_downloads.cfm?searchTerm=simulation+and+...
>
> Chapter 8, section 2 is where I encountered thegroundplane not
> stopping items dropped on it. If anyone wants to take a look, the
> things I encountered and had to fix were a problem with with deleting
> vector iterators and still trying to use them. I think the fix was
> something like "i = m_lstEvents.erase(i); vice "m_lstEvents.erase
> (i);". Also had to add dInitODE(): to main.cpp. I'm thinking it has to
> be in how the tutorial application is setting up theGroundPlane, but

rsreynolds

unread,
Nov 17, 2009, 5:48:49 PM11/17/09
to ode-users
Thank you very much!
Reply all
Reply to author
Forward
0 new messages