]> icculus.org git repositories - icculus/iodoom3.git/blob - neo/game/Light.h
hello world
[icculus/iodoom3.git] / neo / game / Light.h
1 /*
2 ===========================================================================
3
4 Doom 3 GPL Source Code
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company. 
6
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).  
8
9 Doom 3 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 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 Source Code.  If not, see <http://www.gnu.org/licenses/>.
21
22 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.
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( void );
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( void );
58         virtual void    FreeLightDef( void );
59         virtual bool    GetPhysicsToSoundTransform( idVec3 &origin, idMat3 &axis );
60         void                    Present( void );
61
62         void                    SaveState( idDict *args );
63         virtual void    SetColor( float red, float green, float blue );
64         virtual void    SetColor( const idVec4 &color );
65         virtual void    GetColor( idVec3 &out ) const;
66         virtual void    GetColor( idVec4 &out ) const;
67         const idVec3 &  GetBaseColor( void ) const { return baseColor; }
68         void                    SetShader( const char *shadername );
69         void                    SetLightParm( int parmnum, float value );
70         void                    SetLightParms( float parm0, float parm1, float parm2, float parm3 );
71         void                    SetRadiusXYZ( float x, float y, float z );
72         void                    SetRadius( float radius );
73         void                    On( void );
74         void                    Off( void );
75         void                    Fade( const idVec4 &to, float fadeTime );
76         void                    FadeOut( float time );
77         void                    FadeIn( float time );
78         void                    Killed( idEntity *inflictor, idEntity *attacker, int damage, const idVec3 &dir, int location );
79         void                    BecomeBroken( idEntity *activator );
80         qhandle_t               GetLightDefHandle( void ) const { return lightDefHandle; }
81         void                    SetLightParent( idEntity *lparent ) { lightParent = lparent; }
82         void                    SetLightLevel( void );
83
84         virtual void    ShowEditingDialog( void );
85
86         enum {
87                 EVENT_BECOMEBROKEN = idEntity::EVENT_MAXEVENTS,
88                 EVENT_MAXEVENTS
89         };
90
91         virtual void    ClientPredictionThink( void );
92         virtual void    WriteToSnapshot( idBitMsgDelta &msg ) const;
93         virtual void    ReadFromSnapshot( const idBitMsgDelta &msg );
94         virtual bool    ClientReceiveEvent( int event, int time, const idBitMsg &msg );
95
96 private:
97         renderLight_t   renderLight;                            // light presented to the renderer
98         idVec3                  localLightOrigin;                       // light origin relative to the physics origin
99         idMat3                  localLightAxis;                         // light axis relative to physics axis
100         qhandle_t               lightDefHandle;                         // handle to renderer light def
101         idStr                   brokenModel;
102         int                             levels;
103         int                             currentLevel;
104         idVec3                  baseColor;
105         bool                    breakOnTrigger;
106         int                             count;
107         int                             triggercount;
108         idEntity *              lightParent;
109         idVec4                  fadeFrom;
110         idVec4                  fadeTo;
111         int                             fadeStart;
112         int                             fadeEnd;
113         bool                    soundWasPlaying;
114
115 private:
116         void                    PresentLightDefChange( void );
117         void                    PresentModelDefChange( void );
118
119         void                    Event_SetShader( const char *shadername );
120         void                    Event_GetLightParm( int parmnum );
121         void                    Event_SetLightParm( int parmnum, float value );
122         void                    Event_SetLightParms( float parm0, float parm1, float parm2, float parm3 );
123         void                    Event_SetRadiusXYZ( float x, float y, float z );
124         void                    Event_SetRadius( float radius );
125         void                    Event_Hide( void );
126         void                    Event_Show( void );
127         void                    Event_On( void );
128         void                    Event_Off( void );
129         void                    Event_ToggleOnOff( idEntity *activator );
130         void                    Event_SetSoundHandles( void );
131         void                    Event_FadeOut( float time );
132         void                    Event_FadeIn( float time );
133 };
134
135 #endif /* !__GAME_LIGHT_H__ */