]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - contrib/gtkgensurf/gensurf.h
* removed unnecessary gi18n.h inclusions
[xonotic/netradiant.git] / contrib / gtkgensurf / gensurf.h
1 /*
2 GenSurf plugin for GtkRadiant
3 Copyright (C) 2001 David Hyde, Loki software and qeradiant.com
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18 */
19
20 #ifndef _GENSURF_H_
21 #define _GENSURF_H_
22
23 #include <gtk/gtk.h>
24
25 #include "qerplugin.h"
26 //#include "qertypes.h"
27
28 #include "igl.h"
29 #include "iui_gtk.h"
30 #include "ientity.h"
31
32 #include "gendlgs.h"
33
34 #define PLUGIN
35 #define Q3RADIANT
36
37 #if defined(__linux__) || defined(__APPLE__)
38 template <class T>
39 inline T min (T x, T y) { return (x < y) ? x : y; }
40 template <class T>
41 inline T max (T x, T y) { return (x > y) ? x : y; }
42
43 typedef struct { long x, y; } POINT;
44 typedef struct { long left, top, right, bottom; } RECT;
45 #endif
46 inline bool PtInRect (RECT *rc, POINT pt)
47 {
48   if (pt.x < rc->left) return false;
49   if (pt.x > rc->right) return false;
50   if (pt.y < rc->bottom) return false;
51   if (pt.y > rc->top) return false;
52   return true;
53 }
54
55 #define NUMGAMES 7
56
57 #define CONTENTS_SOLID  0x00000001
58 #define CONTENTS_DETAIL 0x08000000      // brushes to be added after vis leafs
59 #define CONTENTS_LADDER 0x20000000
60 #define SURF_HINT               0x100   // make a primary bsp splitter
61 #define SURF_SKIP               0x200   // completely ignore, allowing non-closed brushes
62 #define HINT_OFFSET 96
63
64 #define PI 3.14159265358979224
65 #define RadiansToDegrees(a) (floor(a*57.2957795 - 0.5)+1.)
66 #define DegreesToRadians(a) (a/57.2957795)
67
68 #define BOGUS_RANGE     65536
69 #define DotProduct(x,y) (x[0]*y[0]+x[1]*y[1]+x[2]*y[2])
70 #define VectorAdd(a,b,c) {c[0]=a[0]+b[0];c[1]=a[1]+b[1];c[2]=a[2]+b[2];}
71 #define VectorClear(x) {x[0] = x[1] = x[2] = 0;}
72 #define VectorCopy(a,b) {b[0]=a[0];b[1]=a[1];b[2]=a[2];}
73 #define VectorScale(a,b,c) {c[0]=b*a[0];c[1]=b*a[1];c[2]=b*a[2];}
74 #define VectorSubtract(a,b,c) {c[0]=a[0]-b[0];c[1]=a[1]-b[1];c[2]=a[2]-b[2];}
75 #define XYZVectorSubtract(a,b,c) {c[0]=(float)a[0]-(float)b[0];c[1]=(float)a[1]-(float)b[1];c[2]=(float)a[2]-(float)b[2];}
76 #define side(u1,v1,u2,v2,u3,v3) (v3-v1)*(u2-u1) - (u3-u1)*(v2-v1)
77
78 #define QUAKE2    0
79 #define HALFLIFE  1
80 #define SIN       2
81 #define HERETIC2  3
82 #define KINGPIN   4
83 #define GENESIS3D 5
84 #define QUAKE3    6
85
86 #define MAX_FACES_PER_BRUSH 6
87 #define SLIVER_ANGLE DegreesToRadians(20)
88 #define MAX_NODES (MAX_ROWS+1)*(MAX_ROWS+1)
89 #define MAX_TRIS  (MAX_ROWS)*(MAX_ROWS)
90
91 typedef float vec;
92 typedef vec vec3[3];
93 typedef vec vec2[2];
94
95 typedef struct
96 {
97         vec3   v[3];
98         char   texture[64];
99         float  Shift[2];
100         float  Rotate;
101         float  Scale[2];
102         int    Contents;
103         int    Surface;
104         int    Value;
105 } FACE;
106
107 typedef struct
108 {
109         vec3 normal;
110         vec  dist;
111 } PLANE;
112
113 typedef struct
114 {
115         int             numpoints;
116         vec3    p[4];           // variable sized
117 } MY_WINDING;
118
119 typedef struct
120 {
121         int  Number;
122         int  NumFaces;
123         FACE face[MAX_FACES_PER_BRUSH];
124 } BRUSH;
125
126 typedef struct tagXYZ
127 {
128         int fixed;
129         int done;
130         double p[3];
131         double pp[3];    // these used only for general 3D projection (not isometric)
132         double fixed_value;
133         double range;
134         double rate;
135 } XYZ;
136
137 // Q2 PAK file structures
138 typedef struct
139 {
140         char id[4]; // Should be 'PACK'
141         int dstart; // Offest in the file to the directory
142         int dsize;  // Size in bytes of the directory, same as num_items*64
143 } pak_header_t;
144
145 typedef struct
146 {
147         char name[56]; // The name of the item, normal C string
148         int start; // Offset in .pak file to start of item
149         int size; // Size of item in bytes
150 } pak_item_t;
151
152 // SiN .SIN structures
153 #define SINPAKHEADER            (('K'<<24)+('A'<<16)+('P'<<8)+'S')
154 #define MAX_PAK_FILENAME_LENGTH 120
155
156 typedef struct
157 {
158         char    name[MAX_PAK_FILENAME_LENGTH];
159         int             filepos, filelen;
160 } dpackfile_t;
161
162 typedef struct
163 {
164         int             ident;          // == IDPAKHEADER
165         int             dirofs;
166         int             dirlen;
167 } dpackheader_t;
168
169 // Half-Life WAD file structures
170 typedef struct
171 {
172         char            identification[4];              // should be WAD2 or 2DAW
173         int                     numlumps;
174         int                     infotableofs;
175 } wadinfo_t;
176
177 typedef struct
178 {
179         int                     filepos;
180         int                     disksize;
181         int                     size;                                   // uncompressed
182         char            type;
183         char            compression;
184         char            pad1, pad2;
185         char            name[16];                               // must be null terminated
186 } lumpinfo_t;
187
188 typedef struct
189 {
190         int             signature;
191         short   version;
192         short   bitflag;
193         short   compression_method;
194         short   modfiletime;
195         short   modfiledate;
196         int             crc;
197         int             compressed_size;
198         int             uncompressed_size;
199         short   filename_size;
200         short   extra_size;
201 } zipheader_t;
202
203 typedef struct
204 {
205         double  x[2];
206         double  y[2];
207         double  z[2];
208 } bounding_box;
209
210 typedef struct
211 {
212         float p[3];
213         int   used;
214         int   tri;
215         float error;
216         int   fixed;
217 } NODE;
218
219 typedef struct
220 {
221         int   v[3];
222         int   n[3];    // indices of neighboring triangles
223         PLANE plane;
224         int   flag;
225         float min[3];
226         float max[3];
227 } TRI;
228
229 //--------------- bitmap.c -----------------------------
230 bool OpenBitmap ();
231 void GenerateBitmapMapping ();
232 //--------------- face.c -------------------------------
233 void PlaneFromPoints (float *, float *, float *, PLANE *);
234 void CrossProduct (vec3 v1, vec3 v2, vec3 cross);
235 vec VectorNormalize (vec3 in, vec3 out);
236 //--------------- gendlg.c -----------------------------
237 GtkWidget* create_main_dialog ();
238 void About (GtkWidget *parent);
239 //--------------- genmap.c -----------------------------
240 double AtLeast(double,double);
241 bool CanEdit(int, int);
242 void CloseFuncGroup();
243 bool FixedPoint(int,int);
244 void GenerateMap();
245 void GenerateXYZ();
246 double LessThan(double,double);
247 void MakeBrush(BRUSH *);
248 double MoreThan(double,double);
249 double Nearest(double,double);
250 double NoMoreThan(double,double);
251 void OpenFuncGroup();
252 void PlasmaCloud();
253 int PlayerStartZ(double,double);
254 void SubdividePlasma(int,int,int,int);
255 bool ValidSurface();
256 void XYZtoV(XYZ *, vec3 *);
257 void MakePatch(patchMesh_t *);
258 double CalculateSnapValue(double value);
259
260 //---------------- gensurf.c ---------------------------
261 bool GenSurfInit ();
262 void ReadIniFile (const char *);
263 void WriteIniFile (const char *);
264 void OpenSetup (GtkWidget*,int);
265 void SaveSetup (GtkWidget*);
266 //---------------- heretic.c ---------------------------
267 int GetDefSurfaceProps(char *);
268 //---------------- view.c ------------------------------
269 void CreateViewWindow ();
270 void DrawGrid(RECT);
271 void DrawPreview(RECT);
272 void evaluate();
273 void GetScaleFactor(RECT);
274 void project(XYZ *);
275 void Scale(RECT,XYZ,POINT *);
276 void ShowPreview ();
277 void UpdatePreview (bool);
278
279 //---------------- plugin.c -----------------------------
280 void UseFaceBounds();
281
282 extern _QERFuncTable_1 g_FuncTable;
283 extern _QERQglTable g_GLTable;
284 extern _QERUIGtkTable g_UIGtkTable;
285 extern _QEREntityTable g_EntityTable;
286 //#define MAX_ROWS 64
287 #define MAX_ROWS 128
288
289 #define PLANE_XY0 0
290 #define PLANE_XY1 1
291 #define PLANE_YZ0 2
292 #define PLANE_XZ0 3
293 #define PLANE_YZ1 4
294 #define PLANE_XZ1 5
295
296 #define WAVE_COS_SIN    0
297 #define WAVE_HCYLINDER  1
298 #define WAVE_VCYLINDER  2
299 #define WAVE_BITMAP     3
300 #define WAVE_ROUGH_ONLY 4
301 #define WAVE_FORMULA    5
302 #define WAVE_FIRST      WAVE_COS_SIN
303 #define WAVE_LAST       WAVE_FORMULA
304 #define DLG_WAVE_LAST   DLG_WAVE_01+WAVE_LAST-WAVE_FIRST
305
306 #define MSG_VERTEX_SELECTED WM_USER+1
307
308 typedef struct tagMYBITMAP
309 {
310   char             name[NAME_MAX];
311   char             defpath[NAME_MAX];
312   double           black_value;
313   double           white_value;
314   int width, height;
315   unsigned char* colors;
316 } MYBITMAP;
317
318 typedef struct tagELEMENT {
319         int i;
320         int j;
321 } ELEMENT;
322
323 extern char      gszAppDir[NAME_MAX];
324 extern char      gszCaption[64];
325 extern char      gszHelpFile[NAME_MAX];
326 extern char      gszIni[NAME_MAX];
327 extern char      gszMapFile[NAME_MAX];
328 extern char      gszVersion[64];
329 extern double    Amplitude;
330 extern double    Roughness;
331 extern double    TexOffset[2];
332 extern double    TexScale[2];
333 extern double    WaveLength;
334 extern double    Hll, Hur, Vll, Vur;
335 extern double    Z00, Z01, Z10, Z11;
336 extern double    yaw, pitch, roll;
337 extern ELEMENT   Vertex[(MAX_ROWS+1)*(MAX_ROWS+1)];
338 extern int       AddHints;
339 extern int       ArghRad2;
340 extern int       AutoOverwrite;
341 extern int       Decimate;
342 extern int       FileAppend;
343 extern int       FixBorders;
344 extern int       HideBackFaces;
345 extern int       NH, NV;
346 extern int       NumVerticesSelected;
347 extern int       Plane;
348 extern int       Preview;
349 extern int       RandomSeed;
350 extern int       Skybox;
351 extern int       UseDetail;
352 extern int       UseLadder;
353 extern int       VertexMode;
354 extern int       vid_x, vid_y;
355 extern int       WaveType;
356 extern int       gNumNodes;
357 extern int       gNumTris;
358 extern int       view_x, view_y;
359 extern int       view_cx, view_cy;
360 extern int       UsePatches;
361 extern int       SlantAngle;
362 extern int       GimpHints;
363 extern int                       Antialiasing; // ^Fishman - Antializing for the preview window.
364 extern int                       AddTerrainKey; // ^Fishman - Add terrain key to func_group.
365 extern int                       SnapToGrid; // Hydra : snap to grid
366 extern int       SP; // ^Fishman - Snap to grid.
367
368 /*extern HCURSOR   ghCursorCurrent;
369 extern HCURSOR   ghCursorDefault;
370 extern HCURSOR   ghCursorVertex;
371 extern HINSTANCE ghInst;*/
372 extern GtkWidget *g_pRadiantWnd;
373 extern GtkWidget *g_pWnd;
374 /*extern HWND      ghwndAngles;
375 extern HWND      ghwndFix;
376 */extern GtkWidget     *g_pWndPreview;
377 extern GtkWidget *g_pPreviewWidget;
378 extern MYBITMAP  gbmp;
379 extern NODE      *gNode;
380 extern TRI       *gTri;
381 extern XYZ       xyz[MAX_ROWS+1][MAX_ROWS+1];
382
383 extern int       Game;
384 extern bounding_box PlayerBox[NUMGAMES];
385 //extern char      gszOutputDir[NUMGAMES][NAME_MAX];
386 extern char      Texture[NUMGAMES][3][64];
387 //extern char      gszTextureDir[NUMGAMES][NAME_MAX];
388 extern char      GameName[NUMGAMES][16];
389 //extern char      pakfile[NUMGAMES][NAME_MAX];
390 //extern char      lastpakfile[NUMGAMES][NAME_MAX];
391 //extern int       UsePak[NUMGAMES];
392 //extern char      GameDir[NUMGAMES][NAME_MAX];
393 //extern char      ExcelFunc[1024];
394
395 #endif // _GENSURF_H_