lightBase.h 4.3 KB

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