Sign in to follow this  
Followers 0
MattHolley

OpenGL
Managing 3D Game Worlds

3 posts in this topic

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?
0

Share this post


Link to post
Share on other sites
[quote name='matt.holley' timestamp='1312149956' post='4842938']
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?
[/quote]
My two cents:
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". [url="http://en.wikipedia.org/wiki/Sweep_and_prune"]Sweep'n'prune[/url] would be a good start, because of its good performance and handling of dynamic objects. Or an [url="http://en.wikipedia.org/wiki/Octree"]oct-tree[/url]. 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.
0

Share this post


Link to post
Share on other sites
I've been looking into Bullet recently and that's what it is about.

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 [url="http://www.bulletphysics.org/mediawiki-1.5.8/index.php/CDTestFramework"]CDTestFramework[/url].

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.
0

Share this post


Link to post
Share on other sites
I use a spatial scene graph as my hierarchy, which I think is what you are describing. If you are looking for some information about building a scene graph in a rendering system, then the Dave Eberly books are about as good as they get ([url="http://www.geometrictools.com"]Geometric Tools[/url]). This will not show you how to manage a solar system, but does go into detailed design decisions about how and why he used a spatial scene graph in the Wild Magic engine. His engine is also a good reference for lots of algorithms, so it will be worth your while to check it out.
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Similar Content

    • By Jon Alma
      Some time ago I implemented a particle system using billboarding techniques to ensure that the particles are always facing the viewer.  These billboards are always centered on one 3d coordinate.
      I would like to build on this and use billboarding as the basis for things like laser bolts and gunshots.  Here the difference is that instead of a single point particle I now have to draw a billboard between two points - the start and end of the laser bolt for example.  I appreciate that having two end points places limits on how much the billboard can be rotated to face the viewer, but I'm looking to code a best effort solution.  For the moment I am struggling to work out how to do this or find any tutorials / code examples that explain how to draw a billboard between two points ... can anyone help?
      Thanks.
    • By Sagaceil
      It's always better to fight with a bro.
    • By recp
      Hi,
      I'm working on new asset importer (https://github.com/recp/assetkit) based on COLLADA specs, the question is not about COLLADA directly
      also I'm working on a new renderer to render (https://github.com/recp/libgk) imported document.
      In the future I'll spend more time on this renderer of course, currently rendering imported (implemented parts) is enough for me
      assetkit imports COLLADA document (it will support glTF too),
      importing scene, geometries, effects/materials, 2d textures and rendering them seems working
      My actual confusion is about shaders. COLLADA has COMMON profile and GLSL... profiles,
      GLSL profile provides shaders for effects so I don't need to wory about them just compile, link, group them before render

      The problem occours in COMMON profile because I need to write shaders,
      Actually I wrote them for basic matrials and another version for 2d texture
      I would like to create multiple program but I am not sure how to split this this shader into smaller ones,

      Basic material version (only colors):
      https://github.com/recp/libgk/blob/master/src/default/shader/gk_default.frag
      Texture version:
      https://gist.github.com/recp/b0368c74c35d9d6912f524624bfbf5a3
      I used subroutines to bind materials, actually I liked it,
      In scene graph every node can have different program, and it switches between them if parentNode->program != node->program
      (I'll do scene graph optimizations e.g.  view frustum culling, grouping shaders... later)

      I'm going to implement transparency but I'm considering to create separate shaders,
      because default shader is going to be branching hell
      I can't generate shader for every node because I don't know how many node can be exist, there is no limit.
      I don't know how to write a good uber-shader for different cases:

      Here material struct:
      struct Material { ColorOrTexture emission; ColorOrTexture ambient; ColorOrTexture specular; ColorOrTexture reflective; ColorOrTexture transparent; ColorOrTexture diffuse; float shininess; float reflectivEyety; float transparency; float indexOfRefraction; }; ColorOrTexture could be color or 2d texture, if there would be single colorOrTex then I could split into two programs,
      Also I'm going to implement transparency, I am not sure how many program that I needed

      I'm considering to maintain a few default shaders for COMMON profile,
      1-no-texture, 2-one of colorOrTexture contains texture, 3-........

      Any advices in general or about how to optimize/split (if I need) these shaders which I provied as link?
      What do you think the shaders I wrote, I would like to write them without branching if posible,
      I hope I don't need to write 50+ or 100+ shaders, and 100+ default programs

      PS: These default shaders should render any document, they are not specific, they are general purpose...
             I'm compiling and linking default shaders when app launched

      Thanks
    • By CircleOfLight97
      Hi guys,
      I would like to contribute to a game project as a developer (open source possibly). I have some experiences in C/C++ in game development (perso projects). I don't know either unreal or unity but I have some knowledges in opengl, glsl and shading theory as I had some courses at university regarding to that. I have some knowledges in maths and basic in physics. I know a little how to use blender to do modelling, texturing and simple game assets (no characters, no animation no skinning/rigging). I have no game preferences but I like aventure game, dungeon crawler, platformers, randomly generated things. I know these kind of projects involve a lot of time and I'd be really to work on it but if there are no cleary defined specific design goals/stories/gameplay mechanics I would like to not be part of it x) and I would rather prefer a smaller but well defined project to work on that a huge and not 'finishable' one.
      CircleOfLight97
    • By gamesthatcouldbeworse
      Hi, I finally released KILL COMMANDO on gamejolt for free. It is a retro-funsplatter-shooter with C64 style. Give it a try.
  • Popular Now