diff --git a/lib/irrlicht/source/Irrlicht/CAnimatedMeshSceneNode.h b/lib/irrlicht/source/Irrlicht/CAnimatedMeshSceneNode.h index f2c44f432..6b1db9c3b 100644 --- a/lib/irrlicht/source/Irrlicht/CAnimatedMeshSceneNode.h +++ b/lib/irrlicht/source/Irrlicht/CAnimatedMeshSceneNode.h @@ -173,7 +173,7 @@ namespace scene \return The newly created clone of this node. */ virtual ISceneNode* clone(ISceneNode* newParent=0, ISceneManager* newManager=0); - private: + protected: //! Get a static mesh for the current frame of this animated mesh IMesh* getMeshForCurrentFrame(); diff --git a/src/graphics/stkanimatedmesh.cpp b/src/graphics/stkanimatedmesh.cpp index 574bcf358..794c27e19 100644 --- a/src/graphics/stkanimatedmesh.cpp +++ b/src/graphics/stkanimatedmesh.cpp @@ -1,4 +1,7 @@ #include "graphics/stkanimatedmesh.hpp" +#include +#include +#include using namespace irr; @@ -13,5 +16,48 @@ const core::vector3df& scale) : void STKAnimatedMesh::render() { - CAnimatedMeshSceneNode::render(); + video::IVideoDriver* driver = SceneManager->getVideoDriver(); + + bool isTransparentPass = + SceneManager->getSceneNodeRenderPass() == scene::ESNRP_TRANSPARENT; + + ++PassCount; + + scene::IMesh* m = getMeshForCurrentFrame(); + + if (m) + { + Box = m->getBoundingBox(); + } + else + { +#ifdef _DEBUG + os::Printer::log("Animated Mesh returned no mesh to render.", Mesh->getDebugName(), ELL_WARNING); +#endif + } + + driver->setTransform(video::ETS_WORLD, AbsoluteTransformation); + + + // render original meshes + for (u32 i = 0; igetMeshBufferCount(); ++i) + { + video::IMaterialRenderer* rnd = driver->getMaterialRenderer(Materials[i].MaterialType); + bool transparent = (rnd && rnd->isTransparent()); + + // only render transparent buffer if this is the transparent render pass + // and solid only in solid pass + if (transparent == isTransparentPass) + { + scene::IMeshBuffer* mb = m->getMeshBuffer(i); + const video::SMaterial& material = ReadOnlyMaterials ? mb->getMaterial() : Materials[i]; + if (RenderFromIdentity) + driver->setTransform(video::ETS_WORLD, core::IdentityMatrix); + else if (Mesh->getMeshType() == scene::EAMT_SKINNED) + driver->setTransform(video::ETS_WORLD, AbsoluteTransformation * ((scene::SSkinMeshBuffer*)mb)->Transformation); + printf("Material type is %d\n", material.MaterialType); + driver->setMaterial(material); + driver->drawMeshBuffer(mb); + } + } }