~baltix/+junk/irrlicht-test

« back to all changes in this revision

Viewing changes to source/Irrlicht/CShadowVolumeSceneNode.h

  • Committer: Mantas Kriaučiūnas
  • Date: 2011-07-18 13:06:25 UTC
  • Revision ID: mantas@akl.lt-20110718130625-c5pvifp61e7kj1ol
Included whole irrlicht SVN libraries to work around launchpad recipe issue with quilt, see https://answers.launchpad.net/launchpad/+question/165193

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
4
 
 
5
#ifndef __C_SHADOW_VOLUME_SCENE_NODE_H_INCLUDED__
 
6
#define __C_SHADOW_VOLUME_SCENE_NODE_H_INCLUDED__
 
7
 
 
8
#include "IShadowVolumeSceneNode.h"
 
9
 
 
10
namespace irr
 
11
{
 
12
namespace scene
 
13
{
 
14
 
 
15
        //! Scene node for rendering a shadow volume into a stencil buffer.
 
16
        class CShadowVolumeSceneNode : public IShadowVolumeSceneNode
 
17
        {
 
18
        public:
 
19
 
 
20
                //! constructor
 
21
                CShadowVolumeSceneNode(const IMesh* shadowMesh, ISceneNode* parent, ISceneManager* mgr, 
 
22
                        s32 id,  bool zfailmethod=true, f32 infinity=10000.0f);
 
23
 
 
24
                //! destructor
 
25
                virtual ~CShadowVolumeSceneNode();
 
26
 
 
27
                //! Sets the mesh from which the shadow volume should be generated.
 
28
                /** To optimize shadow rendering, use a simpler mesh for shadows.
 
29
                */
 
30
                virtual void setShadowMesh(const IMesh* mesh);
 
31
 
 
32
                //! Updates the shadow volumes for current light positions.
 
33
                virtual void updateShadowVolumes();
 
34
 
 
35
                //! pre render method
 
36
                virtual void OnRegisterSceneNode();
 
37
 
 
38
                //! renders the node.
 
39
                virtual void render();
 
40
 
 
41
                //! returns the axis aligned bounding box of this node
 
42
                virtual const core::aabbox3d<f32>& getBoundingBox() const;
 
43
 
 
44
                //! Returns type of the scene node
 
45
                virtual ESCENE_NODE_TYPE getType() const { return ESNT_SHADOW_VOLUME; }
 
46
 
 
47
        private:
 
48
 
 
49
                typedef core::array<core::vector3df> SShadowVolume;
 
50
 
 
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);
 
54
 
 
55
                //! Generates adjacency information based on mesh indices.
 
56
                void calculateAdjacency();
 
57
 
 
58
                core::aabbox3d<f32> Box;
 
59
 
 
60
                // a shadow volume for every light
 
61
                core::array<SShadowVolume> ShadowVolumes;
 
62
 
 
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;
 
69
 
 
70
                const scene::IMesh* ShadowMesh;
 
71
 
 
72
                u32 IndexCount;
 
73
                u32 VertexCount;
 
74
 
 
75
                u32 ShadowVolumesUsed;
 
76
 
 
77
                f32 Infinity;
 
78
 
 
79
                bool UseZFailMethod;
 
80
        };
 
81
 
 
82
} // end namespace scene
 
83
} // end namespace irr
 
84
 
 
85
#endif