--- /dev/null
+// Copyright (C) 2002-2012 Nikolaus Gebhardt\r
+// This file is part of the "Irrlicht Engine".\r
+// For conditions of distribution and use, see copyright notice in irrlicht.h\r
+\r
+#ifndef IRR_C_SHADOW_VOLUME_SCENE_NODE_H_INCLUDED\r
+#define IRR_C_SHADOW_VOLUME_SCENE_NODE_H_INCLUDED\r
+\r
+#include "IShadowVolumeSceneNode.h"\r
+\r
+namespace irr\r
+{\r
+namespace scene\r
+{\r
+\r
+ //! Scene node for rendering a shadow volume into a stencil buffer.\r
+ class CShadowVolumeSceneNode : public IShadowVolumeSceneNode\r
+ {\r
+ public:\r
+\r
+ //! constructor\r
+ CShadowVolumeSceneNode(const IMesh* shadowMesh, ISceneNode* parent, ISceneManager* mgr,\r
+ s32 id, bool zfailmethod=true, f32 infinity=10000.0f);\r
+\r
+ //! destructor\r
+ virtual ~CShadowVolumeSceneNode();\r
+\r
+ //! Sets the mesh from which the shadow volume should be generated.\r
+ /** To optimize shadow rendering, use a simpler mesh for shadows.\r
+ */\r
+ virtual void setShadowMesh(const IMesh* mesh) override;\r
+\r
+ //! Updates the shadow volumes for current light positions.\r
+ /** Called each render cycle from Animated Mesh SceneNode render method. */\r
+ virtual void updateShadowVolumes() override;\r
+\r
+ //! Set optimization used to create shadow volumes\r
+ /** Default is ESV_SILHOUETTE_BY_POS. If the shadow \r
+ looks bad then give ESV_NONE a try (which will be slower). */\r
+ virtual void setOptimization(ESHADOWVOLUME_OPTIMIZATION optimization) override;\r
+\r
+ //! Get currently active optimization used to create shadow volumes\r
+ virtual ESHADOWVOLUME_OPTIMIZATION getOptimization() const override\r
+ {\r
+ return Optimization;\r
+ }\r
+\r
+ //! pre render method\r
+ virtual void OnRegisterSceneNode() override;\r
+\r
+ //! renders the node.\r
+ virtual void render() override;\r
+\r
+ //! returns the axis aligned bounding box of this node\r
+ virtual const core::aabbox3d<f32>& getBoundingBox() const override;\r
+\r
+ //! Returns type of the scene node\r
+ virtual ESCENE_NODE_TYPE getType() const override { return ESNT_SHADOW_VOLUME; }\r
+\r
+ private:\r
+\r
+ typedef core::array<core::vector3df> SShadowVolume;\r
+\r
+ void createShadowVolume(const core::vector3df& pos, bool isDirectional);\r
+ u32 createEdgesAndCaps(const core::vector3df& light, bool isDirectional, SShadowVolume* svp, core::aabbox3d<f32>* bb);\r
+\r
+ //! Generates adjacency information based on mesh indices.\r
+ void calculateAdjacency();\r
+\r
+ core::aabbox3d<f32> Box;\r
+\r
+ // a shadow volume for every light\r
+ core::array<SShadowVolume> ShadowVolumes;\r
+\r
+ // a back cap bounding box for every light\r
+ core::array<core::aabbox3d<f32> > ShadowBBox;\r
+\r
+ core::array<core::vector3df> Vertices;\r
+ core::array<u16> Indices;\r
+ core::array<u16> Adjacency;\r
+ core::array<u16> Edges;\r
+ // tells if face is front facing\r
+ std::vector<bool> FaceData;\r
+ bool AdjacencyDirtyFlag;\r
+\r
+ const scene::IMesh* ShadowMesh;\r
+\r
+ u32 IndexCount;\r
+ u32 VertexCount;\r
+ u32 ShadowVolumesUsed;\r
+\r
+ f32 Infinity;\r
+ bool UseZFailMethod;\r
+ ESHADOWVOLUME_OPTIMIZATION Optimization;\r
+ };\r
+\r
+} // end namespace scene\r
+} // end namespace irr\r
+\r
+#endif\r