[ODE] Newbie TriMesh problems

The Hutch the.hutch at virgin.net
Thu Apr 6 07:23:13 MST 2006


Greetings,

I have only recently started to use ODE and am having trouble with
TriMesh's. I am attempting to have a sphere bounce around a TriMesh
landscape.

In my world I have a left handed coord system with Y up. Everything works
fine for the most degenerate of cases (i.e. a flat terrain) but as soon as I
add a little height that's when things start to go wrong. It was necessary
for me to change the orientation of my triangles in order for the normals to
be pointing in the correct direction.

The setup of my TriMesh is as follows:

...

// Assume the existance of a class called xTerrainMesh that contains a
// collection of CollisionTri's

int iNumTris  = xTerrainMesh.GetNumTris();
int iNumVerts = 3 * iNumTris;

m_pxVerts = new dVector3[iNumVerts];
m_pxTris  = new int[3 * iNumTris];

int i  = 0;

CollisionTri* pxTri = xTerrainMesh.GetFirstTri();
for( int iTri = 0; iTri < xTerrainMesh.GetNumTris(); ++iTri, pxTri =
pxTri->m_pxNext )
{
    m_pxVerts[i][0] = pxTri->m_xA.fX;
    m_pxVerts[i][1] = pxTri->m_xA.fY;
    m_pxVerts[i][2] = pxTri->m_xA.fZ;
    m_pxTris[i] = i;
    i++;

    m_pxVerts[i][0] = pxTri->m_xC.fX;
    m_pxVerts[i][1] = pxTri->m_xC.fY;
    m_pxVerts[i][2] = pxTri->m_xC.fZ;
    m_pxTris[i] = i;
    i++;

    m_pxVerts[i][0] = pxTri->m_xB.fX;
    m_pxVerts[i][1] = pxTri->m_xB.fY;
    m_pxVerts[i][2] = pxTri->m_xB.fZ;
    m_pxTris[i] = i;
    i++;
}

m_pTriMeshData = dGeomTriMeshDataCreate();

dGeomTriMeshDataBuildSimple( m_pTriMeshData,
					 (dReal*)m_pxVerts, iNumVerts,
						 m_pxTris, 3 * iNumTris );

...

So my questions are:

[1] Is there somewhere I can get more TriMesh help or examples?
[2] What am I missing?  Do other people use TriMesh's or are they using
their own collision detection routines?

Any help would be very much appreciated.

Thanks,

Rich




More information about the ODE mailing list