[ODE] trimesh problem

Jason Perkins starkos at gmail.com
Thu Jul 27 05:21:00 MST 2006


Please include the mailing list in all responses; do not respond to me
directly. I am swamped at the moment and my ability to answer
questions is limited.

On 7/26/06, Fenyvesi Peter 11.E <fenyvesip at tagdebr.sulinet.hu> wrote:
> Thanks for the answer, Jason
>
> The collision-detection callback function: (most part of the code was
> copied from the sampleprogram)
>
> static void nearCallback(void *data, dGeomID o1, dGeomID o2)
> {
>         int i=0;
>
>         dBodyID b1 = dGeomGetBody(o1);
>         dBodyID b2 = dGeomGetBody(o2);
>         if (b1 && b2 && dAreConnectedExcluding(b1, b2, dJointTypeContact)) return;
>
>         dContact *contact=new dContact[MaxNumberOfContacts];
>         for (i=0; i<MaxNumberOfContacts; i++)
>         {
>                 contact[i].surface.mode=dContactBounce | dContactSoftCFM;
>                 contact[i].surface.mu = 0.6f;
>                 contact[i].surface.mu2 = 0;
>                 contact[i].surface.bounce = 0.1f;
>                 contact[i].surface.bounce_vel = 0.1f;
>                 contact[i].surface.soft_cfm = 0.01f;
>         }
>
>         if (int numc = dCollide(o1, o2, MaxNumberOfContacts,
> &contact[0].geom, sizeof(dContact)))
>         {
>
>                 if ((dGeomGetClass(o1)==dTriMeshClass) ||
>                         (dGeomGetClass(o2)==dTriMeshClass))
>                 {
>                         Collision=true;
>                         return;
>                 }
>
>                 dMatrix3 RI;
>                 dRSetIdentity(RI);
>                 const dReal ss[3] = {0.02f, 0.02f, 0.02f};
>                 for (i=0; i<numc; i++)
>                 {
>                         dJointID c=dJointCreateContact(WorldToCollision,
> JointGroupToCollision, &contact[i]);
>                         dJointAttach(c, b1, b2);
>                 }
>
>
>         }
>         delete[] contact;
> }
>
> The next two data type were copied from the manual.
> struct StridedVertex
> {
>         dVector3 Vertex;
> };
> struct StridedTri
> {
>         int Indices[3];
> };
>
> I created these variables to handle the data, which is necessary for
> the construction of the trimesh
> dGeomID GeomID;
> dTriMeshDataID DataID;
> StridedVertex Vertex[4];
> StridedTri Face[2];
> int VertexStride;
> int TriStride;
> int VertexCount;
> int IndexCount;
>
> And the construction:
> 1.Data initialising
> Vertex[0].Vertex[0]= 1.0f; ... Vertex[3].Vertex[2]= 1.0f;
> Face[0].Indices[0]=0; ... Face[1].Indices[2]=3;
>
> VertexStride=sizeof(StridedVertex);
> VertexCount=4;
> TriStride=sizeof(StridedTri);
> IndexCount=2;
> DataID=dGeomTriMeshDataCreate();
> dGeomTriMeshDataBuildSingle1(DataID, Vertex, VertexStride,
> VertexCount, Face, IndexCount, TriStride, NULL);
> GeomID=dCreateTriMesh(container_space, DataID, NULL, NULL, NULL);
> //container_space is a SpaceID
> dGeomEnable(GeomID);
> dGeomTriMeshEnableTC(GeomID, dBoxClass, int(true));
> dGeomTriMeshEnableTC(GeomID, dSphereClass, int(true));
>
> This is everything.
>
> Thanks
> Peter
>
>
>
>


More information about the ODE mailing list