Quote:Original post by abolfoooud
hi jdaniel ,
thank u very much fro ur reply. to be frank, ur reply has clarified many concepts i read but did not understand how to apply, or i had misconception of applying them.
i got the idea of how to split the polygons and how to include them in their proper boundary boxes of the quad sectors. but when we do the splitting and we need to apply textures on the set of polygons that were split, would not that cause a break in the texture lay out? i mean would not there be breaking in teh texture applied? take for example a wall extended in two quads and split. the texture will not be continuous by then! how do u solve this?
Abolfoooud
Abolfoooud,
Actually, I did not not split my triangles. This is a decision I had to make when constructing the quad tree. Furthermore, the geometry I use for collision detection is never used for rendering directly. Much of the geoemtry used for actual rendering is the same, of course, but other texture mapped geoemtry used for rendered rooms and walls are handled seperately for display. This costs a larger memory footprint, but the benefit is that you can keep your collision geometry at a lower level of detail than the actual geoemtry the player sees.
When rendering collision geoemtry into the quad-tree I decided to "repeat" the triangle if it intersected two quads instead of splitting it into two triangles. If the triangle intersected the quad under consideration, then a pointer to this triangle was added to a doubly linked list associated with that quad. This is done even if the triangle was already added to another quad.
Obviously, I need to be careful how many levels of recursion I let the quad tree grow or this would become a problem. But as long as the quad sectors are about the same size as the bounding sphere of the moving player, this will never be a problem. One thing I could do would be to add a bool to each triangle object that reveals whether or not it has been sent down the collision detection pipeline yet; if not send it; if so don't. I haven't found this step necessary yet, but perhaps I will add this in the future.
I do not construct any BSP tree or quad tree for the actual geometry in the scene at all. Basically, I load everything for the current level in memory. Each object in the game has a bounding box associated with it. However, general world objects and "room geometry" are kept seperate.
There is not a BSP tree used during the actual rendering pass. Instead, there is a frustum culling routine that is passed the bounding box of every object in the level - both world objects and room geoemtry. This routine detects if the bounding box intersects the viewing frustum. Remember, no BSP tree is being used. If the bounding box of these objects intersect the viewing frustum, then I add a pointer to this object to another list... a "possible object to be rendered list", if you will.
Now I iterate through the "possible object to be rendered list" and render every single "room geometry object".
Now that I rendered the walls, floors, windows, and ceilings, the depth buffer has been updated accordingly. I still haven't swapped the buffer yet to display the room geometry because I have general world objects to render still, but I do have a depth buffer with the values of the room in it.
Now, I use a GL_ARB_occlusion_query() call to render the bounding boxes of all the general objects in my "possible object to be rendered list". I do not consider the room geometry that I have already rendered. What this call does is tell me the number of pixels in the framebuffer that would update their z-values if I rendered the object. If it returns a 0, for example, the object might be in the frustum itself but is probably behind a wall - because the z-buffer will not be updated at all if I rendered the bounding box. If I get a value of, say 450, then I know that at least some of the object will be visible to the camera. Maybe part of it is viewable from a window, for example.
A lot of this explaination may have repeated what I already suggested in my previously reponse. So let me attempt to answer your most recent question directly as a summary. You ask "doesn't constructing the BSP tree cause u, v alignment problems when you split a triangle". My answer in this case is, no it does not. Geometry in my engine is never split, and furthermore, geometry that is directly rendered is never rendered into the quad tree in the first place.
BSP-trees are rarely used in visibility culling routines anymore, they are mostly used in collision detection.