diff --git a/changes.txt b/changes.txt index 08d65fc3..ea3b40aa 100644 --- a/changes.txt +++ b/changes.txt @@ -463,6 +463,8 @@ Changes in version 1.6, TA Changes in version 1.6 + - Octtree scene nodes are now IMeshSceneNodes rather than ISceneNodes, and so you can call getMesh() on them. + - New scene parameter B3D_LOADER_IGNORE_MIPMAP_FLAG to ignore the often missing mipmap flag in b3d files. If this parameter is true, the old pre Irrlicht-1.5 behavior is restored. - Added Mipmap LOD Bias attribute to MaterialLayer. diff --git a/examples/07.Collision/main.cpp b/examples/07.Collision/main.cpp index 8b39924a..62aabfb1 100644 --- a/examples/07.Collision/main.cpp +++ b/examples/07.Collision/main.cpp @@ -59,7 +59,7 @@ int main() device->getFileSystem()->addZipFileArchive("../../media/map-20kdm2.pk3"); scene::IAnimatedMesh* q3levelmesh = smgr->getMesh("20kdm2.bsp"); - scene::ISceneNode* q3node = 0; + scene::IMeshSceneNode* q3node = 0; if (q3levelmesh) q3node = smgr->addOctTreeSceneNode(q3levelmesh->getMesh(0)); @@ -88,7 +88,7 @@ int main() q3node->setPosition(core::vector3df(-1350,-130,-1400)); selector = smgr->createOctTreeTriangleSelector( - q3levelmesh->getMesh(0), q3node, 128); + q3node->getMesh(), q3node, 128); q3node->setTriangleSelector(selector); } diff --git a/include/IMeshSceneNode.h b/include/IMeshSceneNode.h index 77fc9ba2..41206315 100644 --- a/include/IMeshSceneNode.h +++ b/include/IMeshSceneNode.h @@ -24,9 +24,9 @@ public: /** Use setMesh() to set the mesh to display. */ IMeshSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, - const core::vector3df& position, - const core::vector3df& rotation, - const core::vector3df& scale) + const core::vector3df& position = core::vector3df(0,0,0), + const core::vector3df& rotation = core::vector3df(0,0,0), + const core::vector3df& scale = core::vector3df(1,1,1)) : ISceneNode(parent, mgr, id, position, rotation, scale) {} //! Sets a new mesh to display diff --git a/include/ISceneManager.h b/include/ISceneManager.h index 3f9dfcd2..0958b6ca 100644 --- a/include/ISceneManager.h +++ b/include/ISceneManager.h @@ -496,7 +496,7 @@ namespace scene \param alsoAddIfMeshPointerZero: Add the scene node even if a 0 pointer is passed. \return Pointer to the OctTree if successful, otherwise 0. This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ - virtual ISceneNode* addOctTreeSceneNode(IAnimatedMesh* mesh, ISceneNode* parent=0, + virtual IMeshSceneNode* addOctTreeSceneNode(IAnimatedMesh* mesh, ISceneNode* parent=0, s32 id=-1, s32 minimalPolysPerNode=512, bool alsoAddIfMeshPointerZero=false) = 0; //! Adds a scene node for rendering using a octtree to the scene graph. @@ -512,7 +512,7 @@ namespace scene \param alsoAddIfMeshPointerZero: Add the scene node even if a 0 pointer is passed. \return Pointer to the octtree if successful, otherwise 0. This pointer should not be dropped. See IReferenceCounted::drop() for more information. */ - virtual ISceneNode* addOctTreeSceneNode(IMesh* mesh, ISceneNode* parent=0, + virtual IMeshSceneNode* addOctTreeSceneNode(IMesh* mesh, ISceneNode* parent=0, s32 id=-1, s32 minimalPolysPerNode=256, bool alsoAddIfMeshPointerZero=false) = 0; //! Adds a camera scene node to the scene graph and sets it as active camera. diff --git a/source/Irrlicht/COctTreeSceneNode.cpp b/source/Irrlicht/COctTreeSceneNode.cpp index e45c5a54..29a24aac 100644 --- a/source/Irrlicht/COctTreeSceneNode.cpp +++ b/source/Irrlicht/COctTreeSceneNode.cpp @@ -22,8 +22,8 @@ namespace scene //! constructor COctTreeSceneNode::COctTreeSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id, s32 minimalPolysPerNode) -: ISceneNode(parent, mgr, id), StdOctTree(0), LightMapOctTree(0), TangentsOctTree(0), - MinimalPolysPerNode(minimalPolysPerNode) +: IMeshSceneNode(parent, mgr, id), StdOctTree(0), LightMapOctTree(0), TangentsOctTree(0), + MinimalPolysPerNode(minimalPolysPerNode), Mesh(0) { #ifdef _DEBUG setDebugName("COctTreeSceneNode"); @@ -279,6 +279,9 @@ bool COctTreeSceneNode::createTree(IMesh* mesh) deleteTree(); + Mesh = mesh; + Mesh->grab(); + u32 beginTime = os::Timer::getRealTime(); u32 nodeCount = 0; @@ -486,8 +489,32 @@ void COctTreeSceneNode::deleteTree() TangentsMeshes.clear(); Materials.clear(); + + if(Mesh) + Mesh->drop(); } +void COctTreeSceneNode::setMesh(IMesh* mesh) +{ + createTree(mesh); +} + +IMesh* COctTreeSceneNode::getMesh(void) +{ + return Mesh; +} + +void COctTreeSceneNode::setReadOnlyMaterials(bool readonly) +{ + // Do nothing +} + +bool COctTreeSceneNode::isReadOnlyMaterials() const +{ + return false; +} + + } // end namespace scene } // end namespace irr diff --git a/source/Irrlicht/COctTreeSceneNode.h b/source/Irrlicht/COctTreeSceneNode.h index d5d71511..076a617e 100644 --- a/source/Irrlicht/COctTreeSceneNode.h +++ b/source/Irrlicht/COctTreeSceneNode.h @@ -5,8 +5,7 @@ #ifndef __C_OCT_TREE_SCENE_NODE_H_INCLUDED__ #define __C_OCT_TREE_SCENE_NODE_H_INCLUDED__ -#include "ISceneNode.h" -#include "IMesh.h" +#include "IMeshSceneNode.h" #include "OctTree.h" namespace irr @@ -14,7 +13,7 @@ namespace irr namespace scene { //! implementation of the IBspTreeSceneNode - class COctTreeSceneNode : public ISceneNode + class COctTreeSceneNode : public IMeshSceneNode { public: @@ -55,6 +54,18 @@ namespace scene //! Returns type of the scene node virtual ESCENE_NODE_TYPE getType() const { return ESNT_OCT_TREE; } + //! Sets a new mesh to display + virtual void setMesh(IMesh* mesh); + + //! Get the currently defined mesh for display. + virtual IMesh* getMesh(void); + + //! Sets if the scene node should not copy the materials of the mesh but use them in a read only style. + virtual void setReadOnlyMaterials(bool readonly); + + //! Check if the scene node should not copy the materials of the mesh but use them in a read only style + virtual bool isReadOnlyMaterials() const; + private: void deleteTree(); @@ -76,6 +87,8 @@ namespace scene core::stringc MeshName; s32 MinimalPolysPerNode; s32 PassCount; + + IMesh * Mesh; }; } // end namespace scene diff --git a/source/Irrlicht/CSceneManager.cpp b/source/Irrlicht/CSceneManager.cpp index 6c8c49fc..cd6f7833 100644 --- a/source/Irrlicht/CSceneManager.cpp +++ b/source/Irrlicht/CSceneManager.cpp @@ -589,7 +589,7 @@ IAnimatedMeshSceneNode* CSceneManager::addAnimatedMeshSceneNode(IAnimatedMesh* m //! Adds a scene node for rendering using a octtree to the scene graph. This a good method for rendering //! scenes with lots of geometry. The Octree is built on the fly from the mesh, much //! faster then a bsp tree. -ISceneNode* CSceneManager::addOctTreeSceneNode(IAnimatedMesh* mesh, ISceneNode* parent, +IMeshSceneNode* CSceneManager::addOctTreeSceneNode(IAnimatedMesh* mesh, ISceneNode* parent, s32 id, s32 minimalPolysPerNode, bool alsoAddIfMeshPointerZero) { if (!alsoAddIfMeshPointerZero && (!mesh || !mesh->getFrameCount())) @@ -601,10 +601,10 @@ ISceneNode* CSceneManager::addOctTreeSceneNode(IAnimatedMesh* mesh, ISceneNode* } -//! Adss a scene node for rendering using a octtree. This a good method for rendering +//! Adds a scene node for rendering using a octtree. This a good method for rendering //! scenes with lots of geometry. The Octree is built on the fly from the mesh, much //! faster then a bsp tree. -ISceneNode* CSceneManager::addOctTreeSceneNode(IMesh* mesh, ISceneNode* parent, +IMeshSceneNode* CSceneManager::addOctTreeSceneNode(IMesh* mesh, ISceneNode* parent, s32 id, s32 minimalPolysPerNode, bool alsoAddIfMeshPointerZero) { if (!alsoAddIfMeshPointerZero && !mesh) diff --git a/source/Irrlicht/CSceneManager.h b/source/Irrlicht/CSceneManager.h index 1614a2b0..3c7a8a6a 100644 --- a/source/Irrlicht/CSceneManager.h +++ b/source/Irrlicht/CSceneManager.h @@ -111,13 +111,13 @@ namespace scene //! Adds a scene node for rendering using a octtree to the scene graph. This a good method for rendering //! scenes with lots of geometry. The Octree is built on the fly from the mesh, much //! faster then a bsp tree. - virtual ISceneNode* addOctTreeSceneNode(IAnimatedMesh* mesh, ISceneNode* parent=0, + virtual IMeshSceneNode* addOctTreeSceneNode(IAnimatedMesh* mesh, ISceneNode* parent=0, s32 id=-1, s32 minimalPolysPerNode=512, bool alsoAddIfMeshPointerZero=false); //! Adss a scene node for rendering using a octtree. This a good method for rendering //! scenes with lots of geometry. The Octree is built on the fly from the mesh, much //! faster then a bsp tree. - virtual ISceneNode* addOctTreeSceneNode(IMesh* mesh, ISceneNode* parent=0, + virtual IMeshSceneNode* addOctTreeSceneNode(IMesh* mesh, ISceneNode* parent=0, s32 id=-1, s32 minimalPolysPerNode=128, bool alsoAddIfMeshPointerZero=false); //! Adds a camera scene node to the tree and sets it as active camera.