Sign in to follow this  
julienr

[Q3BSP] Rendering non-original maps

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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[i].type == 1 || faces[i].type == 3 ) {
glVertexPointer(3, GL_FLOAT, sizeof(struct vertex), &vertices[faces[i].vertex].position[0]);
glDrawElements(GL_TRIANGLES, faces[i].n_meshverts, GL_UNSIGNED_INT, &meshverts[faces[i].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]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this