Sign in to follow this  
Kasya

Octree System

Recommended Posts

Hello, I am working on an Octree System. I want to know what an octree node needs to have. Thats what i am thinking but i don't know if this will work. So please help me with it:

//These two are for scene graphs and octrees together
class SceneNode {
public:
list<SceneNode *> children;
};

class Object : public SceneNode {
//something inside
};

class OctreeNode : public SceneNode {
public:
BoundingBox box;
};

class Octree {
public:
OctreeNode * root;
};


And about scene graph an octree together. How to implement it ? Like how i did it above: octrees are parents of octrees and objects too:

octree->addChild(oct1,oct2);
octree->addChild(obj1);
oct1->addChild(obj2);
oct2->addChild(oct3);
oct2->addChild(obj4);
//etc...


Thanks, Kasya

Share this post


Link to post
Share on other sites
Quote:

And about scene graph an octree together. How to implement it ? Like how i did it above: octrees are parents of octrees and objects too:


Do you really need to combine your spatial partitioning structure with your scene graph? It will increase the complexitity of your scene graph a lot. Wouldn't it be possible to seperate the two things? So only use the scene graph for your dynamic objects and a seperate octree to partition your geometry? Handling dynamic objects could be made possible by having a seperate loose octree (or whatever) that gets notified and updates itself each time an object moves.

Share this post


Link to post
Share on other sites
It's been a while since I did something involving octrees, so I might not be the best one to ask. At the very least you should keep track of the root of the tree, which you seem to be doing in your Octree. Each node has certain dimensions and either eight or zero (if it's a leaf node) children. It kinda depends on what you want to use your octree for, but in case you want to partition geometry you'll have to store your primitives somewhere too. You can choose to split your geometry so that it fits a leaf node and just render all those primitives when the node is visibible or you can choose to store each primitive in the smallest node it'll fit in (which might not necessarily be a leaf node), which avoids having to split your primitives, but makes rendering a bit harder since you'll have to keep track of which primitives have been drawn in order to avoid drawing the same primitive more than once.

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