Torque3D Documentation / _generateds / lightDescription.h

lightDescription.h

Engine/source/T3D/lightDescription.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 _LIGHTDESCRIPTION_H_
 25#define _LIGHTDESCRIPTION_H_
 26
 27#ifndef _SIMDATABLOCK_H_
 28#include "console/simDatablock.h"
 29#endif
 30#ifndef _CONSOLETYPES_H_
 31#include "console/consoleTypes.h"
 32#endif
 33#ifndef _COLOR_H_
 34#include "core/color.h"
 35#endif
 36#ifndef _LIGHTANIMDATA_H_
 37#include "T3D/lightAnimData.h"
 38#endif
 39#ifndef _LIGHTFLAREDATA_H_
 40#include "T3D/lightFlareData.h"
 41#endif
 42
 43struct LightState
 44{
 45   LightInfo *lightInfo;
 46   F32 fullBrightness;   
 47
 48   LightAnimState animState;   
 49   LightFlareState flareState;      
 50
 51   void clear() 
 52   {
 53      lightInfo = NULL;
 54      fullBrightness = 1.0f;
 55      flareState.clear();     
 56   }
 57
 58   void setLightInfo( LightInfo *li )
 59   {
 60      flareState.lightInfo = lightInfo = li;
 61   }
 62};
 63
 64/// LightDescription is a helper datablock used by classes (such as shapebase)
 65/// that submit lights to the scene but do not use actual "LightBase" objects.
 66/// This datablock stores the properties of that light as fields that can be
 67/// initialized from script.
 68
 69class LightAnimData;
 70class LightFlareData;
 71class LightManager;
 72class ISceneLight;
 73
 74class LightDescription : public SimDataBlock
 75{
 76   typedef SimDataBlock Parent;
 77
 78public:
 79
 80   LightDescription();
 81   virtual ~LightDescription();
 82
 83   DECLARE_CONOBJECT( LightDescription );
 84
 85   static void initPersistFields();
 86   virtual void inspectPostApply();
 87   
 88   bool onAdd();
 89
 90   // SimDataBlock
 91   virtual bool preload( bool server, String &errorStr );
 92   virtual void packData( BitStream *stream );
 93   virtual void unpackData( BitStream *stream );
 94   
 95   //void animateLight( LightState *state );
 96   void submitLight( LightState *state, const MatrixF &xfm, LightManager *lm, SimObject *object );
 97   void prepRender( SceneRenderState *sceneState, LightState *lightState, const MatrixF &xfm );
 98
 99   bool _preload( bool server, String &errorStr );
100   
101   LinearColorF color;
102   F32 brightness;
103   F32 range;
104   bool castShadows;
105   S32 mStaticRefreshFreq;
106   S32 mDynamicRefreshFreq;
107
108   LightAnimData *animationData;   
109   S32 animationDataId;
110   F32 animationPeriod;
111   F32 animationPhase;
112
113   LightFlareData *flareData;
114   S32 flareDataId;
115   F32 flareScale;
116};
117
118#endif // _LIGHTDESCRIPTION_H_
119