[ODE] dGeomTriMeshDataBuildSimple
Adrian Boeing
junk at adrianboeing.com
Fri Jun 22 00:01:50 MST 2007
Hi,
I am trying to create a mesh with dGeomTriMeshDataBuildSimple. I have
used this code before, and it has worked, however for the simple mesh I
am now trying to construct objects just fall right through the mesh as
if it was not there.
Does anyone know why ODE will not perform collision tests with this mesh?
This is the mesh I am trying to create is: (an upside down open square
pyramid)
float verts[] = { 0,0,1,//top
-1,0,0, 0,-1,0, 1,0,0, //middle
0,0,-1 }; //bottom
int inds[] = { 2,1,0, 2,0,3,
1,2,4, 2,3,4};
...
ptm->Init(0,0,0,verts,5,inds,3*4);
This is my code for setting up a trimesh:
void palODETerrainMesh::Init(Float px, Float py, Float pz, const Float
*pVertices, int nVertices, const int *pIndices, int nIndices) {
int i;
dVector3 *spacedvert = new dVector3[nVertices];
for (i=0;i<nVertices;i++) {
spacedvert[i][0]=pVertices[i*3+0];
spacedvert[i][1]=pVertices[i*3+1];
spacedvert[i][2]=pVertices[i*3+2];
}
palTerrainMesh::Init(px,py,pz,pVertices,nVertices,pIndices,nIndices);
// build the trimesh data
dTriMeshDataID data=dGeomTriMeshDataCreate();
dGeomTriMeshDataBuildSimple(data,(dReal*)spacedvert,nVertices,pIndices,nIndices);
// build the trimesh geom
odeGeom=dCreateTriMesh(g_space,data,0,0,0);
// set the geom position
dGeomSetPosition(odeGeom,m_fPosX,m_fPosY,m_fPosZ);
// in our application we don't want geoms constructed with meshes
(the terrain) to have a body
dGeomSetBody(odeGeom,0);
delete [] spacedvert;
}
Thanks,
-Adrian
More information about the ODE
mailing list