• Advertisement

Archived

This topic is now archived and is closed to further replies.

quake3 bsp face types

This topic is 5713 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i have written a small q3 map renderer and it works quite well with most geometry. but there are face types in the bsp file where i dont know how to render them. normal geometry is rendered as a tringle fan, ok thats good. but there are objects called meshes an when i render them as a tringle fan it doesnt look right. also as tringle strip or tringle list. i have looked at some tutorials and they dont even try to render meshes. and in a description of the bsp file format there was written: "render it as a tringle list"... well that just doesnt work... any suggestions or links to a good explanation appreciated!

Share this post


Link to post
Share on other sites
Advertisement
actually, I would also be very happy with an explanation. I''ve been trying almost everything to render the meshes and bezier curves in q3bsp levels, with no success.

===========================
UNKNOWN caused an invalid page fault in module unknown at 0000:bff80eb6
: win98 with multiple sclerose

Share this post


Link to post
Share on other sites
I went through the same thing. Firstly make sure you are not trying to use the values stored directly in the mesh structure as the verticies of your objects. The mesh structure contains the locaton in the vertex array of the first vertex of the mesh and num of verts for the mesh. I am sure you know that already just making sure. The meshes can not be rendered in any convientet fashion such as strips or fans that I know of. Rather, they must be rendered basically as polygon soup. just render all the triangles, so using open GL just render them as GL_TRIANGLEs. For slightly more speed I recommend that your preload your verts, at least for the meshes into GL vertex arrays, and then lock the arrays, this should give a slight performance boost, and it can never hurt. Anyway, there you go. Glad to help ya.

Nomad

Share this post


Link to post
Share on other sites
thx for the quick answer.

ok, you say just render the mesh like the normal geometry but use GL_TRIANGLES instead of GL_TRIANGLE_FAN...
doesnt work! (maybe im silly...)

Share this post


Link to post
Share on other sites
also this mesh consists of 22 vertices... a triangle list... hmmm...

Share this post


Link to post
Share on other sites
There is a ''verts'' list, and a ''meshverts'' list.

The polygons are the ''verts'' list as a triangle fan.

The triangle soups are the ''meshverts'' rendered with ''GL_TRIANGLES.''

The other two are... well, more complicated. There are a bunch of old posts about the Q3 bezier patches in these forums. Search ''em out.

Share this post


Link to post
Share on other sites
Do you understand what I was saying about how do derefference the verticies. how they are stored. B/c if you derefference them wrong it will not work. besides this I do not know what else could be wrong. This is the way I do it in my q3 .bsp renderer with the addition of the locked vertex arrays for speed.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Do you understand what I was saying about how do derefference the verticies. how they are stored. B/c if you derefference them wrong it will not work. besides this I do not know what else could be wrong. This is the way I do it in my q3 .bsp renderer with the addition of the locked vertex arrays for speed.

Share this post


Link to post
Share on other sites
Do you understand what I was saying about how do derefference the verticies. how they are stored. B/c if you derefference them wrong it will not work. besides this I do not know what else could be wrong. This is the way I do it in my q3 .bsp renderer with the addition of the locked vertex arrays for speed.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
CheeseGrater:
i think you are right. will try that...

Share this post


Link to post
Share on other sites
I don''t know if it''s correct, but does the mesh definition count as a face? I mean, in my face-structure, there are members like:
int meshVertIndex; //The index into the first meshvertex
int numMeshVerts; //The number of mesh vertices
So when I find a face of type 3, it''s in fact a whole mesh, and not one face. Am I thinking right?

===========================
UNKNOWN caused an invalid page fault in module unknown at 0000:bff80eb6
: win98 with multiple sclerose

Share this post


Link to post
Share on other sites
SwSh:
when a mesh has different textures it will be divided into multiple face entries, but you dont have to care about that.

my problem now is that i dont know where the vertices for the meshes are stored. it cant be the same array as the world vertices because i have seen indices that are bigger than the vertex count.
can anyone explain this?

Share this post


Link to post
Share on other sites
Btw, why do faces of both type 1 and 3 contain vertex information _and_ meshvertex information at the same time?
Small part of a dump:

Face 2071: type 3, 87 vertices, first vertex index: 13680 | 369 meshvertices, first meshvertex index: 25545
Face 2072: type 3, 14 vertices, first vertex index: 13767 | 39 meshvertices, first meshvertex index: 25914
Face 2073: type 3, 87 vertices, first vertex index: 13781 | 369 meshvertices, first meshvertex index: 25953
Face 2074: type 3, 14 vertices, first vertex index: 13868 | 39 meshvertices, first meshvertex index: 26322
Face 2075: type 1, 4 vertices, first vertex index: 13882 | 6 meshvertices, first meshvertex index: 26361
Face 2076: type 1, 5 vertices, first vertex index: 13886 | 9 meshvertices, first meshvertex index: 26367

Share this post


Link to post
Share on other sites

OK. There is a vertexes lump, which contains all the vertexes.

There is a meshverts lump, which contains indexes into the vertex lump.

With a facetype 3, you use the face''s meshverts field to index into the meshverts lump. You then use the contents of the meshverts lump to index into the vertexes lump.

http://graphics.stanford.edu/~kekoa/q3/

Share this post


Link to post
Share on other sites
quote:
Original post by SwSh
Btw, why do faces of both type 1 and 3 contain vertex information _and_ meshvertex information at the same time?



Face type 1 uses the meshverts lump to store a valid triangulation of the polygon. That''s nice if you can''t use triangle fans for whatever reason.

Face type 3 lists all the vertexes once in the vertex list. That''s nice if you want to build and lock a vertex buffer before you start rendering. That''s a real FPS saver once you start working with the multipass shaders.

The meshverts list organizes the vertexes into the actual mesh. Many of the vertexes in the meshverts list are specified multiple times... this is because neighboring triangles often share vertexes.

Share this post


Link to post
Share on other sites
Thanks, I've tried to render them like that some time ago. It seems like the vertices are on their places. The problem is that everything seems to be connected with everything. (especially nice in wireframe) In other words, The vertices are not correctly connected. (I render them as GL_TRIANGLES)

Thanks anyway, I'll try to work on it later, g2g now.

===========================
UNKNOWN caused an invalid page fault in module unknown at 0000:bff80eb6
: win98 with multiple sclerose

[edited by - SwSh on June 28, 2002 1:21:23 PM]

Share this post


Link to post
Share on other sites
hm... doesnt work but thats probably my fault =)
one question: what type are the mesh indices? short,int...

Share this post


Link to post
Share on other sites

4 byte ints.


If you''re still having problems, you can check out an open source Quake 3 level renderer at http://www.planetquake.com/aftershock

If that project''s too much for you to understand let me know and I''ll post some old code from my Quake 3 Mesh class after I get home from work.

Share this post


Link to post
Share on other sites
damn... i dont get it to work.

here some code:

if(s->type==3)
{
glBegin(GL_TRIANGLES);
i3=s->firstIndex;
for(i2=0;i2numIndexes;++i2)
{
v=&vertices[meshverts[i3]];//is this right?
glMultiTexCoord2fARB(GL_TEXTURE0_ARB,v->texture[0],v->texture[1]);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB,v->lightmap[0],v->lightmap[1]);
glVertex3fv(&v->pos.x);
++i3;
}
glEnd();
}

this should be correct according to your explanation, but it seams the indices are wrong somehow...
i have already looked at aftershock but the code is not so easy to understand.

Share this post


Link to post
Share on other sites

I''m not sure if that''s right or not.

What''s i2numIndexes? What''s the definition of your ''s'' struct?

Share this post


Link to post
Share on other sites
s:
struct MapSurface
{
int shaderNum;
int lightmapNum;

int firstVert;////indices for vertex list
int numVerts;

int type;

int firstIndex;//for mesh index list
int numIndexes;
};

i2numIndexes should be i2 "smaller than" s.numIndexes
(forum stripped away the html stuff)

vertices is my vertex list.
meshverts is the mesh index list.

Share this post


Link to post
Share on other sites
I think I see the problem now. Meshverts are offset from the first vertex of the face.

Try


v=&vertices[s->firstVert + meshverts[i3]];

Share this post


Link to post
Share on other sites
yeah that''s it!!!

works great now

thanks CheeseGrater!

Share this post


Link to post
Share on other sites

  • Advertisement