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_CAMERA_H__
30 #define __GAME_CAMERA_H__
31 
32 #include "idlib/math/Quat.h"
33 
34 #include "Entity.h"
35 
36 /*
37 ===============================================================================
38 
39 Camera providing an alternative view of the level.
40 
41 ===============================================================================
42 */
43 
44 class idCamera : public idEntity {
45 public:
46 	ABSTRACT_PROTOTYPE( idCamera );
47 
48 	void					Spawn( void );
49 	virtual void			GetViewParms( renderView_t *view ) = 0;
50 	virtual renderView_t *	GetRenderView();
Stop(void)51 	virtual void			Stop( void ){} ;
52 };
53 
54 /*
55 ===============================================================================
56 
57 idCameraView
58 
59 ===============================================================================
60 */
61 
62 class idCameraView : public idCamera {
63 public:
64 	CLASS_PROTOTYPE( idCameraView );
65 							idCameraView();
66 
67 	// save games
68 	void					Save( idSaveGame *savefile ) const;				// archives object for save game file
69 	void					Restore( idRestoreGame *savefile );				// unarchives object from save game file
70 
71 	void					Spawn( );
72 	virtual void			GetViewParms( renderView_t *view );
73 	virtual void			Stop( void );
74 
75 protected:
76 	void					Event_Activate( idEntity *activator );
77 	void					Event_SetAttachments();
78 	void					SetAttachment( idEntity **e, const char *p );
79 	float					fov;
80 	idEntity				*attachedTo;
81 	idEntity				*attachedView;
82 };
83 
84 
85 
86 /*
87 ===============================================================================
88 
89 A camera which follows a path defined by an animation.
90 
91 ===============================================================================
92 */
93 
94 typedef struct {
95 	idCQuat				q;
96 	idVec3				t;
97 	float				fov;
98 } cameraFrame_t;
99 
100 class idCameraAnim : public idCamera {
101 public:
102 	CLASS_PROTOTYPE( idCameraAnim );
103 
104 							idCameraAnim();
105 							~idCameraAnim();
106 
107 	// save games
108 	void					Save( idSaveGame *savefile ) const;				// archives object for save game file
109 	void					Restore( idRestoreGame *savefile );				// unarchives object from save game file
110 
111 	void					Spawn( void );
112 	virtual void			GetViewParms( renderView_t *view );
113 
114 private:
115 	int						threadNum;
116 	idVec3					offset;
117 	int						frameRate;
118 	int						starttime;
119 	int						cycle;
120 	idList<int>				cameraCuts;
121 	idList<cameraFrame_t>	camera;
122 	idEntityPtr<idEntity>	activator;
123 
124 	void					Start( void );
125 	void					Stop( void );
126 	void					Think( void );
127 
128 	void					LoadAnim( void );
129 	void					Event_Start( void );
130 	void					Event_Stop( void );
131 	void					Event_SetCallback( void );
132 	void					Event_Activate( idEntity *activator );
133 };
134 
135 #endif /* !__GAME_CAMERA_H__ */
136