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
This commit is contained in:
cutealien 2023-04-26 18:52:08 +00:00
parent e55af78b31
commit 28856e78b6

View File

@ -76,14 +76,26 @@ void CCubeSceneNode::render()
if (Shadow) if (Shadow)
Shadow->updateShadowVolumes(); Shadow->updateShadowVolumes();
// for debug purposes only: for (u32 i=0; i<Mesh->getMeshBufferCount(); ++i)
video::SMaterial mat = Mesh->getMeshBuffer(0)->getMaterial(); {
const scene::IMeshBuffer* mb = Mesh->getMeshBuffer(i);
// overwrite half transparency {
if (DebugDataVisible & scene::EDS_HALF_TRANSPARENCY) // for debug purposes only:
mat.MaterialType = video::EMT_TRANSPARENT_ADD_COLOR; if (DebugDataVisible & scene::EDS_HALF_TRANSPARENCY)
driver->setMaterial(mat); {
driver->drawMeshBuffer(Mesh->getMeshBuffer(0)); // 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: // for debug purposes only:
if (DebugDataVisible) if (DebugDataVisible)
@ -95,21 +107,18 @@ void CCubeSceneNode::render()
if (DebugDataVisible & scene::EDS_BBOX) 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) if (DebugDataVisible & scene::EDS_BBOX_BUFFERS)
{ {
driver->draw3DBox(Mesh->getMeshBuffer(0)->getBoundingBox(), driver->draw3DBox(Mesh->getBoundingBox(), video::SColor(255,190,128,128));
video::SColor(255,190,128,128));
} }
if (DebugDataVisible & scene::EDS_NORMALS) if (DebugDataVisible & scene::EDS_NORMALS)
{ {
// draw normals // draw normals
const f32 debugNormalLength = SceneManager->getParameters()->getAttributeAsFloat(DEBUG_NORMAL_LENGTH); const f32 debugNormalLength = SceneManager->getParameters()->getAttributeAsFloat(DEBUG_NORMAL_LENGTH);
const video::SColor debugNormalColor = SceneManager->getParameters()->getAttributeAsColor(DEBUG_NORMAL_COLOR); const video::SColor debugNormalColor = SceneManager->getParameters()->getAttributeAsColor(DEBUG_NORMAL_COLOR);
const u32 count = Mesh->getMeshBufferCount(); for (u32 i=0; i < Mesh->getMeshBufferCount(); ++i)
for (u32 i=0; i != count; ++i)
{ {
driver->drawMeshBufferNormals(Mesh->getMeshBuffer(i), debugNormalLength, debugNormalColor); driver->drawMeshBufferNormals(Mesh->getMeshBuffer(i), debugNormalLength, debugNormalColor);
} }
@ -121,7 +130,10 @@ void CCubeSceneNode::render()
m.Wireframe = true; m.Wireframe = true;
driver->setMaterial(m); 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 //! returns the axis aligned bounding box of this node
const core::aabbox3d<f32>& CCubeSceneNode::getBoundingBox() const const core::aabbox3d<f32>& CCubeSceneNode::getBoundingBox() const
{ {
return Mesh->getMeshBuffer(0)->getBoundingBox(); return Mesh->getBoundingBox();
} }