BSP trees? Or something else?

Started by elias4444, March 14, 2005, 18:43:35

Previous topic - Next topic

elias4444

I've been doing my best to read up on OpenGL theory and whatnot, and now that I'm mostly into the "optimizing my code" part of development, I have a few questions for the experts out there:

I'm looking for an effecient way to organize and sort my 3d objects before outputting them to the screen (so that they're painted in correct order - back to front). This is proving more complicated than I had thought it would though, as an object's z-position doesn't actually translate to its far and near plane positions. Most tutorials recommend using a BSP tree, but whereas they're great in theory, they don't seem to match the opengl model of programming (since everything has to be separated by texture, rotations, translations, etc.., and a BSP tree seems to only focus on vector coordinates and planes). So, what are you guys using? Everything I seem to come up with requires some pretty extensive casting in order to figure out what kind of object it is since I have so many different kinds (GLU and otherwise). I think I'm fine using the OpenGL depth testing, even though I've read that it's not effecient (is that true?).

Any help would be appreciated.
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

tomb

You only need bsp trees for collision detection, or any type of raytracing for that mather, and if you absolutely need to sort every damn triangle perfectly.

You don't need to sort opaque (solid) objects. The z buffer will handle it. It is not slow. Where did you read that it was not effecient? Most transparent object needs to be sorted to look right. The most common way is to sort the center of the objects. No need to be 100% accurate :) That is it.

You can also improve performance by sorting the opaque object front to back.

elias4444

It's in a book I own about game development. But in there, they don't actually use OpenGL for their stuff, so yeah, I take it with a grain of salt.

How do you recommend sorting the different objects then? I'm having a hard time creating a generic class for all objects... right now I have Sprite Objects, Particle Objects, etc.. How do you get them to all "talk" together nicely enough to sort them? My big issue with transparent objects is that some of them are larger than others, and so, on occasion, the overlap makes the tansparency look funny.
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

Chman

I would recommend you looking at some frustrum culling and octree examples... It's very easy to implement and it will give you a good start in optimisation !

elias4444

Any good examples somewhere I can get to?
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

Fool Running

http://www.gametutorials.com/  They recently changed how they do things... but I think you can still download the example code  :roll:
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D