1 /*
2  Copyright (C) 1999-2006 Id Software, Inc. and contributors.
3  For a list of contributors, see the accompanying CONTRIBUTORS file.
4 
5  This file is part of GtkRadiant.
6 
7  GtkRadiant is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation; either version 2 of the License, or
10  (at your option) any later version.
11 
12  GtkRadiant is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with GtkRadiant; if not, write to the Free Software
19  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20  */
21 
22 #if !defined(INCLUDED_ICAMERA_H)
23 #define INCLUDED_ICAMERA_H
24 
25 #include "math/Vector3.h"
26 #include "scenelib.h"
27 enum
28 {
29 	CAMERA_PITCH = 0, // up / down
30 	CAMERA_YAW = 1, // left / right
31 	CAMERA_ROLL = 2
32 // fall over
33 };
34 
35 /**
36  * The "global" interface of DarkRadiant's camera module.
37  */
38 class ICamera
39 {
40 	public:
41 		INTEGER_CONSTANT(Version, 1);
42 		STRING_CONSTANT(Name, "camera");
43 
~ICamera()44 		virtual ~ICamera ()
45 		{
46 		}
47 
48 		/**
49 		 * greebo: Sets the camera origin to the given <point> using the given <angles>.
50 		 */
51 		virtual void focusCamera (const Vector3& point, const Vector3& angles) = 0;
52 };
53 
54 class Matrix4;
55 
56 class CameraView
57 {
58 	public:
~CameraView()59 		virtual ~CameraView ()
60 		{
61 		}
62 		virtual void setModelview (const Matrix4& modelview) = 0;
63 		virtual void setFieldOfView (float fieldOfView) = 0;
64 };
65 
66 class CameraModel
67 {
68 	public:
69 		STRING_CONSTANT(Name, "CameraModel");
~CameraModel()70 		virtual ~CameraModel ()
71 		{
72 		}
73 		virtual void setCameraView (CameraView* view, const Callback& disconnect) = 0;
74 };
75 
Instance_getCameraModel(scene::Instance & instance)76 inline CameraModel* Instance_getCameraModel (scene::Instance& instance)
77 {
78 	return dynamic_cast<CameraModel*>(&instance);
79 }
80 
81 // Module definitions
82 
83 #include "modulesystem.h"
84 
85 template<typename Type>
86 class GlobalModule;
87 typedef GlobalModule<ICamera> GlobalCameraModule;
88 
89 template<typename Type>
90 class GlobalModuleRef;
91 typedef GlobalModuleRef<ICamera> GlobalCameraModuleRef;
92 
93 // This is the accessor for the registry
GlobalCameraView()94 inline ICamera& GlobalCameraView ()
95 {
96 	return GlobalCameraModule::getTable();
97 }
98 
99 #endif
100