Light.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*
  2. ===========================================================================
  3. Doom 3 GPL Source Code
  4. Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
  5. This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
  6. Doom 3 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 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 Source Code. If not, see <http://www.gnu.org/licenses/>.
  16. In addition, the Doom 3 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 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( void );
  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( void );
  40. virtual void FreeLightDef( void );
  41. virtual bool GetPhysicsToSoundTransform( idVec3 &origin, idMat3 &axis );
  42. void Present( void );
  43. void SaveState( idDict *args );
  44. virtual void SetColor( float red, float green, float blue );
  45. virtual void SetColor( const idVec4 &color );
  46. virtual void GetColor( idVec3 &out ) const;
  47. virtual void GetColor( idVec4 &out ) const;
  48. const idVec3 & GetBaseColor( void ) const { return baseColor; }
  49. void SetShader( const char *shadername );
  50. void SetLightParm( int parmnum, float value );
  51. void SetLightParms( float parm0, float parm1, float parm2, float parm3 );
  52. void SetRadiusXYZ( float x, float y, float z );
  53. void SetRadius( float radius );
  54. void On( void );
  55. void Off( void );
  56. void Fade( const idVec4 &to, float fadeTime );
  57. void FadeOut( float time );
  58. void FadeIn( float time );
  59. void Killed( idEntity *inflictor, idEntity *attacker, int damage, const idVec3 &dir, int location );
  60. void BecomeBroken( idEntity *activator );
  61. qhandle_t GetLightDefHandle( void ) const { return lightDefHandle; }
  62. void SetLightParent( idEntity *lparent ) { lightParent = lparent; }
  63. void SetLightLevel( void );
  64. virtual void ShowEditingDialog( void );
  65. enum {
  66. EVENT_BECOMEBROKEN = idEntity::EVENT_MAXEVENTS,
  67. EVENT_MAXEVENTS
  68. };
  69. virtual void ClientPredictionThink( void );
  70. virtual void WriteToSnapshot( idBitMsgDelta &msg ) const;
  71. virtual void ReadFromSnapshot( const idBitMsgDelta &msg );
  72. virtual bool ClientReceiveEvent( int event, int time, const idBitMsg &msg );
  73. private:
  74. renderLight_t renderLight; // light presented to the renderer
  75. idVec3 localLightOrigin; // light origin relative to the physics origin
  76. idMat3 localLightAxis; // light axis relative to physics axis
  77. qhandle_t lightDefHandle; // handle to renderer light def
  78. idStr brokenModel;
  79. int levels;
  80. int currentLevel;
  81. idVec3 baseColor;
  82. bool breakOnTrigger;
  83. int count;
  84. int triggercount;
  85. idEntity * lightParent;
  86. idVec4 fadeFrom;
  87. idVec4 fadeTo;
  88. int fadeStart;
  89. int fadeEnd;
  90. bool soundWasPlaying;
  91. private:
  92. void PresentLightDefChange( void );
  93. void PresentModelDefChange( void );
  94. void Event_SetShader( const char *shadername );
  95. void Event_GetLightParm( int parmnum );
  96. void Event_SetLightParm( int parmnum, float value );
  97. void Event_SetLightParms( float parm0, float parm1, float parm2, float parm3 );
  98. void Event_SetRadiusXYZ( float x, float y, float z );
  99. void Event_SetRadius( float radius );
  100. void Event_Hide( void );
  101. void Event_Show( void );
  102. void Event_On( void );
  103. void Event_Off( void );
  104. void Event_ToggleOnOff( idEntity *activator );
  105. void Event_SetSoundHandles( void );
  106. void Event_FadeOut( float time );
  107. void Event_FadeIn( float time );
  108. };
  109. #endif /* !__GAME_LIGHT_H__ */