[ODE] Quake3 BSP / Trimesh problems

Paul Hunkin bieh.nz at gmail.com
Thu Sep 9 21:41:34 MST 2004


Hi, everyone,

I'm trying to create a Trimesh of my Q3BSP level, but I'm running into
some problems. It's probably easier to show what the problem is,
rather than explain it, so:

http://bieh.meton.net/images/other/screenshot33.JPG
http://bieh.meton.net/images/other/screenshot34.JPG
http://bieh.meton.net/images/other/screenshot35.JPG

The gray lines is the trimesh...as you can see, it's creating lots of
random bits as well as mapping over my level, and I don't know why. As
you can imagine, this completly messes everything up, and my geoms
don't collide properly :(

The code I'm using to create and render the trimesh:

const int MAX_GEOM_OBJECTS = 50000; //temp hack :)

dVector3 Vertices[MAX_GEOM_OBJECTS];
int Indices[MAX_GEOM_OBJECTS];
int totalindices;

void CQuake3BSP::CreatePhysicsGeom()
{

       CPhysicsHandler *mWorld = &e->mPhysicsHandler;

       for(int i=0;i<MAX_GEOM_OBJECTS;i++)
               Indices[i] = -1;

       for(int i=0;i<MAX_GEOM_OBJECTS;i++)
               Vertices[i][0] = Vertices[i][1] = Vertices[i][2] = 0;

       int count=0;
       dTriMeshDataID Data;

       for(int i=0; i<m_numOfFaces; ++i)
       {
               for(int f=0; f < m_pFaces[i].numOfVerts ; ++f)
               {
                       int v = f + m_pFaces[i].startVertIndex;

                       Indices[count] = count;
                       Vertices[count][0] = m_pVerts[v].vPosition.x;
                       Vertices[count][1] = m_pVerts[v].vPosition.y;
                       Vertices[count][2] = m_pVerts[v].vPosition.z;

                       ++count;
               }
       }
       --count;

       totalindices = count;

       Data = dGeomTriMeshDataCreate();
       dGeomTriMeshDataBuildSimple(Data, (dReal*)Vertices,
count,Indices, count);

       mGeom = dCreateTriMesh(mWorld->mWorldHandler.mSpace, Data, 0, 0, 0);

       e->mConsole.Print(LOG_ENGINE,"Created physics for BSP (%d)",count);
}

void CQuake3BSP::RenderPhysicsGeom()
{
       e->mGraphics.Begin(GL_LINES);

       for (int i = 1; i < totalindices; i++)
       {
               e->mGraphics.Vertex(ConvertToVector((float*)&Vertices[Indices[i
- 1]]));
               e->mGraphics.Vertex(ConvertToVector((float*)&Vertices[Indices[i]]));
       }

       e->mGraphics.End();
}

The CQuake3BSP class is (for all the bits that are related to this,
anyway) basically the one from the GameTutorials.com BSP loading
tutorial, if that's any help.

I'm admittedly pretty clueless when it comes to this trimesh stuff,
and I can't help but think I'm missing something really basic. So, if
one of you guys could point it out, that'd be really cool. Thanks :)


-paul


More information about the ODE mailing list