]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - radiant/qe3.h
* brush primitive patch by divVerent
[xonotic/netradiant.git] / radiant / qe3.h
1 /*
2 Copyright (C) 1999-2007 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 #ifndef _QE3_H_
23 #define _QE3_H_
24
25 #ifdef _WIN32
26
27 // disable data conversion warnings for gl
28 #pragma warning(disable : 4244)     // MIPS
29 #pragma warning(disable : 4136)     // X86
30 #pragma warning(disable : 4051)     // ALPHA
31 #pragma warning(disable : 4800)
32 #endif
33
34 // for interfaces, we require main plugin header included
35 #include "iplugin.h"
36 #include "qerplugin.h"
37 #include "qertypes.h"
38
39 #include "missing.h" // temporary stuff, needs to be removed
40 #include "idatastream.h"
41 #include "file.h"
42
43 #include "qgl.h"
44
45 #include <gtk/gtk.h>
46 #include <math.h>
47 #include <stdlib.h>
48
49 #include <stdio.h>
50
51 // this is the version to expect from template projects
52 #define PROJECT_VERSION 2
53
54 //#define MEM_DEBUG
55 #ifdef MEM_DEBUG
56
57 #define malloc(a) debug_malloc(a, __FILE__, __LINE__)
58 #define free(a) debug_free(a, __FILE__, __LINE__)
59
60 void* debug_malloc (size_t size, const char* file, int line);
61 void debug_free (void *buf, const char* file, int line);
62
63 #endif
64
65 #ifdef _DEBUG
66 //#define DBG_WINDOWPOS
67 #endif
68
69 #ifdef DBG_WINDOWPOS
70 void CheckWatchit(char *msg);
71 #endif
72
73 // those two files are generated
74 // if they are missing, you NEED to run makeversion.sh
75 // NOTE: for win32 users, cygwin installation is REQUIRED to run makeversion.sh
76 // NOTE TTimo if any of those changes (they might change a lot), then the whole app is rebuilt.
77 //   very often it's not necessary
78 #include "version.h"
79 #include "aboutmsg.h"
80
81 // synapse is our utility lib for dynamic shared objects management
82 #include "synapse.h"
83
84 #include "qertypes.h"
85 #include "cmdlib.h"
86 #include "mathlib.h"
87 #include "parse.h"
88
89 #include "qedefs.h"
90 #include "qfiles.h"
91 #include "textures.h"
92 #include "brush.h"
93 //#include "entity.h"
94 #define USE_ENTITYTABLE_DEFINE
95 #include "ientity.h"
96 extern _QEREntityTable __ENTITYTABLENAME;
97 // wrappers for brush access
98 #include "ibrush.h"
99 // wrappers for patch access
100 #include "ipatch.h"
101
102 #include "imodel.h"
103
104 #include "imap.h"
105
106 #include "iundo.h"
107
108 extern _QERPlugMapTable g_MapTable;
109
110 //++timo for BP conversion escaping FIXME: remove when mixing two formats!
111 extern bool g_bCancel_Map_LoadFile;
112 // used to be #defines, multiple engine support suggests we should go towards dynamic
113 extern int g_MaxWorldCoord;
114 extern int g_MinWorldCoord;
115 extern int g_MaxBrushSize;
116 /*
117 // set to true when we are parsing a terrain entity
118 extern bool g_bParseTerrain;
119 extern IShader *g_pTerrainShader, *g_pCaulk;
120 */
121 #include "map.h"
122
123 #include "select.h"
124
125 #include "camera.h"
126 #include "z.h"
127
128 #include "undo.h"
129 #include "glwidget.h"
130
131 // the dec offsetof macro doesn't work very well...
132 #define myoffsetof(type,identifier) ((size_t)&((type *)0)->identifier)
133
134 // set these before calling CheckParm
135 extern int myargc;
136 extern char **myargv;
137
138 // our own implementation of Q_int, clamping can be disabled on prefs
139 vec_t Rad_rint (vec_t in);
140
141 double I_FloatTime (void);
142
143 void   Error (const char *error, ...);
144 int    CheckParm (const char *check);
145 void   ParseCommandLine (char *lpCmdLine);
146
147 int    ParseNum (const char *str);
148
149 char*  COM_Parse (char *data);
150 char*  Get_COM_Token();
151
152 extern  char            com_token[1024];
153 extern  qboolean        com_eof;
154
155 #define MAX_NUM_ARGVS   32
156 extern  int             argc;
157 extern  char            *argv[MAX_NUM_ARGVS];
158
159 //
160 // system functions
161 //
162 // TTimo NOTE: WINAPI funcs can be accessed by plugins
163 void    Sys_UpdateStatusBar( void );
164 void    WINAPI Sys_UpdateWindows (int bits);
165 void    Sys_Beep (void);
166 void    Sys_ClearPrintf (void);
167 double  Sys_DoubleTime (void);
168 void    Sys_GetCursorPos (int *x, int *y);
169 void    Sys_SetCursorPos (int x, int y);
170 void    Sys_SetTitle (const char *text);
171 void    WINAPI Sys_BeginWait (void);
172 void    WINAPI Sys_EndWait (void);
173 void    Sys_Status(const char *psz, int part);
174 bool    Sys_AltDown ();
175 bool    Sys_ShiftDown ();
176 // will open/close/check the log file based on the following globals:
177 // g_PrefsDlg.m_bLogConsole g_qeglobals.hLogFile
178 void    Sys_LogFile (void);
179
180 extern  qboolean verbose;
181 #include "qsysprintf.h"
182
183 // NOTE TTimo I split out the GUI-depependant stuff from QEGlobals_t into a seperate struct
184 typedef struct
185 {
186   // GL widget of the camera view
187   // all textures are binded in this context and shared with the others
188   GtkWidget *d_glBase;
189
190   GtkWidget *d_main_window; // d_hwndMain
191   GtkWidget *d_edit;        // d_hwndEdit
192   GtkWidget *d_entity;      // d_hwndEntity
193   GtkWidget *d_camera;      // d_hwndCamera;
194   GtkWidget *d_texture;     // d_hwndTexture;
195   GtkWidget *d_texture_scroll;
196   GtkWidget *d_z;           // d_hwndZ;
197
198 } QEGlobals_GUI_t;
199
200 // usefull portability stuff
201 //++timo move them somewhere
202 bool DoesFileExist(const char* pBuff, long& lSize);
203
204 char *copystring (char *s);
205 char *ExpandReletivePath (char *p);
206
207 #include "xmlstuff.h"
208 #include "points.h"
209
210 //
211 // drag.c
212 //
213 void Drag_Begin (int x, int y, int buttons, vec3_t xaxis, vec3_t yaxis, vec3_t origin, vec3_t dir, bool sf_camera = false);
214 void Drag_MouseMoved (int x, int y, int buttons);
215 void Drag_MouseUp (int nButtons = 0);
216
217 //
218 // csg.c
219 //
220 void CSG_MakeHollow (void);
221 void CSG_Subtract (void);
222 void CSG_Merge (void);
223
224 //
225 // vertsel.c
226 //
227
228 void SetupVertexSelection (void);
229 void SelectEdgeByRay (vec3_t org, vec3_t dir);
230 void SelectVertexByRay (vec3_t org, vec3_t dir);
231
232 void ConnectEntities (void);
233
234 extern  int     update_bits;
235
236 extern  int     screen_width;
237 extern  int     screen_height;
238
239 char *TranslateString (char *buf);
240
241 //
242 // linux_qe3.cc
243 //
244 //void OpenDialog ();
245 //void SaveAsDialog (bool bRegion);
246 void ProjectDialog (void);
247 void MRU_Load ();
248 void MRU_Save ();
249 void MRU_AddWidget (GtkWidget *widget, int pos);
250 void MRU_AddFile (const char *str);
251 void MRU_Activate (int index);
252
253
254 void FillTextureMenu (GSList** pArray = NULL);
255 void FillBSPMenu (void);
256
257 // profile functions - kind of utility lib
258 // they are kind of dumb, they expect to get the path to the .ini file or to the prefs directory when called
259 // load_buffer and save_buffer expect the path only, theyll build a $(pszName).bin file
260 bool WINAPI profile_save_int (const char *filename, const char *section, const char *key, int value);
261 bool WINAPI profile_save_float (const char *filename, const char *section, const char *key, float value);
262 bool WINAPI profile_save_string (const char *filename, const char *section, const char *key, const char *value);
263 bool profile_save_buffer (const char *rc_path, const char *pszName, void *pvBuf, guint32 lSize);
264 bool profile_load_buffer (const char *rc_path, const char *pszName, void *pvBuf, guint32 *plSize);
265 int WINAPI profile_load_int (const char *filename, const char *section, const char *key, int default_value);
266 float WINAPI profile_load_float (const char *filename, const char *section, const char *key, float default_value);
267 char* WINAPI profile_load_string (const char *filename, const char *section, const char *key, const char *default_value);
268 // used in the command map code
269 bool read_var (const char *filename, const char *section, const char *key, char *value);
270
271 //
272 // entityw.c
273 //
274 void FillClassList (void);
275 bool UpdateEntitySel(eclass_t *pec);
276 void SetInspectorMode(int iType);
277 void SetSpawnFlags(void);
278 void GetSpawnFlags(void);
279 void SetKeyValuePairs(bool bClearMD3 = false);
280 extern void BuildGammaTable(float g);
281 bool GetSelectAllCriteria(CString &strKey, CString &strVal);
282
283 // linux_dlg.c
284
285 typedef enum {
286   BEVEL = 0,
287   ENDCAP,
288   IBEVEL,
289   IENDCAP
290 } CapDialog;
291
292 int DoCapDlg (int *type, bool *b_GroupResul);
293 int DoBSInputDlg (const char *fields[5], float values[5]);
294 int DoTextureLayout (float *fx, float *fy);
295 char* DoNameDlg (const char* title);
296 char* DoNewProjectDlg ();
297 /*
298 text editor, open filename at given line
299 opening at line works only for win32 / editpad and builtin Gtk editor
300
301 we only allow one instance of the Gtk editor widget opened at a given time
302 if we get called with an existing instance, switch to new file ..
303 */
304 void DoTextEditor (const char* filename, int cursorpos);
305 int DoLightIntensityDlg (int *intensity);
306
307 void DoMapInfo ();
308 void DoEntityList ();
309 void DoGamma();
310 void DoFind();
311 void DoRotateDlg ();
312 void DoSides(bool bCone = false, bool bSphere = false, bool bTorus = false);
313 void DoAbout();
314 void DoSnapTToGrid(float hscale = 0.0f, float vscale = 0.0f);
315 void DoSurface();
316 void ToggleSurface(); // will show/hide depending on the current state
317 void DoNewPatchDlg ();
318 void DoThickenDlg ();
319 void DoCommandListDlg ();
320 void DoScaleDlg ();;
321 void DoTextureListDlg ();
322 void DoScriptsDlg ();
323
324 // QE function declarations
325 void     QE_CheckAutoSave( void );
326 void     WINAPI QE_ConvertDOSToUnixName( char *dst, const char *src );
327 void     QE_CountBrushesAndUpdateStatusBar( void );
328 void     WINAPI QE_CheckOpenGLForErrors(void);
329 void     QE_ExpandBspString (char *bspaction, GPtrArray & out, char *mapname);
330 // initialise the VFS from current project settings
331 void     QE_InitVFS();
332 // do all initialisations that should happen after a project is load (during startup or project change)
333 void     QE_Init (void);
334 qboolean QE_KeyDown (int key, int nFlags = 0);
335 // does some sanity checks on the project entity, such as removing ending filename seperators from paths
336 // (this usually gets propagated to the actual project file since most of the time we save right after calling the check)
337 void     QE_CheckProjectEntity();
338 // this will load a new project entity in memory, and potentially process it from a template
339 // NOTE TTimo calling QE_LoadProject won't take care of the various initialisation that are performed depending on the project settings
340 //   you should then call QE_Init for that
341 #define PROJECT_TEMPLATE_NAME "default_project.proj"
342 #define PROJECT_USER_NAME "user_project.proj"
343 #define PROJECT_FILETYPE "proj"
344 qboolean QE_LoadProject (const char *projectfile);
345 qboolean QE_SingleBrush (bool bQuiet = false);
346
347
348 // sys stuff
349 void Sys_MarkMapModified (void);
350
351 #if 0 // no longer used
352
353 // QE Win32 function declarations
354 #ifdef _WIN32
355 int  WINAPI QEW_SetupPixelFormat(HDC hDC, qboolean zbuffer );
356 void QEW_StopGL( HWND hWnd, HGLRC hGLRC, HDC hDC );
357 #endif
358
359 #endif
360
361 // extern declarations
362 extern QEGlobals_t   g_qeglobals;
363 extern QEGlobals_GUI_t g_qeglobals_gui;
364
365 qboolean IsBrushSelected(brush_t* bSel);
366
367 // curve brushes
368
369 void Curve_MakeCurvedBrush (qboolean negative, qboolean top, qboolean bottom,
370                                         qboolean s1, qboolean s2, qboolean s3, qboolean s4);
371
372 void Curve_Invert (void);
373
374 void Curve_AddFakePlanes( brush_t *B );
375 void Curve_StripFakePlanes( brush_t *B );
376 void Curve_BuildPoints (brush_t *b);
377 void Curve_XYDraw (brush_t *b);
378 void Curve_CameraDraw (brush_t *b);
379
380 void Curve_WriteFile (char *name);
381
382
383 // patch stuff
384 patchMesh_t *Patch_Alloc();
385 patchMesh_t* MakeNewPatch();
386 brush_t* AddBrushForPatch(patchMesh_t *pm, bool bLinkToWorld = true);
387 brush_t* Patch_GenericMesh(int nWidth, int nHeight, int nOrientation = 2, bool bDeleteSource = true, bool bOverride = false);
388 //void Patch_ReadFile (char *name);
389 //void Patch_WriteFile (char *name);
390 void Patch_BuildPoints (brush_t *b);
391 void Patch_Move(patchMesh_t *p, const vec3_t vMove, bool bRebuild = false);
392 //++timo had to add a default value for bSnap (see Patch_ApplyMatrix call from Select_ApplyMatrix in select.cpp)
393 void Patch_ApplyMatrix(patchMesh_t *p, const vec3_t vOrigin, const vec3_t vMatrix[3], bool bSnap = false);
394 void Patch_EditPatch();
395 void Patch_Deselect();
396 void Patch_Deselect(patchMesh_t *p);
397 void Patch_Delete(patchMesh_t *p);
398 int  Patch_MemorySize(patchMesh_t *p);
399 void Patch_Select(patchMesh_t *p);
400 void Patch_Scale(patchMesh_t *p, const vec3_t vOrigin, const vec3_t vAmt, bool bRebuilt = true);
401 void Patch_Cleanup();
402 void Patch_SetView(int n);
403 void Patch_SetTexture(patchMesh_t *p, texdef_t *tex_def, IPluginTexdef* pPlugTexdef = NULL);
404 void Patch_BrushToMesh(bool bCone = false, bool bBevel = false, bool bEndcap = false, bool bSquare = false, int nHeight = 3);
405 bool Patch_DragScale(patchMesh_t *p, vec3_t vAmt, vec3_t vMove);
406 //void Patch_ReadBuffer(char* pBuff, bool bSelect = false);
407 //void Patch_WriteFile (MemStream* pMemFile);
408 void Patch_UpdateSelected(vec3_t vMove);
409 //brush_t* Patch_Parse(bool bOld);
410 //void Patch_Write (patchMesh_t *p, FILE *f);
411 //void Patch_Write (patchMesh_t *p, MemStream *file);
412 //void Patch_AdjustColumns(patchMesh_t *p, int nCols);
413 //void Patch_AdjustRows(patchMesh_t *p, int nRows);
414 void Patch_AdjustSelected(bool bInsert, bool bColumn, bool bFlag);
415 patchMesh_t* Patch_Duplicate(patchMesh_t *pFrom);
416 void Patch_RotateTexture(patchMesh_t *p, float fAngle);
417 void Patch_ScaleTexture(patchMesh_t *p, float fx, float fy, bool bFixup = true);
418 // shift of some pixel amount
419 void Patch_ShiftTexture(patchMesh_t *p, float fx, float fy);
420 // shift of ST increments
421 void Patch_ShiftTextureST(patchMesh_t *p, float fx, float fy);
422 void Patch_DrawCam(patchMesh_t *p);
423 void Patch_DrawXY(patchMesh_t *p);
424 void Patch_InsertColumn(patchMesh_t *p, bool bAdd);
425 void Patch_InsertRow(patchMesh_t *p, bool bAdd);
426 void Patch_RemoveRow(patchMesh_t *p, bool bFirst);
427 void Patch_RemoveColumn(patchMesh_t *p, bool bFirst);
428 void Patch_ToggleInverted();
429 void Patch_Restore(patchMesh_t *p);
430 void Patch_Save(patchMesh_t *p);
431 void Patch_SetTextureInfo(texdef_t* pt);
432 void Patch_NaturalTexturing();
433 void Patch_ResetTexturing(float fx, float fy);
434 void Patch_FitTexturing();
435 void Patch_BendToggle();
436 //void Patch_StartInsDel();
437 void Patch_BendHandleTAB();
438 void Patch_BendHandleENTER();
439 void Patch_SelectBendNormal();
440 void Patch_SelectBendAxis();
441 bool OnlyPatchesSelected();
442 bool AnyPatchesSelected();
443 patchMesh_t* SinglePatchSelected();
444 void Patch_CapCurrent();
445 void Patch_DisperseRows();
446 void Patch_DisperseIntermediateRows();
447 void Patch_DisperseIntermediateColumns();
448 void Patch_CycleCapSelected();
449 void Patch_NaturalizeSelected(bool bCap = false);//, bool bCycleCap = false);
450 void Patch_SelectAreaPoints(bool bMulti);
451 void Patch_InvertTexture(bool bY);
452 void patchInvert(patchMesh_t *p);
453 //void Patch_InsDelToggle();
454 //void Patch_InsDelHandleTAB();
455 //void Patch_InsDelHandleENTER();
456 void Patch_SetOverlays();
457 void Patch_ClearOverlays();
458 void Patch_Thicken(int nAmount, bool bSeam, qboolean bGroupResult);
459 void Patch_Transpose();
460 void Patch_Freeze();
461 void Patch_UnFreeze(bool bAll);
462 const char* Patch_GetTextureName();
463 void Patch_FindReplaceTexture(brush_t *pb, const char *pFind, const char *pReplace, bool bForce);
464 void Patch_SnapToGrid(patchMesh_t *p);
465 extern bool g_bPatchShowBounds;
466 extern bool g_bPatchWireFrame;
467 extern bool g_bPatchWeld;
468 extern bool g_bPatchDrillDown;
469 //extern bool g_bPatchInsertMode;
470 extern bool g_bPatchBendMode;
471 extern vec3_t g_vBendOrigin;
472 //void Patch_FromTriangle(vec5_t vx, vec5_t vy, vec5_t vz);
473 const char* Patch_GetKeyValue(patchMesh_t *p, const char *pKey);
474 void Patch_SetEpair(patchMesh_t *p, const char *pKey, const char *pValue);
475 void Patch_LODMatchAll();
476 void Patch_CalcBounds(patchMesh_t *p, vec3_t& vMin, vec3_t& vMax);
477
478
479
480
481 // group stuff
482 // group_t are loaded / saved through "group_info" entities
483 // they hold epairs for group settings and additionnal access info (tree nodes)
484 typedef struct group_s
485 {
486   struct group_s *next;
487   epair_t *epairs;
488 #if 0 //! Deprecated in gtk 2.x.
489   GtkCTreeNode *itemOwner;
490 #endif
491 } group_t;
492
493 // NOTES: grouping only enabled in brush primitives mode
494 // grouping works by naming brushes and setting display properties
495 // the group hierarchy is not related with the map hierarchy (entity list, brushes etc.)
496 // brushes with no group are under the "world" node (default for all brushes)
497 // void Group_GetListFromWorld(CStringArray *pArray);
498 void Group_RemoveListFromWorld();
499 // void Group_SetListToWorld(CStringArray *pArray);
500 // void Group_BuildTree(CTreeCtrl *pTree);
501 // void Group_DecomposeTree(CTreeCtrl *pTree);
502 // save group_t as "classname" "group_info" things
503 void Group_Save(FILE *f);
504 // clean the brushes ownerItem, clean the treeview and rebuild everything
505 // is usually called when loading a new map, but may be called anytime
506 void Group_Init();
507 void Group_Add(entity_t *e);
508
509 // remove a brush from it's current group, will erase the "group" epair if any, and delete the tree control node
510 void Group_RemoveBrush(brush_t *b);
511 void Group_AddToWorld(brush_t *b);
512 // will remove brush of it's current group if any, and will add it wherever needed according to it's "group" key
513 void Group_AddToProperGroup(brush_t *b);
514 void Group_AddToSelected(brush_t *b);
515 // allocate a new group, set name
516 group_t* Group_Alloc(const char *name);
517 // we use entities to store information about the groups
518 // these entities are not linked into the world, and they have no brushes
519 // only loaded / saved in map file
520 group_t* Group_ForName(const char *name);
521
522 // TTimo
523 // new brush primitive stuff
524
525 #ifdef _DEBUG
526 //#define DBG_BP
527 #endif
528
529 // get the relative axes of the current texturing
530 void BrushPrimit_GetRelativeAxes(face_t *f, vec3_t vecS, vec3_t vecT);
531 // brush primitive stuff
532 void ComputeAxisBase(vec3_t normal, vec3_t texS, vec3_t texT );
533 void FaceToBrushPrimitFace(face_t *f);
534 void BrushPrimitFaceToFace(face_t *f);
535 void EmitBrushPrimitTextureCoordinates(face_t *, winding_t *);
536 // EmitTextureCoordinates, is old code used for brush to brush primitive conversion
537 void EmitTextureCoordinates ( float *xyzst, qtexture_t *q, face_t *f);
538 void Face_TexdefFromTextureCoordinates ( float *xyzst1, float *xyzst2, float *xyzst3, qtexture_t *q, face_t *f);
539 //void BrushPrimit_Parse(brush_t *);
540 // compute a fake shift scale rot representation from the texture matrix
541 void TexMatToFakeTexCoords( vec_t texMat[2][3], float shift[2], float *rot, float scale[2] );
542 void FakeTexCoordsToTexMat( float shift[2], float rot, float scale[2], vec_t texMat[2][3] );
543 void ConvertTexMatWithQTexture( vec_t texMat1[2][3], qtexture_t *qtex1, vec_t texMat2[2][3], qtexture_t *qtex2 );
544 // NOTE: this is a wrapper over the vec_t mat[2][3] version
545 void ConvertTexMatWithQTexture( brushprimit_texdef_t *texMat1, qtexture_t *qtex1, brushprimit_texdef_t *texMat2, qtexture_t *qtex2 );
546 // texture locking
547 void ShiftTextureGeometric_BrushPrimit(face_t *f, vec3_t delta);
548 void ShiftTextureRelative_BrushPrimit( face_t *f, float x, float y );
549 void RotateFaceTexture_BrushPrimit(face_t *f, int nAxis, float fDeg, vec3_t vOrigin );
550 // used in CCamWnd::ShiftTexture_BrushPrimit
551 void ComputeBest2DVector( vec3_t v, vec3_t X, vec3_t Y, int &x, int &y );
552 void Face_FitTexture_BrushPrimit( face_t *face, vec3_t minx, vec3_t maxs, int nHeight, int nWidth );
553 // lock textures on a random transformation
554 void ApplyMatrix_BrushPrimit(face_t *f, vec3_t matrix[3], vec3_t origin);
555 // low level functions .. put in mathlib?
556 #define BPMatCopy(a,b) {b[0][0] = a[0][0]; b[0][1] = a[0][1]; b[0][2] = a[0][2]; b[1][0] = a[1][0]; b[1][1] = a[1][1]; b[1][2] = a[1][2];}
557 // apply a scale transformation to the BP matrix
558 #define BPMatScale(m,sS,sT) {m[0][0]*=sS; m[1][0]*=sS; m[0][1]*=sT; m[1][1]*=sT;}
559 // apply a translation transformation to a BP matrix
560 #define BPMatTranslate(m,s,t) {m[0][2] += m[0][0]*s + m[0][1]*t; m[1][2] += m[1][0]*s+m[1][1]*t;}
561 // 2D homogeneous matrix product C = A*B
562 void BPMatMul(vec_t A[2][3], vec_t B[2][3], vec_t C[2][3]);
563 // apply a rotation (degrees)
564 void BPMatRotate(vec_t A[2][3], float theta);
565 #ifdef _DEBUG
566 void BPMatDump(vec_t A[2][3]);
567 #endif
568 // GL matrix product
569 void GLMatMul(vec_t M[4][4], vec_t A[4], vec_t B[4]);
570 qboolean IsBrushPrimitMode();
571 //
572 // eclass.cpp
573 //
574 #include "ieclass.h"
575
576 /*!
577   \todo those are at the eclass manager level, but some documentation about what they do will be helpful
578 */
579 extern qboolean parsing_single;
580 extern qboolean eclass_found;
581 extern eclass_t *eclass_e;
582 extern eclass_t *g_md3Cache;
583
584 /*!
585 eclass manager API
586 */
587 void Eclass_InsertAlphabetized(eclass_t *e);
588 eclass_t** Get_EClass_E();
589 void Set_Eclass_Found(qboolean);
590 qboolean Get_Parsing_Single();
591
592 // .def loading, builtin module
593 #include "eclass_def.h"
594 extern CSynapseBuiltinClientDef eclass_def;
595
596 /*!
597 global table to .def entity class description
598 this is a builtin module, even if we rely on fgd, we still use this one in cases such as entities not found etc.
599 */
600 extern _EClassTable g_EClassDefTable;
601
602 /*!
603 support for one additional/optional entity format
604 */
605 extern bool g_bHaveEClassExt;
606 extern _EClassTable g_EClassExtTable;
607
608
609 #include "iplugin.h"
610 // for interfaces, we require main plugin header included
611 #include "qerplugin.h"
612
613 //
614 // SurfaceDlg.cpp and surface properties plugin
615 //
616 //++timo some patch in/out stuff is in there, needs to be moved out in a dedicated interface
617 #include "isurfaceplugin.h"
618 #include "surfaceplugin.h"
619 void WINAPI Patch_Rebuild(patchMesh_t *p);
620 #include "isurfaceplugin.h"
621 extern _QERPlugSurfaceTable g_SurfaceTable;
622 void SurfaceDlgFitAll();
623
624 //
625 // OpenGL interface
626 //
627 #include "igl.h"
628
629 GtkWidget* WINAPI QERApp_GetQeglobalsGLWidget();
630 void WINAPI QERApp_HookGL2DWindow(IGL2DWindow* pGLW);
631 void WINAPI QERApp_UnHookGL2DWindow(IGL2DWindow* pGLW);
632 void WINAPI QERApp_HookGL3DWindow(IGL3DWindow* pGLW);
633 void WINAPI QERApp_UnHookGL3DWindow(IGL3DWindow* pGLW);
634 void Draw2DPluginEntities( VIEWTYPE vt );
635 void Draw3DPluginEntities();
636
637 //
638 // IShaders interface
639 //
640 #define USE_SHADERSTABLE_DEFINE
641 #include "ishaders.h"
642 extern _QERShadersTable g_ShadersTable;
643
644 //
645 // ISelectedFace interface
646 //
647 #include "iselectedface.h"
648 int WINAPI QERApp_GetSelectedFaceCount();
649 // NOTE: it's the brush corresponding to the selected face below!
650 brush_t* WINAPI QERApp_GetSelectedFaceBrush(int iface);
651 face_t* WINAPI QERApp_GetSelectedFace(int iface);
652 int WINAPI QERApp_GetFaceInfo(int iface, _QERFaceData *pFaceData, winding_t *pWinding);
653 int WINAPI QERApp_SetFaceInfo(int iface, _QERFaceData *pFaceData);
654 int WINAPI QERApp_ISelectedFace_GetTextureNumber(int iface);
655 void WINAPI QERApp_GetTextureSize(int iface, int Size[2]);
656
657 //
658 // IEpairs interface
659 //
660 //#include "iepairs.h"
661 //#include "epairswrapper.h"
662
663 //
664 // IImage interface
665 //
666 #include "iimage.h"
667
668 //
669 // IFileSystem interface
670 //
671 #define USE_VFSTABLE_DEFINE
672 #include "ifilesystem.h"
673
674 extern _QERFileSystemTable g_FileSystemTable;
675
676 //
677 // TexWnd.cpp
678 //
679 extern qboolean g_bShowAllShaders;
680
681 //
682 // texwindow.cpp
683 //
684 //++timo TODO: we can probably raise the MAX_TEXTUREDIRS limit?
685 #define         MAX_TEXTUREDIRS 256
686
687 extern CPtrArray g_lstSkinCache;
688 qtexture_t *QERApp_LoadTextureRGBA(unsigned char* pPixels, int nWidth, int nHeight);
689
690 //
691 // IScripLib interface
692 // GetToken, UnGetToken, etc.
693 #include "iscriplib.h"
694 extern FILE *g_File;
695 void WINAPI QERApp_MapPrintf_FILE( char *text, ... );
696
697 //
698 // ISurfacePlugin interface
699 //
700 void QERApp_GetTwoSelectedPatch( patchMesh_t **p1, patchMesh_t **p2 );
701
702 //
703 // IBSPFrontend interface
704 //
705 #include "ibspfrontend.h"
706 extern _QERPlugBSPFrontendTable g_BSPFrontendTable;
707 extern GSList *g_BSPFrontendCommands;
708
709 //
710 // IToolbar
711 //
712 #include "itoolbar.h"
713
714 //
715 // IMessaging interface
716 #include "iui.h"
717 #include "iui_gtk.h"
718 #include "ui.h"
719 IWindow* WINAPI QERApp_CreateGLWindow();
720 void WINAPI QERApp_HookWindow(IWindowListener* pListen);
721 void WINAPI QERApp_UnHookWindow(IWindowListener* pListen);
722 IXYWndWrapper* WINAPI QERApp_GetXYWndWrapper();
723 void WINAPI QERApp_HookListener(IListener* pListen, int Msg);
724 int  WINAPI QERApp_UnHookListener(IListener* pListen);
725 void DispatchRadiantMsg( int Msg );
726 // dispatch for IWindowListener entities
727 void DispatchOnMouseMove(guint32 nFlags, int x, int y);
728 bool DispatchOnLButtonDown(guint32 nFlags, int x, int y);
729 bool DispatchOnLButtonUp(guint32 nFlags, int x, int y);
730
731 //
732 // IData interface
733 //
734 #include "idata.h"
735
736 //
737 // ICamera interface
738 //
739 #include "icamera.h"
740
741 // Some declarations that were in stdafx.h
742
743 // main.cpp
744 extern gint try_destroy_splash(gpointer);
745
746 #include "mainframe.h"
747 #include "preferences.h"
748 #include "findtexturedialog.h"
749 #include "surfacedialog.h"
750 #include "patchdialog.h"
751
752 class MainFrame;
753 class ClipPoint;
754
755 extern MainFrame* g_pParentWnd;
756 extern CString g_strAppPath;
757 extern CString g_strDTDPath;
758 extern CString g_pidFile;
759 extern CString g_pidGameFile;
760 extern CString g_strBitmapsPath;
761 extern CString g_strPluginsDir;
762 extern CString g_strModulesDir;
763
764 extern CGameDescription *g_pGameDescription;
765 extern CString g_strGameToolsPath;
766
767 extern CString g_strTempPath;
768 extern PrefsDlg& g_PrefsDlg;
769 extern FindTextureDialog& g_dlgFind;
770 extern SurfaceDlg g_dlgSurface;
771 extern PatchDialog g_PatchDialog;
772
773 extern int g_bIgnoreCommands;
774
775 void HideInfoDialog();
776 void ShowInfoDialog(const char* pText);
777
778 // externs
779 //extern void HandleCommand (GtkWidget *widget, gpointer data, bool keydown);
780 extern gint HandleCommand (GtkWidget *widget, gpointer data);
781 extern void AddSlash(CString&);
782 extern void DLLBuildDone();
783 extern void CleanUpEntities();
784 extern void FindReplace(CString& strContents, const char* pTag, const char* pValue);
785 extern void CheckBspProcess();
786 extern void QE_CountBrushesAndUpdateStatusBar();
787 extern void     QE_CheckAutoSave();
788 extern qtexture_t       *current_texture;
789 extern void SaveWithRegion(char *name); // save the current map, sets the map name in the name buffer (deals with regioning)
790 extern void RunBsp (char *command);
791 extern void Map_Snapshot();
792 extern void WXY_Print();
793 extern void AddProp( void );
794 extern qboolean DoColor(int iIndex);
795 extern entity_t *edit_entity;
796 extern int inspector_mode;
797 extern bool g_bRotateMode;
798 extern bool g_bClipMode;
799 extern bool g_bScaleMode;
800 extern int g_nScaleHow;
801 extern bool g_bPathMode;
802 extern void RunScript(char* pBuffer);
803 extern bool ExtractPath_and_Filename(const char* pPath, CString& strPath, CString& strFilename);
804 extern void Select_Scale(float x, float y, float z);
805 extern void Select_RotateTexture(int amt);
806 extern void Select_ScaleTexture(float x, float y);
807 extern void Select_ShiftTexture(int x, int y);
808 extern void FindReplaceTextures(const char* pFind, const char* pReplace, bool bSelected, bool bForce, bool bSelectMatchingFaces);
809 /*!
810 \fn DoProjectSettings shows the dialog for per-game configurable settings by the user
811 typically this sets up things like mod editing configuration
812 those a per-project, not the same thing as preferences which are global to the game conf
813 this is still being worked on, as we have several issues with how things are configured
814 we also have a number of behaviours defined in the .game, which can't be edited graphically
815 we dump those properties to the console when the project settings dialog shows up
816 */
817 extern void DoProjectSettings();
818 extern qboolean region_active;
819 extern void Brush_Print(brush_t* b);
820 extern void Texture_ShowStartupShaders();
821 extern void Map_ImportFile (char *filename);
822 extern void Map_SaveSelected(char* pFilename);
823 extern void UpdateSurfaceDialog();
824 extern void Select_GetTrueMid (vec3_t mid);
825 extern bool g_bSwitch;
826 extern brush_t g_brFrontSplits;
827 extern brush_t g_brBackSplits;
828 extern ClipPoint g_Clip1;
829 extern ClipPoint g_Clip2;
830 extern brush_t* g_pSplitList;
831 extern ClipPoint g_PathPoints[256];
832 extern void AcquirePath(int nCount, PFNPathCallback* pFunc);
833 extern bool g_bScreenUpdates;
834 extern SCommandInfo g_Commands[];
835 extern int g_nCommandCount;
836 extern SKeyInfo g_Keys[];
837 extern int g_nKeyCount;
838 extern int inspector_mode;
839 extern char     *bsp_commands[256];
840 extern void RunScriptByName(char*, bool);
841 extern void DoNewColor(int* i1, int* i2, int* i3);
842 extern void UpdateSurfaceDialog();
843 extern void CSG_SplitBrushByFace (brush_t *in, face_t *f, brush_t **front, brush_t **back);
844 //extern void HandlePopup(CWnd* pWindow, unsigned int uId);
845 extern z_t z;
846 extern void Select_Scale(float x, float y, float z);
847 extern void TextureAxisFromPlane(plane_t *pln, vec3_t xv, vec3_t yv);
848 //extern void VectorRotate (vec3_t va, vec3_t vb, vec3_t out);
849 //extern void VectorRotate (vec3_t vIn, vec3_t vRotation, vec3_t vOrigin, vec3_t out);
850 extern qboolean QE_SaveProject (const char* pProjectFile);
851 //extern void NewBSP(char* pCommandLine, HWND);
852 //extern void NewVIS(char* pCommandLine, HWND);
853 //extern void NewRAD(char* pCommandLine, HWND);
854 extern void RunTools(char* pCommandLine, GtkWidget* hwnd, const char* pPAKFile);
855 extern void Clamp(float& f, int nClamp);
856 extern void MemFile_fprintf(MemStream* pMemFile, const char* pText, ...);
857 //extern void SaveWindowPlacement(HWND hwnd, const char* pName);
858 //extern bool LoadWindowPlacement(HWND hwnd, const char* pName);
859 extern qboolean ConfirmModified (void);
860 extern void DoPatchInspector();
861 extern void TogglePatchInspector();
862 void UpdatePatchInspector();
863 extern int BuildShortPathName(const char* pPath, char* pBuffer, int nBufferLen);
864 extern int g_nBrushId;
865
866 // defined in gtkdlgs.cpp, we might want to move declaration and implementatin with other Select_ stuff..
867 // NOTE: there's also a Select_Brush(brush_t *b) function.. unrelated
868 extern void SelectBrush (int entitynum, int brushnum);
869
870 // bp_dlg.cpp
871 // ret: 0 = abort, 1 = load and convert, 2 = changed project settings, load and don't convert
872 // the user might decide to switch the BP mode in project settings
873 // status: 0 = loading regular, got conflict 1 = loading BP, got conflict
874 extern int BP_MessageBox (int status);
875
876 // main.cpp
877 extern gint try_destroy_splash(gpointer);
878
879 // SPoG
880 // targetname.cpp
881 void Entity_Connect(entity_t *e1, entity_t *e2);
882 int GetUniqueTargetId(int iHint);
883
884 // xywindow.cpp
885 void CreateEntityFromName(const char* name, const vec3_t origin);
886
887 // eclass.cpp
888 /*!
889 \brief initialization of the eclass manager
890 general guidelines about eclass.cpp implementation:
891 - we don't support unlimited number of eclass file formats together
892   currently limited to two
893   support for .def is builtin to the core, but you may choose not to activate it
894 - search and load of the files:
895   the manager is in charge of scanning for eclass definition files to load
896   there is a general configuration setting for games which use a different set of
897     entities between single player mode and multiplayer mode (TODO: the code doing
898     this needs to be abstracted some more)
899 - duplicate files / multiple files:
900   if two files with the same name exist (for instance in the basegame, and in fs_game)
901   then only the first one found in the scan order is loaded
902   if several files are found, they are all loaded
903   this allows mods to either replace or extend the list of eclass
904 - if eclass_singleload prop is used in the .game, then there is no multiple files check
905   the first file found is loaded, and there is no further search for the given extension
906   (this was an addition for HL support)
907 */
908 void Eclass_Init ();
909 eclass_t *Eclass_ForName (const char *name, qboolean has_brushes);
910 eclass_t * EClass_Create( const char *name, float col1, float col2, float col3, const vec3_t *mins, const vec3_t *maxs, const char *comments );
911
912 #endif // _QE3_H_