Archived

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

Smurfwow

Quake3 .bsp rendering problems.

Recommended Posts

Hey, I posted here a little while ago asking about a texture problem i had, I''ve got that fixed, now i have a new problem i havn''t been able to overcome. basicly, my render looks.... f$%*ed up, and i have no idea why here are a couple of screenshots. http://members.optushome.com.au/emerald/screen.jpg http://members.optushome.com.au/emerald/q3dm1.jpg (those shots are of q3dm1.bsp) what im doing, is loading the data into structs i wrote based on http://graphics.stanford.edu/~kekoa/q3/. then drawing the verticies as points, and drawing the faces(with textures) if there of type 1 as triangles, quads or polygons based on the number of vert''s in the face. Depth testing and backface culling is enabled. Thanks.

Share this post


Link to post
Share on other sites
First of all, make sure you''ve loaded everything right. Display points only, it should still look like a quake level.

Second, make sure you''re rendering all type 1 polys using a triangle fan.

You can also try and post your rendering code, but first make sure that points work.

Share this post


Link to post
Share on other sites
yup, the map looks right when it''s just the verticies (represneted by GL_POINTS).

It looks better using triangle fan''s , there arn''t stray polygons everywhere now.

What''s the deal with mesh vert''s ?

I''ve noticied that 99% of faces(of type 1 and 3) have a few more meshvert''s than normal verticies.

Are mesh vert''s supposed to be rendered? and if so, how? with triganle fan''s ?

this is the important bit of my current render code, just for the record.

for(i=0; i < numFaces; i++)
{
if(face.type==1)
{
glBegin(GL_TRIANGLE_FAN);

for(j=0; j < face[i].n_vertexes; j++)
{
glVertex3f(vertex[face[i].vertex+j].position[0], vertex[face[i].vertex+j].position[1], vertex[face[i].vertex+j].position[2]);
glTexCoord2f(vertex[face[i].texture+j].texcoord[0][1], vertex[face[i].texture+j].texcoord[0][2]);
}

glEnd();
}
}

Share this post


Link to post
Share on other sites
quote:
Original post by Smurfwow
What''s the deal with mesh vert''s ?

I''ve noticied that 99% of faces(of type 1 and 3) have a few more meshvert''s than normal verticies.



For type 1 faces, the meshverts are a valid split of the polygon into a triangle list. This sometimes requires more verticies than the plain polygon representation in the other vert list.

quote:

Are mesh vert''s supposed to be rendered? and if so, how? with triganle fan''s ?



The ''model'' type (type 3, IIRC) should be drawn as a list of triangles with meshverts (GL_TRIANGLES). Type 1 faces can be drawn either as a fan with the vert list, or a triangle list with the meshvert list. The meshverts end up being faster when you''re trying to sort by shader and minimize rendering calls, but the vert list is better for the naive approach, which is good for the beginnings of a project or less system intensive apps like level editors.

Share this post


Link to post
Share on other sites
ok, thanks for your help.

the geometry seems to look ok now.

http://members.optushome.com.au/emerald/q3dm1tex.jpg

the texturing looks a little off... does this code seem ok?


  
typedef struct
{
float position[3];
float texcoord[2];
float lightcoord[2];
float normal[3];
GLubyte color[4];

} iBSP_vertex;

// <rotate and scale>

// <loop through all faces>

// <check to see if face is type 1>


glBegin(GL_TRIANGLE_FAN);

for(j=0; j < face[i].n_vertexes; j++)
{
glVertex3f(vertex[face[i].vertex+j].position[0], vertex[face[i].vertex+j].position[1], vertex[face[i].vertex+j].position[2]);
glTexCoord2f(vertex[face[i].texture+j].texcoord[0], vertex[face[i].texture+j].texcoord[1]);
}


glEnd();

glBegin(GL_TRIANGLES);

for(l=0; l < face[i].n_meshverts; l++)
{

glVertex3f(vertex[meshvert[face[i].meshvert+l].offset].position[0], vertex[meshvert[face[i].meshvert+l].offset].position[1], vertex[meshvert[face[i].meshvert+l].offset].position[2]);
glTexCoord2f(vertex[face[i].texture+l].texcoord[0], vertex[face[i].texture+l].texcoord[1]);

}

glEnd();

Share this post


Link to post
Share on other sites
there are 4 types of geometry.
take a look at q3 tool sources.

#define BSP_FACETYPE_NORMAL (1)
#define BSP_FACETYPE_PATCH (2)
#define BSP_FACETYPE_MESH (3)
#define BSP_FACETYPE_FLARE (4)

also notice that all faces have vertices of "3",
so 3,6,9,....

make a vertex buffer of GL_TRIANGLE and render them with glDrawElements.

for texturing use gl-s=quake-s, gl-t=1-quake-t, bc. image origin
in ogl is lower left,and in quake upper left.

hope that helps you.

Share this post


Link to post
Share on other sites
For a type 1 face, you should either use the vertex list or the meshvertex list, but not both...

I think the real problem here is that you''re not indexing into the meshvert array for texture coordinates when you''re drawing vertexes from the meshvert array.

Share this post


Link to post
Share on other sites