1
// Copyright (C) 2002-2011 Nikolaus Gebhardt
2
// This file is part of the "Irrlicht Engine".
3
// For conditions of distribution and use, see copyright notice in irrlicht.h
5
#ifndef __C_SHADOW_VOLUME_SCENE_NODE_H_INCLUDED__
6
#define __C_SHADOW_VOLUME_SCENE_NODE_H_INCLUDED__
8
#include "IShadowVolumeSceneNode.h"
15
//! Scene node for rendering a shadow volume into a stencil buffer.
16
class CShadowVolumeSceneNode : public IShadowVolumeSceneNode
21
CShadowVolumeSceneNode(const IMesh* shadowMesh, ISceneNode* parent, ISceneManager* mgr,
22
s32 id, bool zfailmethod=true, f32 infinity=10000.0f);
25
virtual ~CShadowVolumeSceneNode();
27
//! Sets the mesh from which the shadow volume should be generated.
28
/** To optimize shadow rendering, use a simpler mesh for shadows.
30
virtual void setShadowMesh(const IMesh* mesh);
32
//! Updates the shadow volumes for current light positions.
33
virtual void updateShadowVolumes();
36
virtual void OnRegisterSceneNode();
39
virtual void render();
41
//! returns the axis aligned bounding box of this node
42
virtual const core::aabbox3d<f32>& getBoundingBox() const;
44
//! Returns type of the scene node
45
virtual ESCENE_NODE_TYPE getType() const { return ESNT_SHADOW_VOLUME; }
49
typedef core::array<core::vector3df> SShadowVolume;
51
void createShadowVolume(const core::vector3df& pos);
52
void createZPassVolume(s32 faceCount, u32& numEdges, core::vector3df light, SShadowVolume* svp, bool caps);
53
void createZFailVolume(s32 faceCount, u32& numEdges, const core::vector3df& light, SShadowVolume* svp);
55
//! Generates adjacency information based on mesh indices.
56
void calculateAdjacency();
58
core::aabbox3d<f32> Box;
60
// a shadow volume for every light
61
core::array<SShadowVolume> ShadowVolumes;
63
core::array<core::vector3df> Vertices;
64
core::array<u16> Indices;
65
core::array<u16> Adjacency;
66
core::array<u16> Edges;
67
// used for zfail method, if face is front facing
68
core::array<bool> FaceData;
70
const scene::IMesh* ShadowMesh;
75
u32 ShadowVolumesUsed;
82
} // end namespace scene
83
} // end namespace irr