All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
EffectHandler.h
1 // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
2 
3 #pragma once
4 
5 #include "Types.h"
6 #include "VectorMath.h"
7 #include "Rendering.h"
8 #include "Lighting.h"
9 
10 #include <vector>
11 
12 #define EFFECTMANAGER_MAX_EFFECTS (8)
13 
14 namespace Eegeo
15 {
16  class Effect;
17 
19  {
20  public:
21  enum GraphicsEffect
22  {
23  kGraphicsEffectLightTex = 0,
24  kGraphicsEffectPrelitTex,
25  kGraphicsNumEffects
26  };
27  private:
28 
29  static std::vector <Effect*> m_effectList;
30  static s32 m_nCurrentEffect;
31 
32 
33  static Eegeo::m44 m_modelMatrix;
34  static Eegeo::m44 m_viewMatrix;
35  static Eegeo::m44 m_projectionMatrix;
36 
37  static Eegeo::m44 m_viewProjMatrix;
38  static Eegeo::m44 m_modelViewProjectionMatrix;
39  static Eegeo::m44 m_boneMatrices[32];
40  static Eegeo::m44 m_modelViewMatrix;
41 
42  static Eegeo::m33 m_invModelMatrix;
43 
44  static Eegeo::v4 m_modelWorldOffset;
45 
46  static Eegeo::v3 m_v3EyePosition;
47  static float m_fScale;
48 
49  static u32 m_numBoneMatrices;
50 
51  static Eegeo::v3 m_v3LightDirection[3];
52  static Eegeo::v3 m_v3LightColor[3];
53  static Eegeo::v3 m_v3LightAmbient;
54  static s32 m_anTextureIndex[4];
55 
56  static Eegeo::v4 m_v4AnimUVSettings;
57 
58  static float m_fShadowExtrudedHeightAdjust;
59  static float m_fAlpha;
60 
61  static void UpdateModelViewProjectionMatrix ();
62  static void UpdateModelBoneMatrices ();
63  static void UpdateModelViewMatrix ();
64  static void UpdateModelWorldOffset ();
65  static void UpdateLightDirection ();
66  static void UpdateLightColor ();
67  static void UpdateLightAmbient ();
68  static void UpdateTextureIndex (u32 channel);
69  static void UpdateEyePosition ();
70  static void UpdateScale ();
71  static void UpdateAnimUVSettings ();
72  static void UpdateShadowExtrudedHeightAdjust ();
73  public:
74  static void UpdateAlpha ();
75  private:
76  static void CalculateModelViewProjectionMatrix ();
77  static void CalculateInvModelMatrix ();
78  static void CalculateInvModelMatrixUniformScale ();
79  static void CalculateModelViewMatrix ();
80 
81  static u32 m_effectIndexList [kGraphicsNumEffects];
82 
83  public:
84 
85  static void Temp_UpdateFromRenderContext(const Eegeo::Rendering::RenderContext& renderContext);
86 
87  static void Initialise ();
88  static void Shutdown ();
89  static void Reset ();
90  private:
91  static s32 AddEffect (Effect* effect);
92  static Effect* GetEffect (u32 effectIndex);
93  static void UseEffect_GlState (u32 effectIndex, Rendering::GLState& glState);
94  static void CreateEffects();
95  static void DestroyEffects();
96  static void AddEffectByType(GraphicsEffect effectType, Effect* effect);
97  static Effect* GetEffectByType(GraphicsEffect effectType);
98 
99  static void PreWarmEffects ();
100  public:
101  static void UseEffectByType_GlState(GraphicsEffect effectType, Rendering::GLState& glState);
102 
103  static void SetModelMatrix (const Eegeo::m44& matrix);
104  static void SetModelMatrixUniformScale(const Eegeo::m44& matrix);
105  static void SetViewMatrix (const Eegeo::m44& matrix);
106  static void SetProjectionMatrix (const Eegeo::m44& matrix);
107 
108  static void SetModelWorldOffset (const Eegeo::v4& offset);
109 
110  static void SetEyePosition (const Eegeo::v3& position);
111  static void SetScale (float scale);
112 
113  static void SetAnimUVSettings (const Eegeo::v4& settings);
114  static void SetLightDirection (u32 lightIndex, const Eegeo::v3& direction);
115  static void SetLightColor (u32 lightIndex, const Eegeo::v3& colour);
116  static void SetLightAmbient (const Eegeo::v3& ambient);
117 
118  static void SetShadowExtrudedHeightAdjust (float fValue);
119  static void SetAlpha (float fValue);
120 
121  static void SetTexture (u32 channel, u32 textureIndex);
122  static void SetDirty ();
123 
124  static const Eegeo::m44* GetModelViewProjectionMatrix ();
125 
126  static const Eegeo::v4* GetAnimUVSettings ();
127  static const Eegeo::v3* GetLightDirection (u32 lightIndex);
128  static const Eegeo::v3* GetLightColor (u32 lightIndex);
129  static const Eegeo::v3* GetLightAmbient ();
130 
131  static void SetNumSkinMatrices ( u32 munSkinMatrices ) { m_numBoneMatrices = munSkinMatrices; }
132  static void SetSkinMatrix ( const Eegeo::m44& bone, u32 index ) { m_boneMatrices[index] = bone; }
133 
134  static void SetFogState(const Lighting::GlobalFoggingUniformValues& foggingValues);
135  static void SetPerMaterialFogState(const Lighting::GlobalFoggingUniformValues& foggingValues);
136  static void SetPerModelFogState(const Eegeo::v3& cameraRelativeModelOrigin);
137  };
138 }