dCollide() always returns 0

View: New views
4 Messages — Rating Filter:   Alert me  

dCollide() always returns 0

by wb4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Version 0.11.1 on AMD XP 3000+ running Fedora 7

Can somebody tell me what I'm doing wrong?  Here's some compilable C
code which outputs
contact_count is 0

It creates overlapping cube geoms and calls dCollide() with them.
This *should* generate some contacts, but it doesn't.

=== begin demo.c ===

#include <ode/ode.h>

#include <stdio.h>

int main(int argc, char **argv) {
  dGeomID g1;
  dGeomID g2;
  const int MAX_CONTACTS = 10;
  dContact contact[MAX_CONTACTS];
  int contact_count;
  int i;

  g1 = dCreateBox(0, 10, 10, 10);
  g2 = dCreateBox(0, 10, 10, 10);

  dGeomSetPosition(g1, 7, 7, 7);

  for (i = 0;  i < MAX_CONTACTS;  ++i) {
    contact[i].surface.mode = dContactBounce | dContactSoftCFM;
    contact[i].surface.mu = dInfinity;
    contact[i].surface.mu2 = 0;
    contact[i].surface.bounce = 0.8;
    contact[i].surface.bounce_vel = 0.1;
    contact[i].surface.soft_cfm = 0.01;
  }

  contact_count = dCollide(g1, g2, MAX_CONTACTS, &contact[0].geom,
sizeof(dContact));

  printf("contact_count is %d\n", contact_count);

  return 0;
}

=== end demo.c ===

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "ode-users" group.
To post to this group, send email to ode-users@...
To unsubscribe from this group, send email to ode-users+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/ode-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: dCollide() always returns 0

by Bruce Veazie :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


You need to initialize the libary - dInitODE() or similar.

FYI, when just starting out, if you use the debug library, you'll get
informative error messages for things like that.

Bruce
----- Original Message -----
From: "wb4" <wbrameld4@...>
To: "ode-users" <ode-users@...>
Sent: Wednesday, October 28, 2009 7:44 PM
Subject: [ode-users] dCollide() always returns 0


>
> Version 0.11.1 on AMD XP 3000+ running Fedora 7
>
> Can somebody tell me what I'm doing wrong?  Here's some compilable C
> code which outputs
> contact_count is 0
>
> It creates overlapping cube geoms and calls dCollide() with them.
> This *should* generate some contacts, but it doesn't.
>
> === begin demo.c ===
>
> #include <ode/ode.h>
>
> #include <stdio.h>
>
> int main(int argc, char **argv) {
>  dGeomID g1;
>  dGeomID g2;
>  const int MAX_CONTACTS = 10;
>  dContact contact[MAX_CONTACTS];
>  int contact_count;
>  int i;
>
>  g1 = dCreateBox(0, 10, 10, 10);
>  g2 = dCreateBox(0, 10, 10, 10);
>
>  dGeomSetPosition(g1, 7, 7, 7);
>
>  for (i = 0;  i < MAX_CONTACTS;  ++i) {
>    contact[i].surface.mode = dContactBounce | dContactSoftCFM;
>    contact[i].surface.mu = dInfinity;
>    contact[i].surface.mu2 = 0;
>    contact[i].surface.bounce = 0.8;
>    contact[i].surface.bounce_vel = 0.1;
>    contact[i].surface.soft_cfm = 0.01;
>  }
>
>  contact_count = dCollide(g1, g2, MAX_CONTACTS, &contact[0].geom,
> sizeof(dContact));
>
>  printf("contact_count is %d\n", contact_count);
>
>  return 0;
> }
>
> === end demo.c ===
>
> >
>



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "ode-users" group.
To post to this group, send email to ode-users@...
To unsubscribe from this group, send email to ode-users+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/ode-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: dCollide() always returns 0

by wb4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Thank you, that was it exactly!

After I read your reply, I went looking for dInitODE() (and dCloseODE
()) in the tutorials and user guides I had been reading.  There was no
mention of it.  I finally found it in the manual linked to from the
wiki.  Makes me wonder what else I've missed.  I'll definitely soak up
the manual before I post any more questions to this group.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "ode-users" group.
To post to this group, send email to ode-users@...
To unsubscribe from this group, send email to ode-users+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/ode-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: dCollide() always returns 0

by Bruce Veazie :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


It can be a bit daunting and confusing for beginners, but there is a lot of
information that can be gleaned from the tutorials referenced on the wiki
site, and from the examples in the library download. Couple the examples
with looking up functions in the manual and you've got a start.

Bruce



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "ode-users" group.
To post to this group, send email to ode-users@...
To unsubscribe from this group, send email to ode-users+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/ode-users?hl=en
-~----------~----~----~----~------~----~------~--~---