I'm in a bit frustrating dead end as I try to implement a BVH in my framework mainly for ray tracing and secondary for occlusion culling.
I already have a Scene Node system (a Scene Graph) and it works quite well with animations too. Every SceneNode has local and global transformations, children, and may also have: - A Mesh object that can be rendered. - A surrounding bounding volume (AABB, sphere).
The way I render stuff is as follows:
//global scope
SceneManager manager;
Camera *myCamera;
void init()
{
myCamera = manager.cameraCache()->loadObject("player camera"); //create a camera object and name it "player camera"
SceneNode *rootNode = manager.sceneGraph()->rootSceneNode(); //for fast access
Mesh *mesh = manager.meshCache()->loadObject("skeleton.mesh");
SceneNode *skelNode = rootNode->addChildNode("skeleton node");
manager.attachMeshToSceneNode(skelNode, mesh);
if(iWantToPlayAnAnimation)
manager.animationController()->playAnimation(skelNode, "attack");
}
void render() //this is set as the render method in glut
{
manager.drawFrame(myCamera);
}
As you can see I use scene nodes as "keys" as well for my animationController class. (the key above is skelNode)
Now my problem is that I'm not sure how to mix my scene graph and the new BVH. Can you suggest a good approach on this? Anything else you see wrong in my system?
As a side question:
I'm not even sure BVH is the hierarchy I want. I'm not after any fancy collision detection algorithms for many objects. (just my character).
Is BVH the favorite for this situation?