From: Chris B. <chr...@gm...> - 2007-04-24 08:42:10
|
On 24/04/07, Simon Hildebrandt <twi...@ob...> wrote: > Chris Bainbridge wrote: > > a) not use an ODE body for your object - use a Geom, do the collision > > detection, then in your collide handler create an ode.ContactJoint, > > and instead of attaching it to the body of the draggable Geom attach > > it to the static environment (ode.environment). That should give ODE a > > contact on the object you hit, but not on the one you're dragging. > > > *nod* Yeah - from reading the wiki, that seemed to be the best technique > to isolate the selected object. > > Particularly, I'm wondering what would be the best way to get the > selected object in motion? Setting the position seems to interfere with > the collision detection, and I don't think I could get the positioning > accurately by adding forces... Setting velocity, then? You set velocity, add forces etc. to ODE bodies. Those are the things with mass. Geoms are just shapes - you can translate them and rotate them, but they have no properties like velocity. So if you only have a Geom, you have to set its position. Now the collision detection normally generates a ContactJoint constraint from the two Geoms and then applies it to the actual ODE bodies in order to push them apart. In your code this looks something like: j = ode.ContactJoint(self.world, self.contactGroup, c) j.attach(geom1.getBody(), geom2.getBody()) c is the contact - you can get its parameters with c.getContactGeomParams(), which returns the depth, normal, and two intersecting Geoms. As this code shows, the actual collision detection is completely separate from the ODE body simulation. So setting a position directly is only going to be a problem if you have an ODE body attached to the Geom. You can play around with it by calling ode.collide(geom1,geom2) and examining the list of contacts it returns. It's completely up to you how this list gets applied in the ODE simulator; it's just a list of Geoms, intersection normals, penetration depths, and friction coefficients. |