lightBase.h

Engine/source/T3D/lightBase.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//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
 25// Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames
 26// Copyright (C) 2015 Faust Logic, Inc.
 27//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
 28
 29#ifndef _LIGHTBASE_H_
 30#define _LIGHTBASE_H_
 31
 32#ifndef _SCENEOBJECT_H_
 33#include "scene/sceneObject.h"
 34#endif
 35#ifndef _LIGHTINFO_H_
 36#include "lighting/lightInfo.h"
 37#endif
 38#ifndef _ITICKABLE_H_
 39#include "core/iTickable.h"
 40#endif
 41#ifndef _LIGHTFLAREDATA_H_
 42#include "T3D/lightFlareData.h"
 43#endif
 44#ifndef _LIGHTANIMDATA_H_
 45#include "T3D/lightAnimData.h"
 46#endif
 47
 48class LightAnimData;
 49
 50class LightBase : public SceneObject, public ISceneLight, public virtual ITickable
 51{
 52   typedef SceneObject Parent;
 53   friend class LightAnimData;
 54   friend class LightFlareData;
 55
 56protected:
 57
 58   bool mIsEnabled;
 59
 60   LinearColorF mColor;
 61
 62   F32 mBrightness;
 63
 64   bool mCastShadows;
 65   S32 mStaticRefreshFreq;
 66   S32 mDynamicRefreshFreq;
 67   F32 mPriority;
 68
 69   LightInfo *mLight;
 70
 71   LightAnimData *mAnimationData; 
 72   LightAnimState mAnimState;
 73
 74   LightFlareData *mFlareData;
 75   LightFlareState mFlareState;   
 76   F32 mFlareScale;
 77
 78   static bool smRenderViz;
 79
 80   virtual void _conformLights() {}
 81
 82   void _onRenderViz(   ObjectRenderInst *ri, 
 83                        SceneRenderState *state, 
 84                        BaseMatInstance *overrideMat );
 85
 86   virtual void _renderViz( SceneRenderState *state ) {}
 87
 88   enum LightMasks
 89   {
 90      InitialUpdateMask = Parent::NextFreeMask,
 91      EnabledMask       = Parent::NextFreeMask << 1,
 92      TransformMask     = Parent::NextFreeMask << 2,
 93      UpdateMask        = Parent::NextFreeMask << 3,
 94      DatablockMask     = Parent::NextFreeMask << 4,      
 95      NextFreeMask      = Parent::NextFreeMask << 5
 96   };
 97
 98   // SimObject.
 99   virtual void _onSelected();
100   virtual void _onUnselected();
101
102public:
103
104   LightBase();
105   virtual ~LightBase();
106
107   // SimObject
108   virtual bool onAdd();
109   virtual void onRemove();
110
111   // ConsoleObject
112   void inspectPostApply();
113   static void initPersistFields();
114   DECLARE_CONOBJECT(LightBase);
115
116   // NetObject
117   U32 packUpdate( NetConnection *conn, U32 mask, BitStream *stream );
118   void unpackUpdate( NetConnection *conn, BitStream *stream );  
119
120   // ISceneLight
121   virtual void submitLights( LightManager *lm, bool staticLighting );
122   virtual LightInfo* getLight() { return mLight; }
123
124   // SceneObject
125   virtual void setTransform( const MatrixF &mat );
126   virtual void prepRenderImage( SceneRenderState *state );
127
128   // ITickable
129   virtual void interpolateTick( F32 delta );
130   virtual void processTick();
131   virtual void advanceTime( F32 timeDelta );
132
133   /// Toggles the light on and off.
134   void setLightEnabled( bool enabled );
135   bool getLightEnabled() { return mIsEnabled; };
136
137   /// Animate the light.
138   virtual void pauseAnimation( void );
139   virtual void playAnimation( void );
140   virtual void playAnimation( LightAnimData *animData );
141protected:
142   bool mLocalRenderViz;
143};
144
145#endif // _LIGHTBASE_H_
146