[quote]I’m calling a shape whatever xith is calling a shape and i couldn’t care less about what the programmer of the API is doing with this shape/model/whatever internally. I’m just interested in a feature that makes sense to me (and not just me). Maybe it’s hard to implement and doesn’t fit nicely into the current code but should i really care about this as the “user” of the API?
[/quote]
Yes. What makes a good non-realtime system, does not make a good realtime system. The two objectives are almost diametrically opposed. Non-realtime is about handling as much detail as possible, in as configurable way as possible. Realtime is about doing as little as possible between the user code and the graphics hardware. Anything that has to be calculated had better result in a net increase in performance, not a decrease. It is there to provide optimisations for speed so that an end user does not have to write the same thing over and over every time they want to write a 3D application. For example, view frustum culling, picking and state sorting.
[quote] I don’t see how you can make this assumption. By that rationale, every tree in a forest could contained in a single object (since all trees could share the same texture) but it’s silly to assume that every tree would be close to another.
[/quote]
You don’t have to make that assumption at all. There is a single Texture object that can be shared between all the trees. Then, the trees can be spatially separated. So long as you use the same texture object, then state sorting can also be to your benefit, and the culling algorithms will remove useless data eliminating a large percentage of those tree geometries from view. By placing all those trees into a single geometry/shape, you’ve now caused a great amount of problems from a performance perspective. You cover a very large spatial area, so that no matter which direction you face, the scene graph cannot cull some of the geometry. So, instead of only rendering 10K vertices, you now have to render 100K.
[quote]If the Xith answer is “make each of the 2000 polygons into 2000 seperate objects” then that, to me, is not a feasible answer. You’re telling me there’s less overhead with switching between 2000 Shape3Ds than any other possible solution?
[/quote]
Quite simply - yes. It is going to gain you far, far greater performance benefits than doing it the other way. The difference in performance grows at an exponential rate as you increase the number of objects in scene. There’s a darn good reason why every game engine since Doom I have been running spatial partitioning algorithms. It’s certainly not for the programmer or content developer ease of use. Besides, there is no need to have a single shape for every polygon. As others have pointed out, the standard way of solving this problem is to use texture coordinates. Group each object into a single shape (eg a tree model) and then use the texture coords to modify the tree on a per-object basis. It’s not that hard to do and pretty much any programming book that is about game development talks about how to implement these strategies.
[quote]Sorry, but i really don’t get what you are trying to tell me here. That changing the texture state requires 300 lines of code? For sure not.
[/quote]
If you are going to run multiple textures per object, then yes, it will take this many lines of code. That’s precisely the model that the .3ds file format uses internally. Each Object chunk consists of material lists that link to the texture. To work out how to change this to something suitable for openGL to draw, you have to iterate through each object list, breaking apart the coordinate array into a smaller array, set the texture and material state, then send the array to OpenGL, lather, rinse, repeat for all textures on the object. It’s a horrible, inefficient process because of all the for loops that need to be executed per object, per frame.
So what I see here is a case of Having a Hammer problem. Everything looks like a nail. It also appears that JeremieHicks does not have any experience rendering geospatial data. These problems have been solved time and again by the big geospatial engines out there. It’s nothing new in his requirements by any means. You’re using your knowledge of 3DS max, which is designed for doing non-realtime graphics, into assuming that the same techniques are used for realtime, which they’re not.
If you really want to do large scale terrain rendering, I suggest you wander over to the Virtual Terrain Project (commonly known as VTP) at http://www.vterrain.org and have a read through the hundreds of links to the various large-scale terrain rendering algorithms that they have there. You’ll most likely want to look at ROAM or one of the CLOD algorithms. But, in general, what I am seeing here from both of the parties wanting this is a lack of knowledge about fundamental graphics techniques. Do yourself a favour and grab a few books on game engine design or visualisation design and get familiar with the various algorithmic options available. It will save you a heap of time asking questions like this and getting the same “lack of interest” responses.
j3d.org has an implementation of ROAM available in the generic sense, and a specific implementation on top of Java3D. Porting that to work with Xith3D should take very little work. There’s a few bugs in it that are not sorted out, but it will solve all these questions you’re already working on. Managing texture resources and managing polygonal resources can be separated into two orthogonal systems. That’s the way the big rendering engines like Performer work. What you’re asking for is above the design scope for what Xith3D and other scene graphs are aiming for. You can implement these techniques on top of them, but they are not part of the core API for a very good reason - the technique to use is highly application-specific.
As a side note, and the Xith3D guys are probably going to be cranky at me for mentioning this here: Xith3D probably will not be the engine that you’ll want to use if you need to deal with anything more than a single CPU machine. If you’re really doing large-scale terrain visualisation, then you’ll want to make use of my project - Aviatrix3D, which is specifically designed for the visualisation crowd. Multithreaded internals, pluggable rendering pipeline strategies, scales from PC to CAVE with only 2-3 lines of code change etc etc. Still uses JOGL internally for the rendering.