[ODE] Merging multiple geoms into a single trimesh - a few issues
Yordan Gyurchev
yordan at gyurchev.com
Thu Jan 13 20:21:00 MST 2005
> I also need triangle info, for sound generation. While I haven't done
> anything about this yet, I think the best bet is to modify the dContact
> struct to add an int that can store the triangle index (for trimesh-*
> collisions only). With a couple of quick changes, the colliders can
> then set that int, which the app can examine and do whatever with. This
> is superior to the callback since the app knows which successful contact
> is associated with the triangle index - particularly important if the
> app discards contacts (e.g. via depth). Its also a bit nicer than the
> callback.
We had this implemented in our old system and I already porting in in 0.5.
Like Geoff mentioned we have an integer (well 2 of them) in the
dContactGeom structure that is a material index. Mind you this is not a
triangle index. This way materials are finite numbers (enumerations) and can
be half integer leaving space in the contact geom for two materials - after
all you have two objects.
The material list is kept in the trimesh object in our implementation as it
needs
to match the triangle list. Better encapsulation and you don't need the
triangle index
anyway!
Materials are determined and encoded into a material/triangle list during
export phase
in the tools. We do colour coding. Artists colour the physics mesh with
predetermined
material colours.
In a non trimesh object the material can be stored in the actual geom.
So out of dCollide you get a contact geom that has two material indices.
What you do there is up to the app as pointed out earlier. For non physical
objects you might play some sound, emit particle, etc. In our case we simply
provide the info to a general purpose material manager and it does its work.
On other hand if the objects involved in the collision are real physical
objects
you can select appropriate dSurfaceParameters based on the two materials
that you collide. For example wood friction is different when it collides
with
wood, metal or ice.
Hope this helps,
Yordan
More information about the ODE
mailing list