lightDescription.h 3.4 KB

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