[ODE] Contacts and materials

Anselm Hook anselm at hook.org
Mon Dec 2 11:57:01 2002


Sounds good - I should stick this into my C# glue - and separate that glue
from my other project and see if I can't get that into ode as a contrib...
then we can go from there.  I'll try and do this this weekend; since I
have gotten mail from other people who wanted a c# binding.

I also want to look at Martin's C++ wrapper to see if I can closely follow
anything he has done there for consistency across all api's.

And finally somebody pointed out to me that managed c++ is a nice way to
generate C# compatible interfaces... that deserves a peek too.

 - a


On Thu, 28 Nov 2002, Nate W wrote:

> On Thu, 28 Nov 2002, Anselm Hook wrote:
>
> > What about finding a way to generalize material properties such that
> > contacts could be generated automatically?  I'd sure enjoy finding a way
> > to remove the collision callback.
>
> As would I - probably because I've been having fun with C# and I'm eager
> to put your wrappers to work. :-)
>
> Here's how I was thinking the problem might be approached:
>
> The wrapper (your C# wrapper, or probably any wrapper) would define a
> material data structure, something like:
>
> typedef struct
> {
>   void *pUserData;
>   dReal Mu;
>   dReal Bounce;
>   dReal SoftERP;
>   dReal SoftCFM;
>   // etc
> } Material;
>
> All geom objects would have Material pointers in their dGeomGetData /
> dGeomSetData members, and the wrapper would implement those methods as
> follows:
>
> 	// GetData implementation
> 	return ((Material*) dGeomGetData())->m_Data;
>
> 	// SetData implementation
> 	((Material*) dGeomGetData())->m_Data = p;
>
> Then, a wrapper-defined collision callback would work something like this:
>
> void Callback (void *, dGeomID o1, dGeomID o2)
> {
>   int iCount = dCollide (o1, o2, iContacts, &contact[0].geom, sizeof (dContact));
>
>   if (iCount)
>   {
>     int iMax = min (iCount, iContacts);
>     for (int iContact = 0; iContact < iMax; iContact++)
>     {
>       Material *pMaterial1 = null;
>       Material *pMaterial2 = null;
>
>       if (o1)
>         pMaterial1 = dGeomGetData (o1);
>
>       if (o2)
>         pMaterial2 = dGeomGetData (o2);
>
>       SetContactParameters (&contact[iContact], pMaterial1, pMaterial2);
>
>       dJointID ContactJoint = dJointCreateContact (WorldID,
>                CollisionJointGroupID, &contact[iContact]);
>
>       dJointAttach (ContactJoint, Body1, Body2);
>     }
>   }
> }
>
> The implementation of SetContactParameters is left as an exercise for the
> reader. :-)  But, as Anselm suggested, I think it would make a nice
> contrib.  It would make the C# wrapper considerably more useful, and would
> probably be helpful for most non-C/C++ applications that want to use ODE,
> since there would no longer be a need for a callback into the application
> language.  Instead, applications would just set material properties for
> all of the Geoms, and the SetContactParameters method would take care of
> material interactions.
>
> Comments?
>
> --
>
> Nate Waddoups
> Redmond WA USA
> http://www.natew.com
>
>
> _______________________________________________
> ODE mailing list
> ODE@q12.org
> http://q12.org/mailman/listinfo/ode
>