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
101 texdef_t( const texdef_t& other ){
103 SetName( other.name );
104 shift[0] = other.shift[0];
105 shift[1] = other.shift[1];
106 rotate = other.rotate;
107 scale[0] = other.scale[0];
108 scale[1] = other.scale[1];
109 contents = other.contents;
120 void SetName( const char *p ){
126 name = strcpy( new char[strlen( p ) + 1], p );
135 const char * GetName() const {
139 // NOTE TTimo when loading prefs as binary, we load a bogus value in texdef..
145 texdef_t& operator =( const texdef_t& rhs ){
146 if ( &rhs != this ) {
148 shift[0] = rhs.shift[0];
149 shift[1] = rhs.shift[1];
151 scale[0] = rhs.scale[0];
152 scale[1] = rhs.scale[1];
153 contents = rhs.contents;
169 // max length of a vfs texture path
176 texdef_t() { name[0] = '\0'; }
179 void SetName( const char *p ){
180 strncpy( name, p, QPATH );
183 const char * GetName() const {
187 // NOTE TTimo when loading prefs as binary, we load a bogus value in texdef..
192 texdef_t& operator =( const texdef_t& rhs ){
193 if ( &rhs != this ) {
195 shift[0] = rhs.shift[0];
196 shift[1] = rhs.shift[1];
198 scale[0] = rhs.scale[0];
199 scale[1] = rhs.scale[1];
200 contents = rhs.contents;
220 // new brush primitive texdef
221 typedef struct brushprimit_texdef_s
224 } brushprimit_texdef_t;
226 // this structure is used in Radiant to reflect the state of the texture window
227 // it gives information on current shader and various flags
237 // add brushprimit_texdef_t for brush primitive coordinates storage
238 brushprimit_texdef_t brushprimit_texdef;
240 // surface plugin, must be casted to a IPluginTexdef*
244 // NOTE: never NULL, initialized in Texture_Init
245 // NOTE: the reference name of the shader is texdef.name (see QERApp_ReloadShaders for an example)
249 #define QER_TRANS 0x00000001
250 #define QER_NOCARVE 0x00000002
251 #define QER_NODRAW 0x00000004
252 #define QER_NONSOLID 0x00000008
253 #define QER_WATER 0x00000010
254 #define QER_LAVA 0x00000020
255 #define QER_FOG 0x00000040
256 #define QER_ALPHAFUNC 0x00000080
257 #define QER_CULL 0x00000100
260 // describes a GL texture that Radiant uses to represent a shader
261 // NOTE: all qtexture_t are stored in a main list at g_qeglobals.d_qtextures
262 // shaders have reference couting, but qtexture_t don't (they're way too deep into Radiant)
263 typedef struct qtexture_s
265 struct qtexture_s *next;
266 // name of the texture file (the physical image file we are using)
267 // NOTE: used for lookup, must be unique .. vfs path of the texture, lowercase, NO FILE EXTENSION
268 // ex textures/gothic_wall/iron
269 // NOTE: the "textures/" prefix might seem unnecessary .. but it's better to stick to the vfs name
272 GLuint texture_number; // gl bind number (the qtexture_t are usually loaded and binded by the shaders module)
273 vec3_t color; // for flat shade mode
274 qboolean inuse; // true = is present on the level (for the texture browser interface)
277 // NOTE: don't trust this definition!
278 // you should read float points[..][5]
279 // see NewWinding definition
280 // WARNING: don't touch anything to this struct unless you looked into winding.cpp and WINDING_SIZE(pt)
281 #define MAX_POINTS_ON_WINDING 64
286 float points[8][5]; // variable sized
296 // pShader is a shortcut to the shader
297 // it's only up-to-date after a Brush_Build call
298 // to initialize the pShader, use QERApp_Shader_ForName(texdef.name)
299 typedef struct face_s
303 struct face_s *original; //used for vertex movement
312 winding_t *face_winding;
316 // calls through here have indirections (pure virtual)
317 // it would be good if the rendering loop would avoid scanning there (for the GL binding number for example)
319 //++timo FIXME: remove!
320 qtexture_t *d_texture;
322 // Timo new brush primit texdef
323 brushprimit_texdef_t brushprimit_texdef;
325 // cast this one to an IPluginTexdef if you are using it
326 // NOTE: casting can be done with a GETPLUGINTEXDEF defined in isurfaceplugin.h
327 // TODO: if the __ISURFACEPLUGIN_H_ header is used, use a union { void *pData; IPluginTexdef *pPluginTexdef } kind of thing ?
342 #define MIN_PATCH_WIDTH 3
343 #define MIN_PATCH_HEIGHT 3
345 #define MAX_PATCH_WIDTH 16
346 #define MAX_PATCH_HEIGHT 16
349 // type in lower 16 bits, flags in upper
350 // endcaps directly follow this patch in the list
353 #define PATCH_GENERIC 0x00000000 // generic flat patch
354 #define PATCH_CYLINDER 0x00000001 // cylinder
355 #define PATCH_BEVEL 0x00000002 // bevel
356 #define PATCH_ENDCAP 0x00000004 // endcap
357 #define PATCH_HEMISPHERE 0x00000008 // hemisphere
358 #define PATCH_CONE 0x00000010 // cone
359 #define PATCH_TRIANGLE 0x00000020 // simple tri, assumes 3x3 patch
362 #define PATCH_CAP 0x00001000 // flat patch applied as a cap
363 #define PATCH_SEAM 0x00002000 // flat patch applied as a seam
364 #define PATCH_THICK 0x00004000 // patch applied as a thick portion
367 #define PATCH_BEZIER 0x00000000 // default bezier
368 #define PATCH_BSPLINE 0x10000000 // bspline
370 #define PATCH_TYPEMASK 0x00000fff //
371 #define PATCH_BTYPEMASK 0x0000f000 //
372 #define PATCH_STYLEMASK 0xffff0000 //
381 // spog - used for patch LOD trees
385 BTNode_t *left, *right;
394 drawVert_t vLeft, vRight;
403 // used in brush primitive AND entities
404 typedef struct epair_s
406 struct epair_s *next;
412 typedef struct brush_s brush_t;
415 int width, height; // in control points, not patches
416 int contents, flags, value, type;
417 qtexture_t *d_texture;
419 drawVert_t ctrl[MAX_PATCH_WIDTH][MAX_PATCH_HEIGHT];
426 // cast this one to an IPluginTexdef if you are using it
427 // NOTE: casting can be done with a GETPLUGINTEXDEF defined in isurfaceplugin.h
428 // TODO: if the __ISURFACEPLUGIN_H_ header is used, use a union { void *pData; IPluginTexdef *pPluginTexdef } kind of thing ?
430 // spog - curve LOD binary trees and lists
431 BTNode_t *rowLOD[( ( MAX_PATCH_WIDTH - 1 ) / 2 ) * MAX_PATCH_HEIGHT]; // = ((MAX_PATCH_WIDTH-1)/2) * MAX_PATCH_HEIGHT
432 BTNode_t *colLOD[( ( MAX_PATCH_HEIGHT - 1 ) / 2 ) * MAX_PATCH_WIDTH]; // = ((MAX_PATCH_HEIGHT-1)/2) * MAX_PATCH_WIDTH
433 bool rowDirty[( ( MAX_PATCH_WIDTH - 1 ) - 1 ) / 2];
434 bool colDirty[( ( MAX_PATCH_HEIGHT - 1 ) - 1 ) / 2];
436 void *drawLists; // pointer to std::list
439 typedef struct brush_s
441 struct brush_s *prev, *next; // links in active/selected
442 struct brush_s *oprev, *onext; // links in entity
443 struct entity_s *owner;
447 qboolean bModelFailed;
449 // curve brush extensions
450 // all are derived from brush_faces
452 qboolean hiddenBrush;
457 struct entity_s *pUndoOwner;
459 int undoId; //undo ID
460 int redoId; //redo ID
461 int ownerId; //entityId of the owner entity for undo
463 // TTimo: this is not legal, we are not supposed to put UI toolkit dependant stuff in the interfaces
464 // NOTE: the grouping stuff never worked, there is embryonary code everywhere though
466 void* itemOwner; // GtkCTreeNode* ?
468 // brush primitive only
471 // brush filtered toggle
479 typedef struct vertmodel_t
486 typedef struct triindex_t
491 // TTimo: NOTE: we don't have dedicated stuff to copy/allocate/delete this structure like we do for entity_t and brush_t
492 // could be necessary, I'm adding GString *strSkin that needs to be copied around
493 // TTimo 04/01/2001 removing the GString* for toolkit-independent interfaces .. cast it ..
494 typedef struct entitymodel_t
496 struct entitymodel_t *pNext;
498 //trimodel *pTriList;
499 //md3Triangle_t *pTriList;
501 vertmodel *pVertList;
504 void *strSkin; // toolkit-independent .. cast to a GString*
512 #define ECLASS_LIGHT 0x00000001
513 #define ECLASS_ANGLE 0x00000002
514 #define ECLASS_PATH 0x00000004
515 #define ECLASS_MISCMODEL 0x00000008
517 #ifdef USEPLUGINENTITIES
518 #define ECLASS_PLUGINENTITY 0x00000010
519 #endif // USEPLUGINENTITIES
521 typedef struct eclass_s
523 struct eclass_s *next;
526 qboolean unknown; // wasn't found in source
531 char flagnames[MAX_FLAGS][32];
535 //++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)
536 //++hydra NOTE: this, hopefully, will be used to use specific shaders on the bounding boxes of the eclass instead of a color.
539 unsigned int nShowFlags;
544 extern eclass_t *eclass;
549 #define W_CAMERA 0x0001
551 #define W_XY_OVERLAY 0x0004
553 #define W_TEXTURE 0x0010
554 #define W_Z_OVERLAY 0x0020
555 #define W_CONSOLE 0x0040
556 #define W_ENTITY 0x0080
557 #define W_CAMERA_IFON 0x0100
558 #define W_XZ 0x0200 //--| only used for patch vertex manip stuff
559 #define W_YZ 0x0400 //--|
560 #define W_GROUP 0x0800
561 #define W_MEDIA 0x1000
562 #define W_ALL 0xFFFFFFFF
564 // used in some Drawing routines
565 enum VIEWTYPE {YZ, XZ, XY};
566 const char g_AxisName[3] = { 'X', 'Y', 'Z' };
568 // dynamically allocated string
575 inline string_t( const string_t& other ){
576 copy( other.m_string );
578 inline string_t( const char* string ){
584 inline const string_t& operator=( const string_t& other ){
586 copy( other.m_string );
589 inline const string_t& operator=( const char* string ){
594 inline bool operator<( const string_t& other ) const {
595 return compare( other ) < 0;
597 inline bool operator>( const string_t& other ) const {
598 return compare( other ) > 0;
600 inline bool operator==( const string_t& other ) const {
601 return compare( other ) == 0;
603 inline bool operator!=( const string_t& other ) const {
604 return compare( other ) != 0;
606 inline const char* c_str() const {
610 inline void copy( const char* string ){
611 m_string = new char[strlen( string ) + 1];
612 strcpy( m_string, string );
614 inline void destroy(){
617 inline int compare( const string_t& other ) const {
618 return strcmp( m_string, other.m_string );
628 : name( "" ), pattern( "" )
630 filetype_t( const char* _name, const char* _pattern )
631 : name( _name ), pattern( _pattern )
641 #define OUTLINE_ZBUF 0x01 // zbuffered outline
642 #define OUTLINE_BSEL 0x02 // selection overlay
644 #ifdef USEPLUGINENTITIES
645 // forward declare this one
647 #endif // USEPLUGINENTITIES
655 // NOTE TTimo about ~entity_interfaces_t
656 // using constructors / destructors on C structs is bad practice
657 struct entity_interfaces_t
665 typedef struct entity_s
667 struct entity_s *prev, *next;
670 \todo can use a brushes list, or the blind data below
671 for now, blind data should be interpreted as CPtrArray*, only use in the IMAP API
673 brush_t brushes; // head/tail of list
676 int undoId, redoId, entityId; // used for undo/redo
680 entity_interfaces_t model;
681 #ifdef USEPLUGINENTITIES
682 IPluginEntity *pPlugEnt;
683 #endif // USEPLUGINENTITIES
685 // this is cam code addition?
688 // Arnout: HACK-ish and change for 1.3 (in 1.3 we have a blind data pointer according to TTimo)
689 float fLightEnvelope1[3];
690 float fLightEnvelope2[2];
699 // window system independent camera view code
700 // NOTE TTimo taken from xy.h
707 vec3_t origin; // at center of window
710 float topclip, bottomclip;
715 // spog - struct used for nodes in filters list
716 struct bfilter_t //c++ style
719 int attribute; // 1=brush->face->pShader->getName()
720 // 2=brush->pPatch->pShader->getFlags()
721 // 3=brush->owner->eclass->name
722 // 4=brush->owner->eclass->nShowFlags
723 // 5=brush->face->texdef.flags (q2)
724 // 6=brush->face->texdef.contents (q2)
730 // djbob: no longer any need to add only to end, versioning removed, it is no longer saved as binary
731 // IMPORTANT: whenever you update this struct, you need to add the relevant load/save code
732 // preferences.cpp LoadPref / SavePref
735 int iTexMenu; // nearest, linear, etc
736 float fGamma; // gamma for textures
737 vec3_t colors[COLOR_LAST];
740 texdef_t m_SIIncrement; // increments for the surface inspector
741 texdef_t m_PIIncrement; // increments for the patch inspector
742 vec3_t AxisColors[3]; // colors used for X, Y Z axis
743 // these are in the View > Show menu with Show coordinates
745 qboolean show_coordinates;
746 qboolean show_angles;
747 qboolean show_outline;
749 qboolean bNoSelectedOutlines;
750 bfilter_t *filters; // FIXME spog - might be better in another location?
751 int iSelectedOutlinesStyle;
771 // most of the QE globals are stored in this structure
776 qboolean d_bSmallGrid; // we use this flag to hack our way into editing of <1 grids
780 entity_t *d_project_entity;
782 // defines the boundaries of the current work area
783 // is used to guess brushes and drop points third coordinate when creating from 2D view
784 vec3_t d_work_min,d_work_max;
785 // not stored in registry, default is off
786 qboolean d_show_work;
788 vec3_t d_points[MAX_POINTS];
790 pedge_t d_edges[MAX_EDGES];
793 int d_num_move_points;
794 float *d_move_points[4096];
796 qtexture_t *d_qtextures;
797 // used to speedup access, specially in QERApp_Try_Texture_ForName
798 // must always be kept up-to-date with d_qtextures*
799 //++timo FIXME at some point in the future it would even be better to remove d_qtextures and use this instead
800 GHashTable *d_qtexmap;
802 texturewin_t d_texturewin;
804 int d_pointfile_display_list;
808 SavedInfo_t d_savedinfo;
812 // connect entities uses the last two brushes selected
814 brush_t *d_select_order[2];
815 vec3_t d_select_translate; // for dragging w/o making new display lists
816 select_t d_select_mode;
818 int d_parsed_brushes;
820 qboolean show_blocks;
824 // a lot of this data should be in a property bag and available to the other modules through an API
825 // this is generated from game configuration and the project settings, and should be still be part of it
827 // tells if we are internally using brush primitive (texture coordinates and map format)
828 // this is a shortcut for IntForKey( g_qeglobals.d_project_entity, "brush_primit" )
829 // NOTE: must keep the two ones in sync
830 bool m_bBrushPrimitMode;
833 win32: engine full path.
834 unix: user home full path + engine dir.
838 cache for m_strHomeGame + mod subdirectory.
842 // used while importing brush data from file or memory buffer
843 // tells if conversion between map format and internal preferences ( m_bBrushPrimitMode ) is needed
844 qboolean bNeedConvert;
845 qboolean bOldBrushes;
846 qboolean bPrimitBrushes;
851 // tells if we are using .INI files for prefs instead of registry
853 // even in .INI mode we use the registry for all void* prefs
854 char use_ini_registry[64];
855 // disabled all INI / registry read write .. used when shutting down after registry cleanup
856 qboolean disable_ini;
858 // tells we are using a BSP frontend plugin
859 qboolean bBSPFrontendPlugin;
861 // handle to the console log file
862 // we use low level I/O to get rid of buffering and have everything on file if we crash
865 qboolean bTextureCompressionSupported; // is texture compression supported by hardware?
866 GLint texture_components;
868 // temporary values that should be initialised only once at run-time
869 // there are too many uneccessary calls to Sys_QGL_ExtensionSupported
870 // NOTE TTimo: those are unused atm (set right, but not used)
871 bool m_bOpenGLCompressionSupported;
872 bool m_bS3CompressionSupported;
874 // set to true after OpenGL has been initialized and extensions have been tested
879 #endif // _QERTYPES_H_