Light.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /*
  2. ===========================================================================
  3. Doom 3 BFG Edition GPL Source Code
  4. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
  5. This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
  6. Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
  16. In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
  17. If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
  18. ===========================================================================
  19. */
  20. #ifndef __GAME_LIGHT_H__
  21. #define __GAME_LIGHT_H__
  22. /*
  23. ===============================================================================
  24. Generic light.
  25. ===============================================================================
  26. */
  27. extern const idEventDef EV_Light_GetLightParm;
  28. extern const idEventDef EV_Light_SetLightParm;
  29. extern const idEventDef EV_Light_SetLightParms;
  30. class idLight : public idEntity {
  31. public:
  32. CLASS_PROTOTYPE( idLight );
  33. idLight();
  34. ~idLight();
  35. void Spawn();
  36. void Save( idSaveGame *savefile ) const; // archives object for save game file
  37. void Restore( idRestoreGame *savefile ); // unarchives object from save game file
  38. virtual void UpdateChangeableSpawnArgs( const idDict *source );
  39. virtual void Think();
  40. virtual void ClientThink( const int curTime, const float fraction, const bool predict );
  41. virtual void FreeLightDef();
  42. virtual bool GetPhysicsToSoundTransform( idVec3 &origin, idMat3 &axis );
  43. void Present();
  44. void SaveState( idDict *args );
  45. virtual void SetColor( float red, float green, float blue );
  46. virtual void SetColor( const idVec4 &color );
  47. void SetColor( const idVec3 &color );
  48. virtual void GetColor( idVec3 &out ) const;
  49. virtual void GetColor( idVec4 &out ) const;
  50. const idVec3 & GetBaseColor() const { return baseColor; }
  51. void SetShader( const char *shadername );
  52. void SetLightParm( int parmnum, float value );
  53. void SetLightParms( float parm0, float parm1, float parm2, float parm3 );
  54. void SetRadiusXYZ( float x, float y, float z );
  55. void SetRadius( float radius );
  56. void On();
  57. void Off();
  58. void Fade( const idVec4 &to, float fadeTime );
  59. void FadeOut( float time );
  60. void FadeIn( float time );
  61. void Killed( idEntity *inflictor, idEntity *attacker, int damage, const idVec3 &dir, int location );
  62. void BecomeBroken( idEntity *activator );
  63. qhandle_t GetLightDefHandle() const { return lightDefHandle; }
  64. void SetLightParent( idEntity *lparent ) { lightParent = lparent; }
  65. void SetLightLevel();
  66. virtual void ShowEditingDialog();
  67. enum {
  68. EVENT_BECOMEBROKEN = idEntity::EVENT_MAXEVENTS,
  69. EVENT_MAXEVENTS
  70. };
  71. virtual void ClientPredictionThink();
  72. virtual void WriteToSnapshot( idBitMsg &msg ) const;
  73. virtual void ReadFromSnapshot( const idBitMsg &msg );
  74. virtual bool ClientReceiveEvent( int event, int time, const idBitMsg &msg );
  75. private:
  76. renderLight_t renderLight; // light presented to the renderer
  77. idVec3 localLightOrigin; // light origin relative to the physics origin
  78. idMat3 localLightAxis; // light axis relative to physics axis
  79. qhandle_t lightDefHandle; // handle to renderer light def
  80. idStr brokenModel;
  81. int levels;
  82. int currentLevel;
  83. idVec3 baseColor;
  84. // Colors used for client-side interpolation.
  85. idVec3 previousBaseColor;
  86. idVec3 nextBaseColor;
  87. bool breakOnTrigger;
  88. int count;
  89. int triggercount;
  90. idEntity * lightParent;
  91. idVec4 fadeFrom;
  92. idVec4 fadeTo;
  93. int fadeStart;
  94. int fadeEnd;
  95. bool soundWasPlaying;
  96. private:
  97. void PresentLightDefChange();
  98. void PresentModelDefChange();
  99. void Event_SetShader( const char *shadername );
  100. void Event_GetLightParm( int parmnum );
  101. void Event_SetLightParm( int parmnum, float value );
  102. void Event_SetLightParms( float parm0, float parm1, float parm2, float parm3 );
  103. void Event_SetRadiusXYZ( float x, float y, float z );
  104. void Event_SetRadius( float radius );
  105. void Event_Hide();
  106. void Event_Show();
  107. void Event_On();
  108. void Event_Off();
  109. void Event_ToggleOnOff( idEntity *activator );
  110. void Event_SetSoundHandles();
  111. void Event_FadeOut( float time );
  112. void Event_FadeIn( float time );
  113. };
  114. #endif /* !__GAME_LIGHT_H__ */