I want to create complex scenes in my 3D application. Like a house with rooms in it and stuff inside the rooms. I want to remove rooms which are not visible in the camera. I know opengl will clip stuff that are not visible, but I am talking about not sending the data about rooms and objects which are blocked, at all.
So I have heard that for complex scenes a scene grah can help. But most implementation of scene graphs seem to take a hierarchical view of the scene. Say we have a city which is the root node, then the buildings would be its children and the rooms in the buildings would be lower level chidlren etc. This structure does not help in knowing which rooms are adjacent to each other(all adjacent rooms are children of the same parent node).
I came up with this idea for a scene graph where the links between nodes represent the "is adjacent" relationship and the nodes are objects :

The lower part of this picture was added later, please ignore it.for now.
So here we have irregularly shaped rooms. The camera is at the position shown by the red dot. The bounding box(BB) of D is the red border square. As long as the camera is in the red square, the 3D and physics data for B, C & A is loaded. Of course D is there also. But when it moves out of the box to say A, then B & C is unloaded. Also the camera is marked to be "in" A right now.
This saves on texture memory and mesh calls to the graphics API. However a tricky issue is, in a huge graph with many rooms, if I am given a camera position, then I would need to find its owning room by going through all the nodes in the graph which may be prohibitive.
Any objects inside the room D is considered to be adjacent to it as well.If an object is carried outside the room, well then the links are changed to reflect the object's new spatial position with respect to the rooms.
Has anyone got a better suggestion on how to solve this ? Are there open source libraries out there which can do it faster. Especially if I have a camera position and I want to get to the node to which it belongs(is closest to) ?
----------------
The other option as shown in the lower part of the picture, is to combine a hierarchical volume graph and an adjacency graph into one. So we start with a hierarchical graph as shown in the lower part of the image where the root is A and A's children are inside the volume of A. Now if I want to find in which volume the camera is located I can do so in logarithmic time.
However each node(like C) also maintains links to volumes adjacent to it. So I can find and load only adjacent rooms and not the whole darn house !
what do you guys think ?
Edited by altreality, 18 May 2012 - 09:01 PM.










