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