Quake-III-Arena

Quake III Arena GPL Source Release
Log | Files | Refs

QERTYPES.H (10263B)


      1 /*
      2 ===========================================================================
      3 Copyright (C) 1999-2005 Id Software, Inc.
      4 
      5 This file is part of Quake III Arena source code.
      6 
      7 Quake III Arena source code is free software; you can redistribute it
      8 and/or modify it under the terms of the GNU General Public License as
      9 published by the Free Software Foundation; either version 2 of the License,
     10 or (at your option) any later version.
     11 
     12 Quake III Arena source code is distributed in the hope that it will be
     13 useful, 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 Foobar; if not, write to the Free Software
     19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
     20 ===========================================================================
     21 */
     22 // qertypes.h
     23 //
     24 // common types
     25 // merged from brush.h, etc. for plugin support
     26 //
     27 #ifndef _QERTYPE_H
     28 #define _QERTYPE_H
     29 
     30 #ifndef __BYTEBOOL__
     31 #define __BYTEBOOL__
     32 typedef boolean qboolean;
     33 //typedef unsigned char byte;
     34 #endif
     35 
     36 #define	MAXPOINTS	16
     37 
     38 typedef float vec_t;
     39 typedef vec_t vec2_t[2];
     40 typedef vec_t vec3_t[3];
     41 
     42 #include "splines/math_vector.h"
     43 
     44 #ifndef M_PI
     45 #define M_PI		3.14159265358979323846	// matches value in gcc v2 math.h
     46 #endif
     47 
     48 class texdef_t
     49 {
     50 public:
     51   texdef_t()
     52   {
     53     name = new char[1];
     54     name[0] = '\0';
     55   }
     56   ~texdef_t()
     57   {
     58     delete []name;
     59     name = NULL;
     60   }
     61 
     62   const char *Name( void )
     63   {
     64 	  if ( name ) {
     65 		  return name;
     66 	  }
     67 
     68 	  return "";
     69   }
     70 
     71   void SetName(const char *p)
     72   {
     73     if (name)
     74     {
     75       delete []name;
     76     }
     77     if (p)
     78     {
     79       name = strcpy(new char[strlen(p)+1], p);
     80     }
     81     else
     82     {
     83       name = new char[1];
     84       name[0] = '\0';
     85     }
     86   }
     87 
     88   texdef_t& operator =(const texdef_t& rhs)
     89   {
     90     if (&rhs != this)
     91     {
     92       SetName(rhs.name);
     93       shift[0] = rhs.shift[0];
     94       shift[1] = rhs.shift[1];
     95       rotate = rhs.rotate;
     96       scale[0] = rhs.scale[0];
     97       scale[1] = rhs.scale[1];
     98       contents = rhs.contents;
     99       flags = rhs.flags;
    100       value = rhs.value;
    101     }
    102     return *this;
    103   }
    104 	//char	name[128];
    105 	char	*name;
    106 	float	shift[2];
    107 	float	rotate;
    108 	float	scale[2];
    109 	int		contents;
    110 	int		flags;
    111 	int		value;
    112 };
    113 
    114 // Timo
    115 // new brush primitive texdef
    116 typedef struct brushprimit_texdef_s
    117 {
    118 	vec_t	coords[2][3];
    119 } brushprimit_texdef_t;
    120 
    121 class texturewin_t
    122 {
    123 public:
    124   texturewin_t()
    125   {
    126   }
    127   ~texturewin_t()
    128   {
    129   }
    130 	int			width, height;
    131 	int			originy;
    132 	// add brushprimit_texdef_t for brush primitive coordinates storage
    133 	brushprimit_texdef_t	brushprimit_texdef;
    134 	int m_nTotalHeight;
    135 	// surface plugin, must be casted to a IPluginTexdef*
    136 	void* pTexdef;
    137 	texdef_t	texdef;
    138 };
    139 
    140 #define QER_TRANS     0x00000001
    141 #define QER_NOCARVE   0x00000002
    142 
    143 typedef struct qtexture_s
    144 {
    145 	struct	qtexture_s *next;
    146 	char	name[64];		// includes partial directory and extension
    147   int		width,  height;
    148 	int		contents;
    149 	int		flags;
    150 	int		value;
    151 	int		texture_number;	// gl bind number
    152   
    153 	// name of the .shader file
    154   char  shadername[1024]; // old shader stuff
    155   qboolean bFromShader;   // created from a shader
    156   float fTrans;           // amount of transparency
    157   int   nShaderFlags;     // qer_ shader flags
    158 	vec3_t	color;			    // for flat shade mode
    159 	qboolean	inuse;		    // true = is present on the level
    160 
    161 	// cast this one to an IPluginQTexture if you are using it
    162 	// NOTE: casting can be done with a GETPLUGINQTEXTURE defined in isurfaceplugin.h
    163 	// TODO: if the __ISURFACEPLUGIN_H_ header is used, use a union { void *pData; IPluginQTexture *pPluginQTexture } kind of thing ?
    164 	void					*pData;
    165 
    166 	//++timo FIXME: this is the actual filename of the texture
    167 	// this will be removed after shader code cleanup
    168 	char filename[64];
    169 
    170 } qtexture_t;
    171 
    172 // NOTE: don't trust this definition!
    173 // you should read float points[..][5]
    174 // see NewWinding definition
    175 #define MAX_POINTS_ON_WINDING 64
    176 typedef struct
    177 {
    178 	int		numpoints;
    179 	int		maxpoints;
    180 	float 	points[8][5];			// variable sized
    181 } winding_t;
    182 
    183 typedef struct
    184 {
    185     vec3_t	normal;
    186     double	dist;
    187     int		type;
    188 } plane_t;
    189 
    190 //++timo texdef and brushprimit_texdef are static
    191 // TODO : do dynamic ?
    192 typedef struct face_s
    193 {
    194 	struct face_s			*next;
    195 	struct face_s			*original;		//used for vertex movement
    196 	vec3_t					planepts[3];
    197 	texdef_t				texdef;
    198 	plane_t					plane;
    199 
    200 	winding_t				*face_winding;
    201 
    202 	vec3_t					d_color;
    203 	qtexture_t				*d_texture;
    204 
    205 	// Timo new brush primit texdef
    206 	brushprimit_texdef_t	brushprimit_texdef;
    207 
    208 	// cast this one to an IPluginTexdef if you are using it
    209 	// NOTE: casting can be done with a GETPLUGINTEXDEF defined in isurfaceplugin.h
    210 	// TODO: if the __ISURFACEPLUGIN_H_ header is used, use a union { void *pData; IPluginTexdef *pPluginTexdef } kind of thing ?
    211 	void					*pData;
    212 } face_t;
    213 
    214 typedef struct {
    215 	vec3_t	xyz;
    216 	float	sideST[2];
    217 	float	capST[2];
    218 } curveVertex_t;
    219 
    220 typedef struct {
    221 	curveVertex_t	v[2];
    222 } sideVertex_t;
    223 
    224 
    225 #define	MIN_PATCH_WIDTH		3
    226 #define	MIN_PATCH_HEIGHT 	3
    227 
    228 #define	MAX_PATCH_WIDTH		16
    229 #define	MAX_PATCH_HEIGHT	16
    230 
    231 // patch type info
    232 // type in lower 16 bits, flags in upper
    233 // endcaps directly follow this patch in the list
    234 
    235 // types
    236 #define PATCH_GENERIC     0x00000000    // generic flat patch
    237 #define PATCH_CYLINDER    0x00000001    // cylinder
    238 #define PATCH_BEVEL       0x00000002    // bevel
    239 #define PATCH_ENDCAP      0x00000004    // endcap
    240 #define PATCH_HEMISPHERE  0x00000008    // hemisphere
    241 #define PATCH_CONE        0x00000010    // cone
    242 #define PATCH_TRIANGLE    0x00000020    // simple tri, assumes 3x3 patch
    243 
    244 // behaviour styles
    245 #define PATCH_CAP         0x00001000    // flat patch applied as a cap
    246 #define PATCH_SEAM        0x00002000    // flat patch applied as a seam
    247 #define PATCH_THICK       0x00004000    // patch applied as a thick portion
    248 
    249 // styles
    250 #define PATCH_BEZIER      0x00000000    // default bezier
    251 #define PATCH_BSPLINE     0x10000000    // bspline
    252 
    253 #define PATCH_TYPEMASK     0x00000fff    // 
    254 #define PATCH_BTYPEMASK    0x0000f000    // 
    255 #define PATCH_STYLEMASK    0xffff0000    // 
    256 
    257 typedef struct {
    258 	vec3_t		xyz;
    259 	float		st[2];
    260 	float		lightmap[2];
    261 	vec3_t		normal;
    262 } drawVert_t;
    263 
    264 // used in brush primitive AND entities
    265 typedef struct epair_s
    266 {
    267 	struct epair_s	*next;
    268 	char	*key;
    269 	char	*value;
    270 } epair_t;
    271 
    272 struct brush_s;
    273 typedef struct brush_s brush_t;
    274 
    275 typedef struct {
    276   int	width, height;		// in control points, not patches
    277   int   contents, flags, value, type;
    278   qtexture_t *d_texture;
    279   drawVert_t ctrl[MAX_PATCH_WIDTH][MAX_PATCH_HEIGHT];
    280   brush_t *pSymbiot;
    281   qboolean bSelected;
    282   qboolean bOverlay;
    283   qboolean bDirty;
    284   int  nListID;
    285 	epair_t *epairs;
    286   // cast this one to an IPluginTexdef if you are using it
    287   // NOTE: casting can be done with a GETPLUGINTEXDEF defined in isurfaceplugin.h
    288   // TODO: if the __ISURFACEPLUGIN_H_ header is used, use a union { void *pData; IPluginTexdef *pPluginTexdef } kind of thing ?
    289   void					*pData;
    290 } patchMesh_t;
    291 
    292 typedef struct {
    293 	int				index;
    294 	qtexture_t		*texture;
    295 	texdef_t		texdef;
    296 } terrainFace_t;
    297 
    298 typedef struct {
    299 	float			height;
    300 	float			scale;
    301 	terrainFace_t	tri;
    302 	vec4_t			rgba;
    303 	vec3_t			normal;
    304 	vec3_t			xyz;
    305 } terrainVert_t;
    306 
    307 #define MAX_TERRAIN_TEXTURES 128
    308 typedef struct {
    309 	int				width, height;
    310 
    311 	vec3_t			mins, maxs;
    312 	vec3_t			origin;
    313 	float			scale_x;
    314 	float			scale_y;
    315 
    316 	int				numtextures;
    317 	qtexture_t		*textures[ MAX_TERRAIN_TEXTURES ];
    318 
    319 	terrainVert_t	*heightmap;       // width * height
    320 
    321 	epair_t			*epairs;
    322 
    323 	brush_s			*pSymbiot;
    324 	bool			bSelected;
    325 	bool			bDirty;
    326 	int				nListID;
    327 } terrainMesh_t;
    328 
    329 typedef struct brush_s
    330 {
    331 	struct brush_s	*prev, *next;	// links in active/selected
    332 	struct brush_s	*oprev, *onext;	// links in entity
    333 	struct entity_s	*owner;
    334 	vec3_t	mins, maxs;
    335 	face_t     *brush_faces;
    336 
    337 	qboolean bModelFailed;
    338 	//
    339 	// curve brush extensions
    340 	// all are derived from brush_faces
    341 	qboolean	patchBrush;
    342 	qboolean	hiddenBrush;
    343 	qboolean	terrainBrush;
    344   
    345   //int nPatchID;
    346 
    347 	patchMesh_t *pPatch;
    348 	terrainMesh_t	*pTerrain;
    349 
    350 	struct entity_s *pUndoOwner;
    351 
    352 	int undoId;						//undo ID
    353 	int redoId;						//redo ID
    354 	int ownerId;					//entityId of the owner entity for undo
    355 
    356 	// TTimo: HTREEITEM is MFC, some plugins really don't like it
    357 #ifdef QERTYPES_USE_MFC
    358 	int numberId;         // brush number
    359 	HTREEITEM itemOwner;  // owner for grouping
    360 #else
    361 	int numberId;
    362 	DWORD itemOwner;
    363 #endif
    364 
    365 	// brush primitive only
    366 	epair_t *epairs;
    367 
    368 } brush_t;
    369 
    370 
    371 #define	MAX_FLAGS	8
    372 
    373 
    374 typedef struct trimodel_t
    375 {
    376   vec3_t v[3];
    377   float  st[3][2];
    378 } trimodel;
    379 
    380 typedef struct entitymodel_t
    381 {
    382   struct entitymodel_t *pNext;
    383   int nTriCount;
    384   trimodel *pTriList;
    385   int nTextureBind;
    386   int nSkinWidth;
    387   int nSkinHeight;
    388   int	nModelPosition;
    389 } entitymodel;
    390 
    391 
    392 // eclass show flags
    393 
    394 #define     ECLASS_LIGHT      0x00000001
    395 #define     ECLASS_ANGLE      0x00000002
    396 #define     ECLASS_PATH       0x00000004
    397 #define     ECLASS_MISCMODEL  0x00000008
    398 #define		ECLASS_PLUGINENTITY 0x00000010
    399 
    400 typedef struct eclass_s
    401 {
    402 	struct eclass_s *next;
    403 	char	*name;
    404 	qboolean	fixedsize;
    405 	qboolean	unknown;		// wasn't found in source
    406 	vec3_t	mins, maxs;
    407 	vec3_t	color;
    408 	texdef_t	texdef;
    409 	char	*comments;
    410 	char	flagnames[MAX_FLAGS][32];
    411 
    412 /*
    413   int nTriCount;
    414   trimodel *pTriList;
    415   int nTextureBind;
    416   int nSkinWidth, nSkinHeight;
    417 */
    418   entitymodel *model;
    419   char	*modelpath;
    420   char	*skinpath;
    421   int   nFrame;
    422   unsigned int nShowFlags;
    423 
    424   HMODULE	hPlug;
    425 } eclass_t;
    426 
    427 extern	eclass_t	*eclass;
    428 
    429 /*
    430 ** window bits
    431 */
    432 #define	W_CAMERA		  0x0001
    433 #define	W_XY			    0x0002
    434 #define	W_XY_OVERLAY	0x0004
    435 #define	W_Z				    0x0008
    436 #define	W_TEXTURE		  0x0010
    437 #define	W_Z_OVERLAY		0x0020
    438 #define W_CONSOLE		  0x0040
    439 #define W_ENTITY		  0x0080
    440 #define W_CAMERA_IFON 0x0100
    441 #define W_XZ          0x0200  //--| only used for patch vertex manip stuff
    442 #define W_YZ          0x0400  //--|
    443 #define W_GROUP       0x0800 
    444 #define W_MEDIA       0x1000 
    445 #define	W_ALL			0xFFFFFFFF
    446 
    447 // used in some Drawing routines
    448 enum VIEWTYPE {YZ, XZ, XY};
    449 
    450 enum terrainnoise_t { NOISE_NONE, NOISE_PLUS, NOISE_PLUSMINUS };
    451 enum terrainbrush_t { TERRAIN_BRUSH_CIRCLE, TERRAIN_BRUSH_SQUARE };
    452 enum terrainfalloff_t { TERRAIN_FALLOFF_LINEAR, TERRAIN_FALLOFF_CURVED };
    453 
    454 #endif