Wrapping my head around SceneGraphs

Started by
2 comments, last by smitty1276 13 years, 11 months ago
Scene graphs. They make my brain hurt. I require someone to comment on my design. I understand that a Scene graph is a generic logical representation of objects in relation to one another. A scene graph is not used for culling, nor is it used for spacial awareness. It's not used for render sorting. So, knowing that, I have made up a series of subsystems that covers the above areas, which are all separate of one another. Here is what it looks like (pseudocode): State: - Contains a RenderTargetPtr - Contains a ShaderPtr - Contains a TechniqueID - Contains a map of shader parameters and their values (before application) - Contains Vertex and Index buffers - has function Render(MyRenderer &myRenderer) --- Applies RenderTarget, Shader, Technique, Parameters and Buffers --- MyRenderer holds the last 'state', to minimize unnecessary state changes SceneObject: - Contains a 'pose' (myPoseMat4x4) - Contains a pointer to a State - Contains a list of children (Other SceneObjects) - OnUpdate(Mat4x4 &parentMat4x4, Mat4x4 &camProjMat4x4) --- State->SetParameter("someShaderParam", parentMat4x4 * myPoseMat4x4 * camProjMat4x4); --- for_each(children) child->OnUpdate(parentMat4x4 * myPose4x4, camProjMat4x4); TransformationGraph: - Contains a list of SceneObjects at root level - OnUpdate(Camera &myCamera) --- Loop through all nodes and call OnUpdate(myCamera->getWorldMat(), myCamera->getProjMat); RenderGraph: - Contains a list of States - has a function Update() which sorts the states - has a function Add(State &) which sorts the new state into the list - OnRender(MyRenderer &myRenderer) --- for_each(State in StateList) State->render(myRenderer); This is how far I got. What I'm stuck on is how does one do culling when your data is in the structure above? Assume I'm using an Octree for simplicity. I'm not tied down to this structure, so if you have better ideas, please post them. Thanks!
------------Anything prior to 9am should be illegal.
Advertisement
You have your transformation matrices for your camera, so you can determine the view frustum from there and use frustum culling.

http://www.flipcode.com/archives/Frustum_Culling.shtml

WAIT: I misunderstood what you were asking... do your scene objects not have some bounding volume, or are they not stored in your octree?
What I'm asking is how does an Octree fit into here. I guess I add an IsVisisble member to the SceneObject which would ignore the entire node if the Octree deems that it is outside the bounds of the Frustum. I guess in that case the SceneObject would need a bounding Volume of some sort, probably an AABB.

------------Anything prior to 9am should be illegal.
That sounds roughly like what I would do... each SceneObject is associated with the smallest bounding volume in the octree that holds it. If you keep a pointer to the object's octant in the object itself, you could do...

if (sceneObject.Octant.IsVisible) Draw(sceneObject)


This topic is closed to new replies.

Advertisement