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