Quake 3 .bsp rendering

Started by
5 comments, last by Rocket05 20 years, 11 months ago
well as the topic says, im trying to write a quake 3 .bsp loader/renderer. i started by following digiben''s (of www.gametutorials.com) guide to the format and rendering. the format appears to be correct and im loading all data correctly, and i can even correctly render the maps that he supplies with his tutorials. however when i tried compiling my own map (with gtkradiant/q3map2), i get a few rendering problems. quake3 renders the map fine, so i know its not something wrong with the file. the map is a simple 6 walled room with one light in it. when i render all the faces as triangle fan''s, but for some reason, every face but the floor is missing a big triangle out of it. kinda like this: |\ /| |x\/x| |xxxx| where X is where the polygon is rendered correctly. am i right in assuming to draw faces as triangle fans? has anyone else encountered this problem before? unfortunatly there is a lacking of articles on the internet about rendering quake3 bsp''s. all help is greatly apprecited, please ask questions about anything unclear.
"I never let schooling interfere with my education" - Mark Twain
Advertisement
well i''ve made some headway in figuring this out...

apparently the faces index the verticies in the wrong order... instead of going around the verticies in a clockwise or even counter clockwise order, the indicies jump around so that your face is drawn wrong. let me attempt another visual:

lets say that the 4 numbers are actually a square face, and the number is the index of that vertex from the face.

a normal face should index like this:
12
43
or:
14
23

but the way the bsp face is coming out, it looks like:
12
34

so you can see it woudln''t fill in the polygon correctly...

the only way i can think to counter this is to check the clockwise order of each face''s indicies and swap as necessary. not too hard, but it seems a very ugly way of doing it. i know quake3 is known for its ugly hacks (even though they work amazingly well), but for quake 3 to load a bsp and correct face indicies at runtime just seems to ugly.

any idea on what *should* be done, or at least how quake3 handles this?
"I never let schooling interfere with my education" - Mark Twain
The answer is easy. Those gamemaker tutorials contain wrong ineformation on how the faces are stored and must be rendered.
They are NOT stored as triangle fan! They are stored as indexed triangle list. They need to be rendered using glDrawElements() and GL_TRIANGLES as element type. The "meshverts" they describe in the tutorial are in fact the needed indices.

skynet
well it turns out mr.(or mrs.) Anonymous was right. i was laying in bed last night (before he posted it) and realized that that must be what the mesh verts were for, and thanks goes to him for clarifying that they are actually triangle lists.

thanks anonymous
"I never let schooling interfere with my education" - Mark Twain
Meshverts are triangle lists, but the other vertex list of a type 1 face is supposed to be a triangle fan.
Type 1 surface is a normal triangle surface. It is not a triangle fan... it is, as they said, an indexed triangle list. What it does have going for it, however, is it''s ordered in triangle strip order whenever possible. Take a look at the Aftershock source code if you want to see what I mean.

R_BackendStripmine in:
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/new-aftershock/src/renderback.c?rev=1.28&content-type=text/vnd.viewcvs-markup
Also, for future issues and ideas in rendering BSPs, you can find my list of BSP sources here.

This topic is closed to new replies.

Advertisement