Torque3D Documentation / _generateds / lightFlareData.h

lightFlareData.h

Engine/source/T3D/lightFlareData.h

More...

Classes:

Public Defines

define

Detailed Description

Public Defines

MAX_ELEMENTS() 20
  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 _LIGHTFLAREDATA_H_
 25#define _LIGHTFLAREDATA_H_
 26
 27#ifndef _SIMDATABLOCK_H_
 28#include "console/simDatablock.h"
 29#endif
 30#ifndef _GFXTEXTUREHANDLE_H_
 31#include "gfx/gfxTextureHandle.h"
 32#endif
 33#ifndef _GFXPRIMITIVEBUFFER_H_
 34#include "gfx/gfxPrimitiveBuffer.h"
 35#endif
 36#ifndef _CONSOLETYPES_H_
 37#include "console/consoleTypes.h"
 38#endif
 39#ifndef _GFXVERTEXBUFFER_H_
 40#include "gfx/gfxVertexBuffer.h"
 41#endif
 42#ifndef _GFXSTATEBLOCK_H_
 43#include "gfx/gfxStateBlock.h"
 44#endif
 45#ifndef _GFXOCCLUSIONQUERY_H_
 46#include "gfx/gfxOcclusionQuery.h"
 47#endif
 48
 49class LightInfo;
 50struct ObjectRenderInst;
 51class SceneRenderState;
 52class BaseMatInstance;
 53
 54struct LightFlareState
 55{  
 56   ~LightFlareState();
 57   void clear();
 58
 59   /// Object calling LightFlareData::prepRender fills these in!
 60   F32 scale;              
 61   F32 fullBrightness;
 62   MatrixF lightMat;
 63   LightInfo *lightInfo;
 64   F32 worldRadius;
 65
 66   /// Used internally by LightFlareData!
 67   U32 visChangedTime;
 68   bool visible;   
 69   F32 occlusion;
 70   GFXVertexBufferHandle<GFXVertexPCT> vertBuffer;   
 71   GFXOcclusionQueryHandle occlusionQuery;
 72   GFXOcclusionQueryHandle fullPixelQuery;
 73};
 74
 75class LightFlareData : public SimDataBlock
 76{
 77   typedef SimDataBlock Parent;
 78   
 79   #define MAX_ELEMENTS 20
 80
 81public:
 82
 83   LightFlareData();
 84   virtual ~LightFlareData();
 85
 86   DECLARE_CONOBJECT( LightFlareData );
 87
 88   static void initPersistFields();
 89   virtual void inspectPostApply();
 90
 91   // SimDataBlock
 92   virtual bool preload( bool server, String &errorStr );
 93   virtual void packData( BitStream *stream );
 94   virtual void unpackData( BitStream *stream );
 95
 96   /// Submits render instances for corona and flare effects.
 97   void prepRender( SceneRenderState *state, LightFlareState *flareState );
 98
 99protected:
100
101   bool _testVisibility(   const SceneRenderState *state, LightFlareState *flareState, 
102                           U32 *outVisDelta, F32 *outOcclusionFade, Point3F *outLightPosSS );
103
104   bool _preload( bool server, String &errorStr );
105   void _makePrimBuffer( GFXPrimitiveBufferHandle *pb, U32 count );
106   void _renderCorona( ObjectRenderInst *ri, SceneRenderState *state, BaseMatInstance *overrideMat );
107
108protected:
109   
110   static const U32 LosMask;
111   static const U32 FadeOutTime = 20;
112   static const U32 FadeInTime = 125;    
113   static Point3F sBasePoints[4];
114
115   // Fields...
116
117   F32 mScale;
118   bool mFlareEnabled;
119   String mFlareTextureName;
120   GFXTexHandle mFlareTexture;
121   F32 mOcclusionRadius;
122   bool mRenderReflectPass;
123
124   RectF mElementRect[MAX_ELEMENTS];
125   F32 mElementDist[MAX_ELEMENTS];
126   F32 mElementScale[MAX_ELEMENTS];
127   LinearColorF mElementTint[MAX_ELEMENTS];
128   bool mElementRotate[MAX_ELEMENTS];
129   bool mElementUseLightColor[MAX_ELEMENTS];   
130
131protected:
132
133   U32 mElementCount;   
134   GFXPrimitiveBufferHandle mFlarePrimBuffer;   
135};
136
137#endif // _LIGHTFLAREDATA_H_
138