2 Copyright (C) 1999-2007 id Software, Inc. and contributors.
3 For a list of contributors, see the accompanying CONTRIBUTORS file.
5 This file is part of GtkRadiant.
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.
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.
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
25 // merged from brush.h, etc. for plugin support
45 typedef bool qboolean;
49 // merged from qedefs.h ------
52 #define MAX_POINTS 1024
54 #define COLOR_TEXTUREBACK 0
55 #define COLOR_GRIDBACK 1
56 #define COLOR_GRIDMINOR 2
57 #define COLOR_GRIDMAJOR 3
58 #define COLOR_CAMERABACK 4
59 #define COLOR_ENTITY 5
60 #define COLOR_GRIDBLOCK 6
61 #define COLOR_GRIDTEXT 7
62 #define COLOR_BRUSHES 8
63 #define COLOR_SELBRUSHES 9
64 #define COLOR_CLIPPER 10
65 #define COLOR_VIEWNAME 11
66 #define COLOR_SELBRUSHES3D 12
68 #define COLOR_GRIDMINOR_ALT 13
69 #define COLOR_GRIDMAJOR_ALT 14
73 // ----------------------------
76 typedef vec_t vec3_t[3];
78 // turn this on/off to use a static texdef or a memory one
79 // THIS MUST BE CONSISTENT throughout a whole build of Radiant / modules / plugins
80 // DO_TEXDEF_ALLOC is more memory efficient, but I suspect it to be wacky on win32 / C runtime etc.
81 #define DO_TEXDEF_ALLOC 1
102 texdef_t(const texdef_t& other)
106 shift[0] = other.shift[0];
107 shift[1] = other.shift[1];
108 rotate = other.rotate;
109 scale[0] = other.scale[0];
110 scale[1] = other.scale[1];
111 contents = other.contents;
124 void SetName(const char *p)
133 name = strcpy(new char[strlen(p)+1], p);
142 const char * GetName() const
147 // NOTE TTimo when loading prefs as binary, we load a bogus value in texdef..
154 texdef_t& operator =(const texdef_t& rhs)
159 shift[0] = rhs.shift[0];
160 shift[1] = rhs.shift[1];
162 scale[0] = rhs.scale[0];
163 scale[1] = rhs.scale[1];
164 contents = rhs.contents;
180 // max length of a vfs texture path
187 texdef_t() { name[0] = '\0'; }
190 void SetName(const char *p)
192 strncpy(name, p, QPATH);
195 const char * GetName() const
200 // NOTE TTimo when loading prefs as binary, we load a bogus value in texdef..
206 texdef_t& operator =(const texdef_t& rhs)
211 shift[0] = rhs.shift[0];
212 shift[1] = rhs.shift[1];
214 scale[0] = rhs.scale[0];
215 scale[1] = rhs.scale[1];
216 contents = rhs.contents;
236 // new brush primitive texdef
237 typedef struct brushprimit_texdef_s
240 } brushprimit_texdef_t;
242 // this structure is used in Radiant to reflect the state of the texture window
243 // it gives information on current shader and various flags
255 // add brushprimit_texdef_t for brush primitive coordinates storage
256 brushprimit_texdef_t brushprimit_texdef;
258 // surface plugin, must be casted to a IPluginTexdef*
262 // NOTE: never NULL, initialized in Texture_Init
263 // NOTE: the reference name of the shader is texdef.name (see QERApp_ReloadShaders for an example)
267 #define QER_TRANS 0x00000001
268 #define QER_NOCARVE 0x00000002
269 #define QER_NODRAW 0x00000004
270 #define QER_NONSOLID 0x00000008
271 #define QER_WATER 0x00000010
272 #define QER_LAVA 0x00000020
273 #define QER_FOG 0x00000040
274 #define QER_ALPHAFUNC 0x00000080
275 #define QER_CULL 0x00000100
278 // describes a GL texture that Radiant uses to represent a shader
279 // NOTE: all qtexture_t are stored in a main list at g_qeglobals.d_qtextures
280 // shaders have reference couting, but qtexture_t don't (they're way too deep into Radiant)
281 typedef struct qtexture_s
283 struct qtexture_s *next;
284 // name of the texture file (the physical image file we are using)
285 // NOTE: used for lookup, must be unique .. vfs path of the texture, lowercase, NO FILE EXTENSION
286 // ex textures/gothic_wall/iron
287 // NOTE: the "textures/" prefix might seem unnecessary .. but it's better to stick to the vfs name
290 GLuint texture_number; // gl bind number (the qtexture_t are usually loaded and binded by the shaders module)
291 vec3_t color; // for flat shade mode
292 qboolean inuse; // true = is present on the level (for the texture browser interface)
295 // NOTE: don't trust this definition!
296 // you should read float points[..][5]
297 // see NewWinding definition
298 // WARNING: don't touch anything to this struct unless you looked into winding.cpp and WINDING_SIZE(pt)
299 #define MAX_POINTS_ON_WINDING 64
304 float points[8][5]; // variable sized
314 // pShader is a shortcut to the shader
315 // it's only up-to-date after a Brush_Build call
316 // to initialize the pShader, use QERApp_Shader_ForName(texdef.name)
317 typedef struct face_s
321 struct face_s *original; //used for vertex movement
330 winding_t *face_winding;
334 // calls through here have indirections (pure virtual)
335 // it would be good if the rendering loop would avoid scanning there (for the GL binding number for example)
337 //++timo FIXME: remove!
338 qtexture_t *d_texture;
340 // Timo new brush primit texdef
341 brushprimit_texdef_t brushprimit_texdef;
343 // cast this one to an IPluginTexdef if you are using it
344 // NOTE: casting can be done with a GETPLUGINTEXDEF defined in isurfaceplugin.h
345 // TODO: if the __ISURFACEPLUGIN_H_ header is used, use a union { void *pData; IPluginTexdef *pPluginTexdef } kind of thing ?
360 #define MIN_PATCH_WIDTH 3
361 #define MIN_PATCH_HEIGHT 3
363 #define MAX_PATCH_WIDTH 16
364 #define MAX_PATCH_HEIGHT 16
367 // type in lower 16 bits, flags in upper
368 // endcaps directly follow this patch in the list
371 #define PATCH_GENERIC 0x00000000 // generic flat patch
372 #define PATCH_CYLINDER 0x00000001 // cylinder
373 #define PATCH_BEVEL 0x00000002 // bevel
374 #define PATCH_ENDCAP 0x00000004 // endcap
375 #define PATCH_HEMISPHERE 0x00000008 // hemisphere
376 #define PATCH_CONE 0x00000010 // cone
377 #define PATCH_TRIANGLE 0x00000020 // simple tri, assumes 3x3 patch
380 #define PATCH_CAP 0x00001000 // flat patch applied as a cap
381 #define PATCH_SEAM 0x00002000 // flat patch applied as a seam
382 #define PATCH_THICK 0x00004000 // patch applied as a thick portion
385 #define PATCH_BEZIER 0x00000000 // default bezier
386 #define PATCH_BSPLINE 0x10000000 // bspline
388 #define PATCH_TYPEMASK 0x00000fff //
389 #define PATCH_BTYPEMASK 0x0000f000 //
390 #define PATCH_STYLEMASK 0xffff0000 //
399 // spog - used for patch LOD trees
403 BTNode_t *left, *right;
412 drawVert_t vLeft, vRight;
421 // used in brush primitive AND entities
422 typedef struct epair_s
424 struct epair_s *next;
430 typedef struct brush_s brush_t;
433 int width, height; // in control points, not patches
434 int contents, flags, value, type;
435 qtexture_t *d_texture;
437 drawVert_t ctrl[MAX_PATCH_WIDTH][MAX_PATCH_HEIGHT];
444 // cast this one to an IPluginTexdef if you are using it
445 // NOTE: casting can be done with a GETPLUGINTEXDEF defined in isurfaceplugin.h
446 // TODO: if the __ISURFACEPLUGIN_H_ header is used, use a union { void *pData; IPluginTexdef *pPluginTexdef } kind of thing ?
448 // spog - curve LOD binary trees and lists
449 BTNode_t *rowLOD[((MAX_PATCH_WIDTH-1)/2) * MAX_PATCH_HEIGHT]; // = ((MAX_PATCH_WIDTH-1)/2) * MAX_PATCH_HEIGHT
450 BTNode_t *colLOD[((MAX_PATCH_HEIGHT-1)/2) * MAX_PATCH_WIDTH]; // = ((MAX_PATCH_HEIGHT-1)/2) * MAX_PATCH_WIDTH
451 bool rowDirty[((MAX_PATCH_WIDTH-1)-1)/2];
452 bool colDirty[((MAX_PATCH_HEIGHT-1)-1)/2];
454 void *drawLists; // pointer to std::list
457 typedef struct brush_s
459 struct brush_s *prev, *next; // links in active/selected
460 struct brush_s *oprev, *onext; // links in entity
461 struct entity_s *owner;
465 qboolean bModelFailed;
467 // curve brush extensions
468 // all are derived from brush_faces
470 qboolean hiddenBrush;
475 struct entity_s *pUndoOwner;
477 int undoId; //undo ID
478 int redoId; //redo ID
479 int ownerId; //entityId of the owner entity for undo
481 // TTimo: this is not legal, we are not supposed to put UI toolkit dependant stuff in the interfaces
482 // NOTE: the grouping stuff never worked, there is embryonary code everywhere though
484 void* itemOwner; // GtkCTreeNode* ?
486 // brush primitive only
489 // brush filtered toggle
497 typedef struct vertmodel_t
504 typedef struct triindex_t
509 // TTimo: NOTE: we don't have dedicated stuff to copy/allocate/delete this structure like we do for entity_t and brush_t
510 // could be necessary, I'm adding GString *strSkin that needs to be copied around
511 // TTimo 04/01/2001 removing the GString* for toolkit-independent interfaces .. cast it ..
512 typedef struct entitymodel_t
514 struct entitymodel_t *pNext;
516 //trimodel *pTriList;
517 //md3Triangle_t *pTriList;
519 vertmodel *pVertList;
522 void *strSkin; // toolkit-independent .. cast to a GString*
530 #define ECLASS_LIGHT 0x00000001
531 #define ECLASS_ANGLE 0x00000002
532 #define ECLASS_PATH 0x00000004
533 #define ECLASS_MISCMODEL 0x00000008
535 #ifdef USEPLUGINENTITIES
536 #define ECLASS_PLUGINENTITY 0x00000010
537 #endif // USEPLUGINENTITIES
539 typedef struct eclass_s
541 struct eclass_s *next;
544 qboolean unknown; // wasn't found in source
549 char flagnames[MAX_FLAGS][32];
553 //++timo NOTE: I don't know what this is used for exactly. But don't trust it for the real skin paths on models (screws up with long/short path names)
554 //++hydra NOTE: this, hopefully, will be used to use specific shaders on the bounding boxes of the eclass instead of a color.
557 unsigned int nShowFlags;
562 extern eclass_t *eclass;
567 #define W_CAMERA 0x0001
569 #define W_XY_OVERLAY 0x0004
571 #define W_TEXTURE 0x0010
572 #define W_Z_OVERLAY 0x0020
573 #define W_CONSOLE 0x0040
574 #define W_ENTITY 0x0080
575 #define W_CAMERA_IFON 0x0100
576 #define W_XZ 0x0200 //--| only used for patch vertex manip stuff
577 #define W_YZ 0x0400 //--|
578 #define W_GROUP 0x0800
579 #define W_MEDIA 0x1000
580 #define W_ALL 0xFFFFFFFF
582 // used in some Drawing routines
583 enum VIEWTYPE {YZ, XZ, XY};
584 const char g_AxisName[3] = { 'X', 'Y', 'Z' };
586 // dynamically allocated string
594 inline string_t(const string_t& other)
596 copy(other.m_string);
598 inline string_t(const char* string)
606 inline const string_t& operator=(const string_t& other)
609 copy(other.m_string);
612 inline const string_t& operator=(const char* string)
618 inline bool operator<(const string_t& other) const
620 return compare(other) < 0;
622 inline bool operator>(const string_t& other) const
624 return compare(other) > 0;
626 inline bool operator==(const string_t& other) const
628 return compare(other) == 0;
630 inline bool operator!=(const string_t& other) const
632 return compare(other) != 0;
634 inline const char* c_str() const
639 inline void copy(const char* string)
641 m_string = new char[strlen(string)+1];
642 strcpy(m_string, string);
644 inline void destroy()
648 inline int compare(const string_t& other) const
650 return strcmp(m_string, other.m_string);
660 : name(""), pattern("")
662 filetype_t(const char* _name, const char* _pattern)
663 : name(_name), pattern(_pattern)
673 #define OUTLINE_ZBUF 0x01 // zbuffered outline
674 #define OUTLINE_BSEL 0x02 // selection overlay
676 #ifdef USEPLUGINENTITIES
677 // forward declare this one
679 #endif // USEPLUGINENTITIES
687 // NOTE TTimo about ~entity_interfaces_t
688 // using constructors / destructors on C structs is bad practice
689 struct entity_interfaces_t
697 typedef struct entity_s
699 struct entity_s *prev, *next;
702 \todo can use a brushes list, or the blind data below
703 for now, blind data should be interpreted as CPtrArray*, only use in the IMAP API
705 brush_t brushes; // head/tail of list
708 int undoId, redoId, entityId; // used for undo/redo
712 entity_interfaces_t model;
713 #ifdef USEPLUGINENTITIES
714 IPluginEntity *pPlugEnt;
715 #endif // USEPLUGINENTITIES
717 // this is cam code addition?
720 // Arnout: HACK-ish and change for 1.3 (in 1.3 we have a blind data pointer according to TTimo)
721 float fLightEnvelope1[3];
722 float fLightEnvelope2[2];
731 // window system independent camera view code
732 // NOTE TTimo taken from xy.h
739 vec3_t origin; // at center of window
742 float topclip, bottomclip;
747 // spog - struct used for nodes in filters list
748 struct bfilter_t //c++ style
751 int attribute; // 1=brush->face->pShader->getName()
752 // 2=brush->pPatch->pShader->getFlags()
753 // 3=brush->owner->eclass->name
754 // 4=brush->owner->eclass->nShowFlags
755 // 5=brush->face->texdef.flags (q2)
756 // 6=brush->face->texdef.contents (q2)
762 // djbob: no longer any need to add only to end, versioning removed, it is no longer saved as binary
763 // IMPORTANT: whenever you update this struct, you need to add the relevant load/save code
764 // preferences.cpp LoadPref / SavePref
767 int iTexMenu; // nearest, linear, etc
768 float fGamma; // gamma for textures
769 vec3_t colors[COLOR_LAST];
772 texdef_t m_SIIncrement; // increments for the surface inspector
773 texdef_t m_PIIncrement; // increments for the patch inspector
774 vec3_t AxisColors[3]; // colors used for X, Y Z axis
775 // these are in the View > Show menu with Show coordinates
777 qboolean show_coordinates;
778 qboolean show_angles;
779 qboolean show_outline;
781 qboolean bNoSelectedOutlines;
782 bfilter_t *filters; // FIXME spog - might be better in another location?
783 int iSelectedOutlinesStyle;
803 // most of the QE globals are stored in this structure
808 qboolean d_bSmallGrid; // we use this flag to hack our way into editing of <1 grids
812 entity_t *d_project_entity;
814 // defines the boundaries of the current work area
815 // is used to guess brushes and drop points third coordinate when creating from 2D view
816 vec3_t d_work_min,d_work_max;
817 // not stored in registry, default is off
818 qboolean d_show_work;
820 vec3_t d_points[MAX_POINTS];
822 pedge_t d_edges[MAX_EDGES];
825 int d_num_move_points;
826 float *d_move_points[4096];
828 qtexture_t *d_qtextures;
829 // used to speedup access, specially in QERApp_Try_Texture_ForName
830 // must always be kept up-to-date with d_qtextures*
831 //++timo FIXME at some point in the future it would even be better to remove d_qtextures and use this instead
832 GHashTable *d_qtexmap;
834 texturewin_t d_texturewin;
836 int d_pointfile_display_list;
840 SavedInfo_t d_savedinfo;
844 // connect entities uses the last two brushes selected
846 brush_t *d_select_order[2];
847 vec3_t d_select_translate; // for dragging w/o making new display lists
848 select_t d_select_mode;
850 int d_parsed_brushes;
852 qboolean show_blocks;
856 // a lot of this data should be in a property bag and available to the other modules through an API
857 // this is generated from game configuration and the project settings, and should be still be part of it
859 // tells if we are internally using brush primitive (texture coordinates and map format)
860 // this is a shortcut for IntForKey( g_qeglobals.d_project_entity, "brush_primit" )
861 // NOTE: must keep the two ones in sync
862 bool m_bBrushPrimitMode;
865 win32: engine full path.
866 unix: user home full path + engine dir.
870 cache for m_strHomeGame + mod subdirectory.
874 // used while importing brush data from file or memory buffer
875 // tells if conversion between map format and internal preferences ( m_bBrushPrimitMode ) is needed
876 qboolean bNeedConvert;
877 qboolean bOldBrushes;
878 qboolean bPrimitBrushes;
883 // tells if we are using .INI files for prefs instead of registry
885 // even in .INI mode we use the registry for all void* prefs
886 char use_ini_registry[64];
887 // disabled all INI / registry read write .. used when shutting down after registry cleanup
888 qboolean disable_ini;
890 // tells we are using a BSP frontend plugin
891 qboolean bBSPFrontendPlugin;
893 // handle to the console log file
894 // we use low level I/O to get rid of buffering and have everything on file if we crash
897 qboolean bTextureCompressionSupported; // is texture compression supported by hardware?
898 GLint texture_components;
900 // temporary values that should be initialised only once at run-time
901 // there are too many uneccessary calls to Sys_QGL_ExtensionSupported
902 // NOTE TTimo: those are unused atm (set right, but not used)
903 bool m_bOpenGLCompressionSupported;
904 bool m_bS3CompressionSupported;
906 // set to true after OpenGL has been initialized and extensions have been tested
911 #endif // _QERTYPES_H_