Torque3D Documentation / _generateds / advancedLightManager.h

advancedLightManager.h

Engine/source/lighting/advanced/advancedLightManager.h

More...

Classes:

Detailed Description

  1
  2//-----------------------------------------------------------------------------
  3// Copyright (c) 2012 GarageGames, LLC
  4//
  5// Permission is hereby granted, free of charge, to any person obtaining a copy
  6// of this software and associated documentation files (the "Software"), to
  7// deal in the Software without restriction, including without limitation the
  8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9// sell copies of the Software, and to permit persons to whom the Software is
 10// furnished to do so, subject to the following conditions:
 11//
 12// The above copyright notice and this permission notice shall be included in
 13// all copies or substantial portions of the Software.
 14//
 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 21// IN THE SOFTWARE.
 22//-----------------------------------------------------------------------------
 23
 24#ifndef _ADVANCEDLIGHTMANAGER_H_
 25#define _ADVANCEDLIGHTMANAGER_H_
 26
 27#ifndef _SIMOBJECT_H_
 28#include "console/simObject.h"
 29#endif 
 30#ifndef _LIGHTMANAGER_H_
 31#include "lighting/lightManager.h"
 32#endif 
 33#ifndef _LIGHTINFO_H_
 34#include "lighting/lightInfo.h"
 35#endif
 36#ifndef _GFXTEXTUREHANDLE_H_
 37#include "gfx/gfxTextureHandle.h"
 38#endif
 39#ifndef _GFXTARGET_H_
 40#include "gfx/gfxTarget.h"
 41#endif
 42#ifndef _TDICTIONARY_H_
 43#include "core/util/tDictionary.h"
 44#endif
 45#ifndef _LIGHTSHADOWMAP_H_
 46#include "lighting/shadowMap/lightShadowMap.h"
 47#endif
 48#ifndef _GFXPRIMITIVEBUFFER_H_
 49#include "gfx/gfxPrimitiveBuffer.h"
 50#endif
 51#ifndef _GFXVERTEXBUFFER_H_
 52#include "gfx/gfxVertexBuffer.h"
 53#endif
 54
 55
 56class AvailableSLInterfaces;
 57class AdvancedLightBinManager;
 58class RenderDeferredMgr;
 59class BaseMatInstance;
 60class MaterialParameters;
 61class MaterialParameterHandle;
 62class GFXShader;
 63class GFXShaderConstHandle;
 64class ShadowMapManager;
 65
 66
 67class AdvancedLightManager : public LightManager
 68{
 69   typedef LightManager Parent;
 70
 71public:
 72
 73   /// Return the lightBinManager for this light manager.
 74   AdvancedLightBinManager* getLightBinManager() { return mLightBinManager; }
 75   RenderDeferredMgr* getDeferredRenderBin() { return mDeferredRenderBin; }
 76
 77   // LightManager
 78   virtual bool isCompatible() const;
 79   virtual void activate( SceneManager *sceneManager );
 80   virtual void deactivate();
 81   virtual void registerGlobalLight(LightInfo *light, SimObject *obj);
 82   virtual void unregisterAllLights();
 83   virtual void setLightInfo( ProcessedMaterial *pmat, 
 84                              const Material *mat, 
 85                              const SceneData &sgData, 
 86                              const SceneRenderState *state,
 87                              U32 pass, 
 88                              GFXShaderConstBuffer *shaderConsts );
 89   virtual bool setTextureStage( const SceneData &sgData, 
 90                                 const U32 currTexFlag, 
 91                                 const U32 textureSlot, 
 92                                 GFXShaderConstBuffer *shaderConsts, 
 93                                 ShaderConstHandles *handles );
 94
 95   typedef GFXVertexPC LightVertex;
 96
 97   GFXVertexBufferHandle<LightVertex> getSphereMesh(U32 &outNumPrimitives, GFXPrimitiveBuffer *&outPrimitives );
 98   GFXVertexBufferHandle<LightVertex> getConeMesh(U32 &outNumPrimitives, GFXPrimitiveBuffer *&outPrimitives );
 99
100   LightShadowMap* findShadowMapForObject( SimObject *object );
101
102#ifndef TORQUE_BASIC_LIGHTING
103   static F32 getShadowFilterDistance() { return smProjectedShadowFilterDistance; }
104#endif
105
106protected:   
107
108   // LightManager
109   virtual void _addLightInfoEx( LightInfo *lightInfo );
110   virtual void _initLightFields();
111
112   /// A simple protected singleton.  Use LightManager::findByName()
113   /// to access this light manager.
114   /// @see LightManager::findByName()
115   static AdvancedLightManager smSingleton;
116
117   // These are protected because we're a singleton and
118   // no one else should be creating us!
119   AdvancedLightManager();
120   virtual ~AdvancedLightManager();
121
122   SimObjectPtr<AdvancedLightBinManager> mLightBinManager;
123
124   SimObjectPtr<RenderDeferredMgr> mDeferredRenderBin;
125
126   LightConstantMap mConstantLookup;
127
128   GFXShaderRef mLastShader;
129
130   LightingShaderConstants* mLastConstants;
131
132   // Convex geometry for lights
133   GFXVertexBufferHandle<LightVertex> mSphereGeometry;
134
135   GFXPrimitiveBufferHandle mSphereIndices;
136
137   U32 mSpherePrimitiveCount;
138
139   GFXVertexBufferHandle<LightVertex> mConeGeometry;
140
141   GFXPrimitiveBufferHandle mConeIndices;
142
143   U32 mConePrimitiveCount;
144
145   LightingShaderConstants* getLightingShaderConstants(GFXShaderConstBuffer* shader);
146   
147#ifndef TORQUE_BASIC_LIGHTING
148   /// This is used to determine the distance  
149   /// at which the shadow filtering PostEffect  
150   /// will be enabled for ProjectedShadow.  
151   static F32 smProjectedShadowFilterDistance;
152#endif
153};
154
155#endif // _ADVANCEDLIGHTMANAGER_H_
156