I created an IrrEdit scene with an octree scene node. The problem is that I want to retrieve its mesh. I tried exactly as in tutorial 15, but it failed at runtime because the node can't be cast to an IMeshSceneNode.
Any ideas why the tutorial is wrong? It would be good if there was a common base class for all geometric scene nodes, then triangle selectors could be created directly from them. IMeshSceneNode, IAnimatedMeshSceneNode and IOctreeSceneNode would inherit from, let's say, IGeometricSceneNode, then a triangle selector could be created directly from any IGeometricSceneNode without necessarily requiring the original mesh from which the geometric scene node was loaded.
The Octree does not have an IMesh base, hence it cannot be used as an IMeshSceneNode directly. However, getMesh should return an IMesh with which you can work.
The common base is not that easily possible, because we need to know the exact type and act depending on the actual implementation behind the interface.
hybrid wrote:The Octree does not have an IMesh base, hence it cannot be used as an IMeshSceneNode directly. However, getMesh should return an IMesh with which you can work.
The common base is not that easily possible, because we need to know the exact type and act depending on the actual implementation behind the interface.
Presumably the IMesh passed to COctTreeSceneNode::createTree(IMesh* mesh) is going to come from an octtree, so can we just derive COctTreeSceneNode from IMeshSceneNode, store the provided IMesh and return it in getMesh()? Looking at example 7, we're building the oct tree triangle selector from the same mesh that we're buildling the oct tree scene node from, so I'm not sure that we need to do anything other than store the IMesh given to createTree().
I've got that implemented locally, and tested with a slightly modified example 07 (and example 15 should work with its current code). Is there anything obvious that I'm missing?
I'm not sure if getMesh would have to return the octree organized mesh, or the original mesh. For now, it would probably be sufficient to return the original mesh.
So it looks like we're just using whatever mesh data is in the IMesh that's got from loading the .bsp. I've just stored a reference to that IMesh in the COctTreeSceneNode so that it can be recovered later.