Derive COctTreeSceneNode from IMeshSceneNode instead ISceneNode, and have it return the IMesh that was used to create its octtree. Tested with a slightly modified example 07. git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2173 dfc29bdd-3216-0410-991c-e03cc46cb475master
parent
0e00187fdd
commit
bd192519d6
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue