Managing 3D Game Worlds
#1 Members - Reputation: 100
Posted 31 July 2011 - 04:05 PM
I am a c++ programmer and have worked with OpenGL and I understand how to do things like, render primitives, load models, get input from devices, etc. what I am struggling with, is putting it all together. Nor can I find information about this or maybe what I am looking for is not the way it is done.
How do I manage a 3d scene, ie. Load Game World Objects into a scene and manage them, the way I visualize it and which may be my shortcoming, is like a hierarchy of
objects, all with parents and children. but maybe this is way to complicated for a simple game. Should I use a basic container like vector and iterate through it every frame?
I have tried project after project, attempting to use this hierarchy idea, and have alway's come to a dead end. I have read several books, and they go as far as telling me how to draw objects, and control them, but what If my Game World is per say, a large Solar System with Planets, Asteroids, Ships, and a Star, how do I manage them all?
#2 Members - Reputation: 4604
Posted 31 July 2011 - 11:20 PM
My two cents:Hi, I have been searching on Google and looking over these forums for a while and haven't found what I am looking for, I think I am wording it wrong for any search engine so maybe someone can help me grasp these concepts.
I am a c++ programmer and have worked with OpenGL and I understand how to do things like, render primitives, load models, get input from devices, etc. what I am struggling with, is putting it all together. Nor can I find information about this or maybe what I am looking for is not the way it is done.
How do I manage a 3d scene, ie. Load Game World Objects into a scene and manage them, the way I visualize it and which may be my shortcoming, is like a hierarchy of
objects, all with parents and children. but maybe this is way to complicated for a simple game. Should I use a basic container like vector and iterate through it every frame?
I have tried project after project, attempting to use this hierarchy idea, and have alway's come to a dead end. I have read several books, and they go as far as telling me how to draw objects, and control them, but what If my Game World is per say, a large Solar System with Planets, Asteroids, Ships, and a Star, how do I manage them all?
First you should divide your engine in different parts, like render-engine, physics-engine, game-logic, AI. The reason is, that you often need special or optimized representation of your world objects in different contexts. This already lead to the necessarity, that you will not be happy with only one representation.
The hierarchy is a good starting point, it will help you to organise your objects in a game-logic way (have different squads, with mulitple members , who got different equipment etc.) and is often useful for updating objects.
The next step should be a "random access" structure, where you can query your world according to some parameters, i.e. "give me all objects at position X of type Z". Sweep'n'prune would be a good start, because of its good performance and handling of dynamic objects. Or an oct-tree. You could combine them (static object => oct-tree, moving object =>SnP).
Your hierachy must be synchronised with this structure.
The next step depends on your rendering/physics engine etc. External libs for physics(recommended to use one !!) often have their own specialised structures, renderer engines too. When writing your own rendering engine you could start to use your game-logic query structure first, but certain rendering techniques could perform better with spezialised structures.
My game: Gnoblins
Developer journal about Gnoblins
Small goodies: Simple alpha transparency in deferred shader
#3 GDNet+ - Reputation: 1727
Posted 01 August 2011 - 12:53 AM
SAP has proven to be not good enough IMO. With more than 5% moving entities (410) it becomes almost 3 times slower than btDbvt, which I understand to be an AABB tree. See CDTestFramework.
I've been playing with BVH for a while and recently moved to an array of AABB as well. They always provided good perf to me so far, although I wish I would have just used AABB since start as I spent so many time on this it's hard to believe.
#4 GDNet+ - Reputation: 2368
Posted 02 August 2011 - 02:23 PM
Check out our (now available) D3D11 book: Practical Rendering and Computation with Direct3D 11
Check out my Direct3D 11 engine on CodePlex: Hieroglyph 3
Check out our free online D3D10 book: Programming Vertex, Geometry, and Pixel Shaders
Lunar Rift :: Dual-Paraboloid Mapping Article :: Parallax Occlusion Mapping Article :: Fast Silhouettes Article






