From 28856e78b6ec2bd8471e32b4c610f6113bf634b2 Mon Sep 17 00:00:00 2001 From: cutealien Date: Wed, 26 Apr 2023 18:52:08 +0000 Subject: [PATCH] CCubeSceneNode can now handle new multi-material cube type git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6472 dfc29bdd-3216-0410-991c-e03cc46cb475 --- source/Irrlicht/CCubeSceneNode.cpp | 44 +++++++++++++++++++----------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/source/Irrlicht/CCubeSceneNode.cpp b/source/Irrlicht/CCubeSceneNode.cpp index 1e882ea6..3bafe21d 100644 --- a/source/Irrlicht/CCubeSceneNode.cpp +++ b/source/Irrlicht/CCubeSceneNode.cpp @@ -76,14 +76,26 @@ void CCubeSceneNode::render() if (Shadow) Shadow->updateShadowVolumes(); - // for debug purposes only: - video::SMaterial mat = Mesh->getMeshBuffer(0)->getMaterial(); - - // overwrite half transparency - if (DebugDataVisible & scene::EDS_HALF_TRANSPARENCY) - mat.MaterialType = video::EMT_TRANSPARENT_ADD_COLOR; - driver->setMaterial(mat); - driver->drawMeshBuffer(Mesh->getMeshBuffer(0)); + for (u32 i=0; igetMeshBufferCount(); ++i) + { + const scene::IMeshBuffer* mb = Mesh->getMeshBuffer(i); + { + // for debug purposes only: + if (DebugDataVisible & scene::EDS_HALF_TRANSPARENCY) + { + // overwrite half transparency + video::SMaterial mat = mb->getMaterial(); + mat.MaterialType = video::EMT_TRANSPARENT_ADD_COLOR; + driver->setMaterial(mat); + } + else + { + const video::SMaterial& mat = mb->getMaterial(); + driver->setMaterial(mat); + } + driver->drawMeshBuffer(mb); + } + } // for debug purposes only: if (DebugDataVisible) @@ -95,21 +107,18 @@ void CCubeSceneNode::render() if (DebugDataVisible & scene::EDS_BBOX) { - driver->draw3DBox(Mesh->getMeshBuffer(0)->getBoundingBox(), video::SColor(255,255,255,255)); + driver->draw3DBox(Mesh->getBoundingBox(), video::SColor(255,255,255,255)); } if (DebugDataVisible & scene::EDS_BBOX_BUFFERS) { - driver->draw3DBox(Mesh->getMeshBuffer(0)->getBoundingBox(), - video::SColor(255,190,128,128)); + driver->draw3DBox(Mesh->getBoundingBox(), video::SColor(255,190,128,128)); } if (DebugDataVisible & scene::EDS_NORMALS) { // draw normals const f32 debugNormalLength = SceneManager->getParameters()->getAttributeAsFloat(DEBUG_NORMAL_LENGTH); const video::SColor debugNormalColor = SceneManager->getParameters()->getAttributeAsColor(DEBUG_NORMAL_COLOR); - const u32 count = Mesh->getMeshBufferCount(); - - for (u32 i=0; i != count; ++i) + for (u32 i=0; i < Mesh->getMeshBufferCount(); ++i) { driver->drawMeshBufferNormals(Mesh->getMeshBuffer(i), debugNormalLength, debugNormalColor); } @@ -121,7 +130,10 @@ void CCubeSceneNode::render() m.Wireframe = true; driver->setMaterial(m); - driver->drawMeshBuffer(Mesh->getMeshBuffer(0)); + for (u32 i=0; i < Mesh->getMeshBufferCount(); ++i) + { + driver->drawMeshBuffer(Mesh->getMeshBuffer(i)); + } } } } @@ -130,7 +142,7 @@ void CCubeSceneNode::render() //! returns the axis aligned bounding box of this node const core::aabbox3d& CCubeSceneNode::getBoundingBox() const { - return Mesh->getMeshBuffer(0)->getBoundingBox(); + return Mesh->getBoundingBox(); }