]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - contrib/camera/camera.h
Merge branch 'fix-fast' into 'master'
[xonotic/netradiant.git] / contrib / camera / camera.h
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 /*
23    Camera plugin for GtkRadiant
24    Copyright (C) 2002 Splash Damage Ltd.
25  */
26
27 #ifndef _CAMERA_H_
28 #define _CAMERA_H_
29
30 typedef unsigned char byte;
31
32 #include "mathlib.h"
33 #include <string.h>
34 #include "qertypes.h"
35 #include <stdio.h>
36
37 #define USE_QERTABLE_DEFINE
38
39 #include "iscenegraph.h"
40 #include "qerplugin.h"
41
42 #define USE_QGLTABLE_DEFINE
43
44 #include "igl.h"
45
46 extern _QERQglTable __QGLTABLENAME;
47
48 #include "iui.h"
49 #include "icamera.h"
50
51 #include "bytebool.h"
52
53 class CCamera;
54
55 #include "str.h"
56
57
58 #include "misc.h"
59 #include "dialogs.h"
60 #include "funchandlers.h"
61 #include "renderer.h"
62 #include "listener.h"
63
64 extern _QERFuncTable_1 g_FuncTable;
65 extern _QERQglTable g_QglTable;
66 extern _QERUITable g_UITable;
67 extern _QERCameraTable g_CameraTable;
68
69 extern CRenderer *Renderer;
70 extern CListener *Listener;
71
72 // splinelib
73 #define CAMERA_PLUGIN
74 #define DotProduct(a, b)         ( ( a )[0] * ( b )[0] + ( a )[1] * ( b )[1] + ( a )[2] * ( b )[2] )
75
76 #include "splines/splines.h"
77
78 // this needs to match splines.cpp
79 #define MAX_CAMERAS 64
80 extern idCameraDef camera[MAX_CAMERAS];
81
82 extern "C" qboolean loadCamera(int camNum, const char *name);
83
84 #ifndef PATH_MAX
85 #define PATH_MAX 260
86 #endif
87
88 //
89 // CCamera
90 //
91
92 class CCamera {
93 public:
94     CCamera(int i)
95     {
96         cam = &camera[i];
97         camnum = i;
98         Init();
99     }
100
101     ~CCamera();
102
103     void Init()
104     {
105         next = prev = NULL;
106         fileName[0] = '\0';
107         hasbeensaved = 0;
108     }
109
110     idCameraDef *GetCam()
111     {
112         return (cam);
113     }
114
115     int GetCamNum()
116     {
117         return (camnum);
118     }
119
120     char *GetFileName()
121     {
122         return (fileName);
123     }
124
125     void SetFileName(const char *name, bool save)
126     {
127         strcpy(fileName, name);
128         if (save) {
129             hasbeensaved = 1;
130         }
131     }
132
133     CCamera *GetNext()
134     {
135         return (next);
136     }
137
138     CCamera *GetPrev()
139     {
140         return (prev);
141     }
142
143     void SetNext(CCamera *camera)
144     {
145         next = camera;
146     }
147
148     void SetPrev(CCamera *camera)
149     {
150         prev = camera;
151     }
152
153     int HasBeenSaved()
154     {
155         return (hasbeensaved);
156     }
157
158     void HasBeenModified()
159     {
160         if (hasbeensaved) {
161             hasbeensaved = 2;
162         }
163     }
164
165 protected:
166     idCameraDef *cam;
167     int camnum;
168     CCamera *next, *prev;
169     char fileName[PATH_MAX];
170     int hasbeensaved;       // 0:never saved 1:saved 2:saved, but modified
171 };
172
173 CCamera *AllocCam();
174
175 void FreeCam(CCamera *cam);
176
177 void SetCurrentCam(CCamera *cam);
178
179 CCamera *GetCurrentCam();
180
181 // globals
182 extern ui::Window g_pRadiantWnd;
183 extern ui::Window g_pCameraInspectorWnd;
184 extern CCamera *firstCam;
185 extern bool g_bEditOn;
186 extern int g_iEditMode;
187 extern int g_iActiveTarget;
188 extern int g_iPreviewRunning;
189 extern CCamera *g_pCurrentEditCam;
190
191 #endif // _CAMERA_H_