[ODE] Quake3 BSP / Trimesh problems

Flavien Brebion f.brebion at vrcontext.com
Fri Sep 10 15:51:08 MST 2004


ODE only supports triangle meshes. Are you sure your m_pFaces[i].numOfVerts
is always 3 ?

Why are you decreasing the number of indices by 1 after the vertex/index
construction loop ?

Your RenderPhysicsGeom function looks suspicious too. If you have two
triangles: ABC DEF, it's going to draw lines AB, BC, CD, DE, EF. The line
CD should obviously not exist. The lines AC and DF are missing. But maybe
it's me, i'm falling asleep. Good luck anyway,

F. Brebion


-----Original Message-----
From: ode-bounces at q12.org [mailto:ode-bounces at q12.org]On Behalf Of Paul
Hunkin
Sent: Friday, September 10, 2004 3:42 AM
To: ode at q12.org
Subject: [ODE] Quake3 BSP / Trimesh problems


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
_______________________________________________
ODE mailing list
ODE at q12.org
http://q12.org/mailman/listinfo/ode
---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.748 / Virus Database: 500 - Release Date: 9/1/2004

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.748 / Virus Database: 500 - Release Date: 9/1/2004



More information about the ODE mailing list