lightBase.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #ifndef _LIGHTBASE_H_
  23. #define _LIGHTBASE_H_
  24. #ifndef _SCENEOBJECT_H_
  25. #include "scene/sceneObject.h"
  26. #endif
  27. #ifndef _LIGHTINFO_H_
  28. #include "lighting/lightInfo.h"
  29. #endif
  30. #ifndef _ITICKABLE_H_
  31. #include "core/iTickable.h"
  32. #endif
  33. #ifndef _LIGHTFLAREDATA_H_
  34. #include "T3D/lightFlareData.h"
  35. #endif
  36. #ifndef _LIGHTANIMDATA_H_
  37. #include "T3D/lightAnimData.h"
  38. #endif
  39. class LightAnimData;
  40. class LightBase : public SceneObject, public ISceneLight, public virtual ITickable
  41. {
  42. typedef SceneObject Parent;
  43. friend class LightAnimData;
  44. friend class LightFlareData;
  45. protected:
  46. bool mIsEnabled;
  47. ColorF mColor;
  48. F32 mBrightness;
  49. bool mCastShadows;
  50. F32 mPriority;
  51. LightInfo *mLight;
  52. LightAnimData *mAnimationData;
  53. LightAnimState mAnimState;
  54. LightFlareData *mFlareData;
  55. LightFlareState mFlareState;
  56. F32 mFlareScale;
  57. static bool smRenderViz;
  58. virtual void _conformLights() {}
  59. void _onRenderViz( ObjectRenderInst *ri,
  60. SceneRenderState *state,
  61. BaseMatInstance *overrideMat );
  62. virtual void _renderViz( SceneRenderState *state ) {}
  63. enum LightMasks
  64. {
  65. InitialUpdateMask = Parent::NextFreeMask,
  66. EnabledMask = Parent::NextFreeMask << 1,
  67. TransformMask = Parent::NextFreeMask << 2,
  68. UpdateMask = Parent::NextFreeMask << 3,
  69. DatablockMask = Parent::NextFreeMask << 4,
  70. NextFreeMask = Parent::NextFreeMask << 5
  71. };
  72. // SimObject.
  73. virtual void _onSelected();
  74. virtual void _onUnselected();
  75. public:
  76. LightBase();
  77. virtual ~LightBase();
  78. // SimObject
  79. virtual bool onAdd();
  80. virtual void onRemove();
  81. // ConsoleObject
  82. void inspectPostApply();
  83. static void initPersistFields();
  84. DECLARE_CONOBJECT(LightBase);
  85. // NetObject
  86. U32 packUpdate( NetConnection *conn, U32 mask, BitStream *stream );
  87. void unpackUpdate( NetConnection *conn, BitStream *stream );
  88. // ISceneLight
  89. virtual void submitLights( LightManager *lm, bool staticLighting );
  90. virtual LightInfo* getLight() { return mLight; }
  91. // SceneObject
  92. virtual void setTransform( const MatrixF &mat );
  93. virtual void prepRenderImage( SceneRenderState *state );
  94. // ITickable
  95. virtual void interpolateTick( F32 delta );
  96. virtual void processTick();
  97. virtual void advanceTime( F32 timeDelta );
  98. /// Toggles the light on and off.
  99. void setLightEnabled( bool enabled );
  100. bool getLightEnabled() { return mIsEnabled; };
  101. /// Animate the light.
  102. virtual void pauseAnimation( void );
  103. virtual void playAnimation( void );
  104. virtual void playAnimation( LightAnimData *animData );
  105. };
  106. #endif // _LIGHTBASE_H_