[Q3BSP] Rendering non-original maps

Started by
4 comments, last by Zakwayda 19 years, 6 months ago
Hello, I have writted a Q3Bsp loader and it is working fine with all the original q3map ( http://www.fhtagn.net/images/bspq3dm1.png ). But i tried some other maps like defrag one (like Freestyle_88 : content.mousepotato.org/maps/f/freestyle_88.pk3 ) and i get wrong ( http://www.fhtagn.net/images/bspbug.png ) rendering. I think it has something to do with triangles fans or strip, but i can't find any documentation about how to determine if a face muste be rendered with something other than GL_TRIANGL_FAN

 glVertexPointer(3, GL_FLOAT, sizeof(BspVertex), &pVerts[0].vPosition);
glDrawArrays(GL_TRIANGLE_FAN, pFace->startVertIndex, pFace->numOfVerts); 
Has anybody an idea about what is wrong ? You can get complete source of my q3bsp class here (it's mainly taken from gametutorials.com and other docs): http://cvs.sourceforge.net/viewcvs.py/epfl/tgengine-0.1/q3bsp.h?rev=1.2&view=markup (header) http://cvs.sourceforge.net/viewcvs.py/epfl/tgengine-0.1/q3bsp.cc?rev=1.7&view=markup (source) Thanks Julien
Advertisement
If you are rendering regular faces with triangle fans, that may be causing problems. 'Normal' faces in .bsp maps are described with an index set triangulation, just like meshes. They aren't necessarily just a set of verts in order.

In my first .bsp loader I rendered the regular faces as fans for the q3 maps, and it appeared to work fine. But I don't know that it's guaranteed to work for any map. I would try ditching the fans and treating the 'normal' faces just like 'mesh' faces (at least as far as rendering is concerned) and see if that clears the problem up.

Let me know if you need any clarification.
You should not render the type 1 faces as triangles fans but as triangles. And they should be rendered exactly like type 3 faces.

The vertex member in the the face struct of the face you are rendering signifies the start of the vertex array you should use. Something like this

struct vertex* vertices;struct face* faces;struct meshvert* meshverts;for(i=0; i<facecount; i++) {  if ( faces.type == 1 || faces.type == 3 ) {    glVertexPointer(3, GL_FLOAT, sizeof(struct vertex), &vertices[faces.vertex].position[0]);    glDrawElements(GL_TRIANGLES, faces.n_meshverts, GL_UNSIGNED_INT, &meshverts[faces.meshvert].offset);  }}


You'd do the same thing with texcoord arrays and all that stuff.

So the vertex indices are stored in the meshvert-array and the meshvert data of the face is used. And since the meshvert array indices does not contain absolute indices into the vertex-list of the map you have to set the vertex pointer to point at the first vertex of the face.

edit: forgot end source-tag and added if-statement just to clarify. Also fixed sizeof(), my brain's not working.

[Edited by - fiskbil on October 18, 2004 5:36:53 PM]
this will be covered in my upcomming article!
"I am a donut! Ask not how many tris/batch, but rather how many batches/frame!" -- Matthias Wloka & Richard Huddy, (GDC, DirectX 9 Performance)

http://www.silvermace.com/ -- My personal website
It's working !
Thanks :)

But why is there a difference between mesh and polygon faces (type 1 & 3), since they are rendered exactly in the same way ?
One difference between the types is that faces generally use lightmaps, while meshes generally use colors. At least in my q3 renderer, the shader manager needs to know which type it's working with so it can construct the appropriate default shader from a texture when necessary.

Also, I think meshes and patches may be culled by their bounding boxes, but I'm not sure whether Quake does this or not.

So anyway, yes they are rendered the same, but there are a few detail about how they're handled internally that are different.

This topic is closed to new replies.

Advertisement