#include "IAnimatedMesh.h"\r
#include "IMaterialRenderer.h"\r
#include "IFileSystem.h"\r
-#ifdef _IRR_COMPILE_WITH_SHADOW_VOLUME_SCENENODE_\r
-#include "CShadowVolumeSceneNode.h"\r
-#else\r
-#include "IShadowVolumeSceneNode.h"\r
-#endif // _IRR_COMPILE_WITH_SHADOW_VOLUME_SCENENODE_\r
\r
namespace irr\r
{\r
CMeshSceneNode::CMeshSceneNode(IMesh* mesh, ISceneNode* parent, ISceneManager* mgr, s32 id,\r
const core::vector3df& position, const core::vector3df& rotation,\r
const core::vector3df& scale)\r
-: IMeshSceneNode(parent, mgr, id, position, rotation, scale), Mesh(0), Shadow(0),\r
+: IMeshSceneNode(parent, mgr, id, position, rotation, scale), Mesh(0),\r
PassCount(0), ReadOnlyMaterials(false)\r
{\r
#ifdef _DEBUG\r
//! destructor\r
CMeshSceneNode::~CMeshSceneNode()\r
{\r
- if (Shadow)\r
- Shadow->drop();\r
if (Mesh)\r
Mesh->drop();\r
}\r
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);\r
Box = Mesh->getBoundingBox();\r
\r
- if (Shadow && PassCount==1)\r
- Shadow->updateShadowVolumes();\r
-\r
// for debug purposes only:\r
\r
bool renderMeshes = true;\r
if (DebugDataVisible & scene::EDS_NORMALS)\r
{\r
// draw normals\r
- const f32 debugNormalLength = SceneManager->getParameters()->getAttributeAsFloat(DEBUG_NORMAL_LENGTH);\r
- const video::SColor debugNormalColor = SceneManager->getParameters()->getAttributeAsColor(DEBUG_NORMAL_COLOR);\r
+ const f32 debugNormalLength = 1.f;\r
+ const video::SColor debugNormalColor = video::SColor(255, 34, 221, 221);\r
const u32 count = Mesh->getMeshBufferCount();\r
\r
for (u32 i=0; i != count; ++i)\r
//! or to remove attached childs.\r
bool CMeshSceneNode::removeChild(ISceneNode* child)\r
{\r
- if (child && Shadow == child)\r
- {\r
- Shadow->drop();\r
- Shadow = 0;\r
- }\r
-\r
return ISceneNode::removeChild(child);\r
}\r
\r
}\r
\r
\r
-//! Creates shadow volume scene node as child of this node\r
-//! and returns a pointer to it.\r
-IShadowVolumeSceneNode* CMeshSceneNode::addShadowVolumeSceneNode(\r
- const IMesh* shadowMesh, s32 id, bool zfailmethod, f32 infinity)\r
-{\r
-#ifdef _IRR_COMPILE_WITH_SHADOW_VOLUME_SCENENODE_\r
- if (!SceneManager->getVideoDriver()->queryFeature(video::EVDF_STENCIL_BUFFER))\r
- return 0;\r
-\r
- if (!shadowMesh)\r
- shadowMesh = Mesh; // if null is given, use the mesh of node\r
-\r
- if (Shadow)\r
- Shadow->drop();\r
-\r
- Shadow = new CShadowVolumeSceneNode(shadowMesh, this, SceneManager, id, zfailmethod, infinity);\r
- return Shadow;\r
-#else\r
- return 0;\r
-#endif\r
-}\r
-\r
-\r
void CMeshSceneNode::copyMaterials()\r
{\r
Materials.clear();\r
}\r
\r
\r
-//! Writes attributes of the scene node.\r
-void CMeshSceneNode::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const\r
-{\r
- IMeshSceneNode::serializeAttributes(out, options);\r
-\r
- if (options && (options->Flags&io::EARWF_USE_RELATIVE_PATHS) && options->Filename)\r
- {\r
- const io::path path = SceneManager->getFileSystem()->getRelativeFilename(\r
- SceneManager->getFileSystem()->getAbsolutePath(SceneManager->getMeshCache()->getMeshName(Mesh).getPath()),\r
- options->Filename);\r
- out->addString("Mesh", path.c_str());\r
- }\r
- else\r
- out->addString("Mesh", SceneManager->getMeshCache()->getMeshName(Mesh).getPath().c_str());\r
- out->addBool("ReadOnlyMaterials", ReadOnlyMaterials);\r
-}\r
-\r
-\r
-//! Reads attributes of the scene node.\r
-void CMeshSceneNode::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options)\r
-{\r
- io::path oldMeshStr = SceneManager->getMeshCache()->getMeshName(Mesh);\r
- io::path newMeshStr = in->getAttributeAsString("Mesh");\r
- ReadOnlyMaterials = in->getAttributeAsBool("ReadOnlyMaterials");\r
-\r
- if (newMeshStr != "" && oldMeshStr != newMeshStr)\r
- {\r
- IMesh* newMesh = 0;\r
- IAnimatedMesh* newAnimatedMesh = SceneManager->getMesh(newMeshStr.c_str());\r
-\r
- if (newAnimatedMesh)\r
- newMesh = newAnimatedMesh->getMesh(0);\r
-\r
- if (newMesh)\r
- setMesh(newMesh);\r
- }\r
-\r
- // optional attribute to assign the hint to the whole mesh\r
- if (in->existsAttribute("HardwareMappingHint") &&\r
- in->existsAttribute("HardwareMappingBufferType"))\r
- {\r
- scene::E_HARDWARE_MAPPING mapping = scene::EHM_NEVER;\r
- scene::E_BUFFER_TYPE bufferType = scene::EBT_NONE;\r
-\r
- core::stringc smapping = in->getAttributeAsString("HardwareMappingHint");\r
- if (smapping.equals_ignore_case("static"))\r
- mapping = scene::EHM_STATIC;\r
- else if (smapping.equals_ignore_case("dynamic"))\r
- mapping = scene::EHM_DYNAMIC;\r
- else if (smapping.equals_ignore_case("stream"))\r
- mapping = scene::EHM_STREAM;\r
-\r
- core::stringc sbufferType = in->getAttributeAsString("HardwareMappingBufferType");\r
- if (sbufferType.equals_ignore_case("vertex"))\r
- bufferType = scene::EBT_VERTEX;\r
- else if (sbufferType.equals_ignore_case("index"))\r
- bufferType = scene::EBT_INDEX;\r
- else if (sbufferType.equals_ignore_case("vertexindex"))\r
- bufferType = scene::EBT_VERTEX_AND_INDEX;\r
-\r
- IMesh* mesh = getMesh();\r
- if (mesh)\r
- mesh->setHardwareMappingHint(mapping, bufferType);\r
- }\r
-\r
- IMeshSceneNode::deserializeAttributes(in, options);\r
-}\r
-\r
-\r
//! Sets if the scene node should not copy the materials of the mesh but use them in a read only style.\r
/* In this way it is possible to change the materials a mesh causing all mesh scene nodes\r
referencing this mesh to change too. */\r
nb->cloneMembers(this, newManager);\r
nb->ReadOnlyMaterials = ReadOnlyMaterials;\r
nb->Materials = Materials;\r
- nb->Shadow = Shadow;\r
- if ( nb->Shadow )\r
- nb->Shadow->grab();\r
\r
if (newParent)\r
nb->drop();\r