2 GenSurf plugin for GtkRadiant
3 Copyright (C) 2001 David Hyde, Loki software and qeradiant.com
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.
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.
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
28 #include "iscenegraph.h"
29 #define USE_QERTABLE_DEFINE
30 #include "qerplugin.h"
31 extern _QERFuncTable_1 g_FuncTable;
34 #include "iselection.h"
36 #define USE_ENTITYTABLE_DEFINE
38 extern _QEREntityTable __ENTITYTABLENAME;
40 #define USE_PATCHTABLE_DEFINE
42 extern _QERPatchTable __PATCHTABLENAME;
44 #define USE_BRUSHTABLE_DEFINE
46 extern _QERBrushTable __BRUSHTABLENAME;
63 typedef struct { long x, y; } Point;
64 typedef struct { long left, top, right, bottom; } Rect;
71 inline bool PtInRect( Rect *rc, Point pt ){
72 if ( pt.x < rc->left ) {
75 if ( pt.x > rc->right ) {
78 if ( pt.y < rc->bottom ) {
81 if ( pt.y > rc->top ) {
89 #define CONTENTS_SOLID 0x00000001
90 #define CONTENTS_DETAIL 0x08000000 // brushes to be added after vis leafs
91 #define CONTENTS_LADDER 0x20000000
92 #define SURF_HINT 0x100 // make a primary bsp splitter
93 #define SURF_SKIP 0x200 // completely ignore, allowing non-closed brushes
94 #define HINT_OFFSET 96
96 #define PI 3.14159265358979224
97 #define RadiansToDegrees( a ) ( floor( a * 57.2957795 - 0.5 ) + 1. )
98 #define DegreesToRadians( a ) ( a / 57.2957795 )
100 #define BOGUS_RANGE 65536
102 #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]; }
103 #define side( u1,v1,u2,v2,u3,v3 ) ( v3 - v1 ) * ( u2 - u1 ) - ( u3 - u1 ) * ( v2 - v1 )
113 #define MAX_FACES_PER_BRUSH 6
114 #define SLIVER_ANGLE DegreesToRadians( 20 )
115 #define MAX_NODES ( MAX_ROWS + 1 ) * ( MAX_ROWS + 1 )
116 #define MAX_TRIS (MAX_ROWS)*( MAX_ROWS )
143 vec3 p[4]; // variable sized
150 FACE face[MAX_FACES_PER_BRUSH];
153 typedef struct tagXYZ
158 double pp[3]; // these used only for general 3D projection (not isometric)
164 // Q2 PAK file structures
167 char id[4]; // Should be 'PACK'
168 int dstart; // Offest in the file to the directory
169 int dsize; // Size in bytes of the directory, same as num_items*64
174 char name[56]; // The name of the item, normal C string
175 int start; // Offset in .pak file to start of item
176 int size; // Size of item in bytes
179 // SiN .SIN structures
180 #define SINPAKHEADER ( ( 'K' << 24 ) + ( 'A' << 16 ) + ( 'P' << 8 ) + 'S' )
181 #define MAX_PAK_FILENAME_LENGTH 120
185 char name[MAX_PAK_FILENAME_LENGTH];
186 int filepos, filelen;
191 int ident; // == IDPAKHEADER
196 // Half-Life WAD file structures
199 char identification[4]; // should be WAD2 or 2DAW
208 int size; // uncompressed
212 char name[16]; // must be null terminated
220 short compression_method;
225 int uncompressed_size;
249 int n[3]; // indices of neighboring triangles
256 //--------------- bitmap.c -----------------------------
258 double CalculateSnapValue( double value );
259 void GenerateBitmapMapping();
260 //--------------- face.c -------------------------------
261 void PlaneFromPoints( float *, float *, float *, PLANE * );
262 //void CrossProduct (vec3 v1, vec3 v2, vec3 cross);
263 //vec VectorNormalize (vec3 in, vec3 out);
264 //--------------- gendlg.c -----------------------------
265 GtkWidget* create_main_dialog();
266 void About( GtkWidget *parent );
267 //--------------- genmap.c -----------------------------
268 double AtLeast( double,double );
269 bool CanEdit( int, int );
270 void CloseFuncGroup();
271 bool FixedPoint( int,int );
274 double LessThan( double,double );
275 void MakeBrush( BRUSH * );
276 double MoreThan( double,double );
277 double Nearest( double,double );
278 double NoMoreThan( double,double );
279 void OpenFuncGroup();
281 int PlayerStartZ( double,double );
282 void SubdividePlasma( int,int,int,int );
284 void XYZtoV( XYZ *, vec3 * );
285 scene::Node* MakePatch( void );
287 //---------------- gensurf.c ---------------------------
289 void ReadIniFile( const char * );
290 void WriteIniFile( const char * );
291 void OpenSetup( GtkWidget*,int );
292 void SaveSetup( GtkWidget* );
293 //---------------- heretic.c ---------------------------
294 int GetDefSurfaceProps( char * );
295 //---------------- view.c ------------------------------
296 void CreateViewWindow();
297 void DrawGrid( Rect );
298 void DrawPreview( Rect );
300 void GetScaleFactor( Rect );
301 void project( XYZ * );
302 void Scale( Rect,XYZ,Point * );
304 void UpdatePreview( bool );
306 //---------------- plugin.c -----------------------------
307 void UseFaceBounds();
309 extern _QERFuncTable_1 g_FuncTable;
310 extern _QERQglTable g_GLTable;
311 extern _QERUIGtkTable g_UIGtkTable;
312 extern _QEREntityTable g_EntityTable;
313 //#define MAX_ROWS 64
323 #define WAVE_COS_SIN 0
324 #define WAVE_HCYLINDER 1
325 #define WAVE_VCYLINDER 2
326 #define WAVE_BITMAP 3
327 #define WAVE_ROUGH_ONLY 4
328 #define WAVE_FORMULA 5
329 #define WAVE_FIRST WAVE_COS_SIN
330 #define WAVE_LAST WAVE_FORMULA
331 #define DLG_WAVE_LAST DLG_WAVE_01 + WAVE_LAST - WAVE_FIRST
333 #define MSG_VERTEX_SELECTED WM_USER + 1
335 typedef struct tagMYBITMAP
338 char defpath[NAME_MAX];
342 unsigned char* colors;
345 typedef struct tagELEMENT {
350 extern char gszAppDir[NAME_MAX];
351 extern char gszCaption[64];
352 extern char gszHelpFile[NAME_MAX];
353 extern char gszIni[NAME_MAX];
354 extern char gszMapFile[NAME_MAX];
355 extern char gszVersion[64];
356 extern double Amplitude;
357 extern double Roughness;
358 extern double TexOffset[2];
359 extern double TexScale[2];
360 extern double WaveLength;
361 extern double Hll, Hur, Vll, Vur;
362 extern double Z00, Z01, Z10, Z11;
363 extern double yaw, pitch, roll;
364 extern ELEMENT Vertex[( MAX_ROWS + 1 ) * ( MAX_ROWS + 1 )];
367 extern int AutoOverwrite;
369 extern int FileAppend;
370 extern int FixBorders;
371 extern int HideBackFaces;
373 extern int NumVerticesSelected;
376 extern int RandomSeed;
378 extern int UseDetail;
379 extern int UseLadder;
380 extern int VertexMode;
381 extern int vid_x, vid_y;
383 extern int gNumNodes;
385 extern int view_x, view_y;
386 extern int view_cx, view_cy;
387 extern int UsePatches;
388 extern int SlantAngle;
389 extern int GimpHints;
390 extern int Antialiasing; // ^Fishman - Antializing for the preview window.
391 extern int AddTerrainKey; // ^Fishman - Add terrain key to func_group.
392 extern int SnapToGrid; // Hydra : snap to grid
393 extern int SP; // ^Fishman - Snap to grid.
396 /*extern HCURSOR ghCursorCurrent;
397 extern HCURSOR ghCursorDefault;
398 extern HCURSOR ghCursorVertex;
399 extern HINSTANCE ghInst;*/
400 extern GtkWidget *g_pRadiantWnd;
401 extern GtkWidget *g_pWnd;
402 /*extern HWND ghwndAngles;
403 extern HWND ghwndFix;
404 */extern GtkWidget *g_pWndPreview;
405 extern GtkWidget *g_pPreviewWidget;
406 extern MYBITMAP gbmp;
409 extern XYZ xyz[MAX_ROWS + 1][MAX_ROWS + 1];
412 extern bounding_box PlayerBox[NUMGAMES];
413 //extern char gszOutputDir[NUMGAMES][NAME_MAX];
414 extern char Texture[NUMGAMES][3][64];
415 //extern char gszTextureDir[NUMGAMES][NAME_MAX];
416 extern char GameName[NUMGAMES][16];
417 //extern char pakfile[NUMGAMES][NAME_MAX];
418 //extern char lastpakfile[NUMGAMES][NAME_MAX];
419 //extern int UsePak[NUMGAMES];
420 //extern char GameDir[NUMGAMES][NAME_MAX];
421 //extern char ExcelFunc[1024];
423 #endif // _GENSURF_H_