Octree System

Started by
2 comments, last by johand_ 14 years, 10 months ago
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
Advertisement
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.
i understand what you mean. Thanks for help.
what about the octree system itself. Is it correct implementation?

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

This topic is closed to new replies.

Advertisement