Organizing world data

Post your questions, suggestions and experiences regarding game design, integration of external libraries here. For irrEdit, irrXML and irrKlang, see the
ambiera forums
Post Reply
RustyNail
Posts: 168
Joined: Fri Jun 02, 2006 1:49 pm
Contact:

Organizing world data

Post by RustyNail »

How wonderful it is to be back here after so much time ^_^.

Anyway, i've been writing a simple OpenGL 3D engine, and have come to a rather large problem:
I need to organize all my world/entity data into bite-sized chunks, and render only the ones that a visible. The best part is, that I have no idea what-so-ever on how to do it. :oops:

What methods would you recommend, and how would I go about implementing it ? :?:
Vsk
Posts: 343
Joined: Thu Sep 27, 2007 4:43 pm

Post by Vsk »

Some scene graph + some space structure for the leaves of the graph.
The space structre could be an octree or BSP.

check for irrlicht code :D. I think you will find some ideas.
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post by MasterGod »

Vsk wrote:Some scene graph + some space structure for the leaves of the graph.
The space structre could be an octree or BSP.

check for irrlicht code :D. I think you will find some ideas.
Continuing what he said, Learn the data structure, understand its pros and cons then implement your own version of that same design.
You can learn the design from the Irrlicht sources, you'd like to check:
/include:
ISceneNode.h
ISceneManager.h
/source/Irrlicht:
CSceneManager.h
CSceneManager.cpp

Edit:
It might help a bit: http://irrlicht.sourceforge.net/phpBB2/ ... p?p=145307
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
RustyNail
Posts: 168
Joined: Fri Jun 02, 2006 1:49 pm
Contact:

Post by RustyNail »

Hmmm... never thought of looking at Irrlicht's code :?
I'll have to take a look at it...
Anyway. I am currently attempting to implement an Octree for the geometry...
In my class cOctreeNode, i have a static function BuildOctree that traverses through my loaded world, and builds a bounding box around the world, storing all that info into a scene node called 'root'.
It then shall check if 'root' contains more that N triangles, and if it does, it calls root's member function subdivide, which generates 8 more scene nodes, storing pointers to them in root's children array...
And so it continues, until each node has less than X triangles.

Okay, i know, this implementation sucks, but it's the best i could think of on my own... BTW, all the scene nodes are linked view pointers to their parent, and to 8 children nodes...

:shock: Did I just write that? :shock:
RustyNail
Posts: 168
Joined: Fri Jun 02, 2006 1:49 pm
Contact:

Post by RustyNail »

My way failed :-/
After several hours of digging through arrays of pointers to pointers, i gave up. 8)
Guess it's time too look through the Irrlicht code... :roll:
RustyNail
Posts: 168
Joined: Fri Jun 02, 2006 1:49 pm
Contact:

Post by RustyNail »

I've Implemented a simple scene graph, but now i have a little problem...
All the objects must be children of the Camera class for them to NOT be drawn at the origin.
Out of this come two questions:
1. How do I avoid this &
2. Does my camera class need rewriting.
:roll:
The camera works through Translating & Rotating the world around itself...

Ugh. I'm a newb.... ><
agi_shi
Posts: 122
Joined: Mon Feb 26, 2007 12:46 am

Post by agi_shi »

RustyNail wrote:I've Implemented a simple scene graph, but now i have a little problem...
All the objects must be children of the Camera class for them to NOT be drawn at the origin.
Out of this come two questions:
1. How do I avoid this &
2. Does my camera class need rewriting.
:roll:
The camera works through Translating & Rotating the world around itself...

Ugh. I'm a newb.... ><
OpenGL uses a combined view/model matrix. Just keep a copy of the current view/model matrix separately. When the view or model matrix changes, multiple it with the other "stored" matrix (for example, if the view changes, multiple it with the stored world matrix) and do glLoadMatrix on MODELVIEW.
RustyNail
Posts: 168
Joined: Fri Jun 02, 2006 1:49 pm
Contact:

Post by RustyNail »

:) Thanks!

The only problem now, is that I'm not quite up to par with my matrix math... :lol:
ugh. Time to bring out that huge math encyclopedia I have somewhere... 8)
RustyNail
Posts: 168
Joined: Fri Jun 02, 2006 1:49 pm
Contact:

Post by RustyNail »

8) I've found a different way of achieving my goal:
I just removed the glPushMatrix(); and glPopMatrix(); calls when I rotate & translate the world with the camera :lol:
So now all my objects don't have to be children of the camera; with the exception of the skybox...
I have recently discovered that both the Flu and my Algebra teacher have exact the same effect on my health: it quickly degrades.
Post Reply