advancedLightManager.h
Engine/source/lighting/advanced/advancedLightManager.h
Classes:
class
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 RenderPrePassMgr; 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 76 // LightManager 77 virtual bool isCompatible() const; 78 virtual void activate( SceneManager *sceneManager ); 79 virtual void deactivate(); 80 virtual void registerGlobalLight(LightInfo *light, SimObject *obj); 81 virtual void unregisterAllLights(); 82 virtual void setLightInfo( ProcessedMaterial *pmat, 83 const Material *mat, 84 const SceneData &sgData, 85 const SceneRenderState *state, 86 U32 pass, 87 GFXShaderConstBuffer *shaderConsts ); 88 virtual bool setTextureStage( const SceneData &sgData, 89 const U32 currTexFlag, 90 const U32 textureSlot, 91 GFXShaderConstBuffer *shaderConsts, 92 ShaderConstHandles *handles ); 93 94 typedef GFXVertexPC LightVertex; 95 96 GFXVertexBufferHandle<LightVertex> getSphereMesh(U32 &outNumPrimitives, GFXPrimitiveBuffer *&outPrimitives ); 97 GFXVertexBufferHandle<LightVertex> getConeMesh(U32 &outNumPrimitives, GFXPrimitiveBuffer *&outPrimitives ); 98 99 LightShadowMap* findShadowMapForObject( SimObject *object ); 100 101protected: 102 103 // LightManager 104 virtual void _addLightInfoEx( LightInfo *lightInfo ); 105 virtual void _initLightFields(); 106 107 /// A simple protected singleton. Use LightManager::findByName() 108 /// to access this light manager. 109 /// @see LightManager::findByName() 110 static AdvancedLightManager smSingleton; 111 112 // These are protected because we're a singleton and 113 // no one else should be creating us! 114 AdvancedLightManager(); 115 virtual ~AdvancedLightManager(); 116 117 SimObjectPtr<AdvancedLightBinManager> mLightBinManager; 118 119 SimObjectPtr<RenderPrePassMgr> mPrePassRenderBin; 120 121 LightConstantMap mConstantLookup; 122 123 GFXShaderRef mLastShader; 124 125 LightingShaderConstants* mLastConstants; 126 127 // Convex geometry for lights 128 GFXVertexBufferHandle<LightVertex> mSphereGeometry; 129 130 GFXPrimitiveBufferHandle mSphereIndices; 131 132 U32 mSpherePrimitiveCount; 133 134 GFXVertexBufferHandle<LightVertex> mConeGeometry; 135 136 GFXPrimitiveBufferHandle mConeIndices; 137 138 U32 mConePrimitiveCount; 139 140 LightingShaderConstants* getLightingShaderConstants(GFXShaderConstBuffer* shader); 141 142}; 143 144#endif // _ADVANCEDLIGHTMANAGER_H_ 145
