Source

quake3 / q3radiant / QERTYPES.H

Full commit
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.

This file is part of Quake III Arena source code.

Quake III Arena source code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.

Quake III Arena source code is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Foobar; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
===========================================================================
*/
// qertypes.h
//
// common types
// merged from brush.h, etc. for plugin support
//
#ifndef _QERTYPE_H
#define _QERTYPE_H

#ifndef __BYTEBOOL__
#define __BYTEBOOL__
typedef boolean qboolean;
//typedef unsigned char byte;
#endif

#define	MAXPOINTS	16

typedef float vec_t;
typedef vec_t vec2_t[2];
typedef vec_t vec3_t[3];

#include "splines/math_vector.h"

#ifndef M_PI
#define M_PI		3.14159265358979323846	// matches value in gcc v2 math.h
#endif

class texdef_t
{
public:
  texdef_t()
  {
    name = new char[1];
    name[0] = '\0';
  }
  ~texdef_t()
  {
    delete []name;
    name = NULL;
  }

  const char *Name( void )
  {
	  if ( name ) {
		  return name;
	  }

	  return "";
  }

  void SetName(const char *p)
  {
    if (name)
    {
      delete []name;
    }
    if (p)
    {
      name = strcpy(new char[strlen(p)+1], p);
    }
    else
    {
      name = new char[1];
      name[0] = '\0';
    }
  }

  texdef_t& operator =(const texdef_t& rhs)
  {
    if (&rhs != this)
    {
      SetName(rhs.name);
      shift[0] = rhs.shift[0];
      shift[1] = rhs.shift[1];
      rotate = rhs.rotate;
      scale[0] = rhs.scale[0];
      scale[1] = rhs.scale[1];
      contents = rhs.contents;
      flags = rhs.flags;
      value = rhs.value;
    }
    return *this;
  }
	//char	name[128];
	char	*name;
	float	shift[2];
	float	rotate;
	float	scale[2];
	int		contents;
	int		flags;
	int		value;
};

// Timo
// new brush primitive texdef
typedef struct brushprimit_texdef_s
{
	vec_t	coords[2][3];
} brushprimit_texdef_t;

class texturewin_t
{
public:
  texturewin_t()
  {
  }
  ~texturewin_t()
  {
  }
	int			width, height;
	int			originy;
	// add brushprimit_texdef_t for brush primitive coordinates storage
	brushprimit_texdef_t	brushprimit_texdef;
	int m_nTotalHeight;
	// surface plugin, must be casted to a IPluginTexdef*
	void* pTexdef;
	texdef_t	texdef;
};

#define QER_TRANS     0x00000001
#define QER_NOCARVE   0x00000002

typedef struct qtexture_s
{
	struct	qtexture_s *next;
	char	name[64];		// includes partial directory and extension
  int		width,  height;
	int		contents;
	int		flags;
	int		value;
	int		texture_number;	// gl bind number
  
	// name of the .shader file
  char  shadername[1024]; // old shader stuff
  qboolean bFromShader;   // created from a shader
  float fTrans;           // amount of transparency
  int   nShaderFlags;     // qer_ shader flags
	vec3_t	color;			    // for flat shade mode
	qboolean	inuse;		    // true = is present on the level

	// cast this one to an IPluginQTexture if you are using it
	// NOTE: casting can be done with a GETPLUGINQTEXTURE defined in isurfaceplugin.h
	// TODO: if the __ISURFACEPLUGIN_H_ header is used, use a union { void *pData; IPluginQTexture *pPluginQTexture } kind of thing ?
	void					*pData;

	//++timo FIXME: this is the actual filename of the texture
	// this will be removed after shader code cleanup
	char filename[64];

} qtexture_t;

// NOTE: don't trust this definition!
// you should read float points[..][5]
// see NewWinding definition
#define MAX_POINTS_ON_WINDING 64
typedef struct
{
	int		numpoints;
	int		maxpoints;
	float 	points[8][5];			// variable sized
} winding_t;

typedef struct
{
    vec3_t	normal;
    double	dist;
    int		type;
} plane_t;

//++timo texdef and brushprimit_texdef are static
// TODO : do dynamic ?
typedef struct face_s
{
	struct face_s			*next;
	struct face_s			*original;		//used for vertex movement
	vec3_t					planepts[3];
	texdef_t				texdef;
	plane_t					plane;

	winding_t				*face_winding;

	vec3_t					d_color;
	qtexture_t				*d_texture;

	// Timo new brush primit texdef
	brushprimit_texdef_t	brushprimit_texdef;

	// cast this one to an IPluginTexdef if you are using it
	// NOTE: casting can be done with a GETPLUGINTEXDEF defined in isurfaceplugin.h
	// TODO: if the __ISURFACEPLUGIN_H_ header is used, use a union { void *pData; IPluginTexdef *pPluginTexdef } kind of thing ?
	void					*pData;
} face_t;

typedef struct {
	vec3_t	xyz;
	float	sideST[2];
	float	capST[2];
} curveVertex_t;

typedef struct {
	curveVertex_t	v[2];
} sideVertex_t;


#define	MIN_PATCH_WIDTH		3
#define	MIN_PATCH_HEIGHT 	3

#define	MAX_PATCH_WIDTH		16
#define	MAX_PATCH_HEIGHT	16

// patch type info
// type in lower 16 bits, flags in upper
// endcaps directly follow this patch in the list

// types
#define PATCH_GENERIC     0x00000000    // generic flat patch
#define PATCH_CYLINDER    0x00000001    // cylinder
#define PATCH_BEVEL       0x00000002    // bevel
#define PATCH_ENDCAP      0x00000004    // endcap
#define PATCH_HEMISPHERE  0x00000008    // hemisphere
#define PATCH_CONE        0x00000010    // cone
#define PATCH_TRIANGLE    0x00000020    // simple tri, assumes 3x3 patch

// behaviour styles
#define PATCH_CAP         0x00001000    // flat patch applied as a cap
#define PATCH_SEAM        0x00002000    // flat patch applied as a seam
#define PATCH_THICK       0x00004000    // patch applied as a thick portion

// styles
#define PATCH_BEZIER      0x00000000    // default bezier
#define PATCH_BSPLINE     0x10000000    // bspline

#define PATCH_TYPEMASK     0x00000fff    // 
#define PATCH_BTYPEMASK    0x0000f000    // 
#define PATCH_STYLEMASK    0xffff0000    // 

typedef struct {
	vec3_t		xyz;
	float		st[2];
	float		lightmap[2];
	vec3_t		normal;
} drawVert_t;

// used in brush primitive AND entities
typedef struct epair_s
{
	struct epair_s	*next;
	char	*key;
	char	*value;
} epair_t;

struct brush_s;
typedef struct brush_s brush_t;

typedef struct {
  int	width, height;		// in control points, not patches
  int   contents, flags, value, type;
  qtexture_t *d_texture;
  drawVert_t ctrl[MAX_PATCH_WIDTH][MAX_PATCH_HEIGHT];
  brush_t *pSymbiot;
  qboolean bSelected;
  qboolean bOverlay;
  qboolean bDirty;
  int  nListID;
	epair_t *epairs;
  // cast this one to an IPluginTexdef if you are using it
  // NOTE: casting can be done with a GETPLUGINTEXDEF defined in isurfaceplugin.h
  // TODO: if the __ISURFACEPLUGIN_H_ header is used, use a union { void *pData; IPluginTexdef *pPluginTexdef } kind of thing ?
  void					*pData;
} patchMesh_t;

typedef struct {
	int				index;
	qtexture_t		*texture;
	texdef_t		texdef;
} terrainFace_t;

typedef struct {
	float			height;
	float			scale;
	terrainFace_t	tri;
	vec4_t			rgba;
	vec3_t			normal;
	vec3_t			xyz;
} terrainVert_t;

#define MAX_TERRAIN_TEXTURES 128
typedef struct {
	int				width, height;

	vec3_t			mins, maxs;
	vec3_t			origin;
	float			scale_x;
	float			scale_y;

	int				numtextures;
	qtexture_t		*textures[ MAX_TERRAIN_TEXTURES ];

	terrainVert_t	*heightmap;       // width * height

	epair_t			*epairs;

	brush_s			*pSymbiot;
	bool			bSelected;
	bool			bDirty;
	int				nListID;
} terrainMesh_t;

typedef struct brush_s
{
	struct brush_s	*prev, *next;	// links in active/selected
	struct brush_s	*oprev, *onext;	// links in entity
	struct entity_s	*owner;
	vec3_t	mins, maxs;
	face_t     *brush_faces;

	qboolean bModelFailed;
	//
	// curve brush extensions
	// all are derived from brush_faces
	qboolean	patchBrush;
	qboolean	hiddenBrush;
	qboolean	terrainBrush;
  
  //int nPatchID;

	patchMesh_t *pPatch;
	terrainMesh_t	*pTerrain;

	struct entity_s *pUndoOwner;

	int undoId;						//undo ID
	int redoId;						//redo ID
	int ownerId;					//entityId of the owner entity for undo

	// TTimo: HTREEITEM is MFC, some plugins really don't like it
#ifdef QERTYPES_USE_MFC
	int numberId;         // brush number
	HTREEITEM itemOwner;  // owner for grouping
#else
	int numberId;
	DWORD itemOwner;
#endif

	// brush primitive only
	epair_t *epairs;

} brush_t;


#define	MAX_FLAGS	8


typedef struct trimodel_t
{
  vec3_t v[3];
  float  st[3][2];
} trimodel;

typedef struct entitymodel_t
{
  struct entitymodel_t *pNext;
  int nTriCount;
  trimodel *pTriList;
  int nTextureBind;
  int nSkinWidth;
  int nSkinHeight;
  int	nModelPosition;
} entitymodel;


// eclass show flags

#define     ECLASS_LIGHT      0x00000001
#define     ECLASS_ANGLE      0x00000002
#define     ECLASS_PATH       0x00000004
#define     ECLASS_MISCMODEL  0x00000008
#define		ECLASS_PLUGINENTITY 0x00000010

typedef struct eclass_s
{
	struct eclass_s *next;
	char	*name;
	qboolean	fixedsize;
	qboolean	unknown;		// wasn't found in source
	vec3_t	mins, maxs;
	vec3_t	color;
	texdef_t	texdef;
	char	*comments;
	char	flagnames[MAX_FLAGS][32];

/*
  int nTriCount;
  trimodel *pTriList;
  int nTextureBind;
  int nSkinWidth, nSkinHeight;
*/
  entitymodel *model;
  char	*modelpath;
  char	*skinpath;
  int   nFrame;
  unsigned int nShowFlags;

  HMODULE	hPlug;
} eclass_t;

extern	eclass_t	*eclass;

/*
** window bits
*/
#define	W_CAMERA		  0x0001
#define	W_XY			    0x0002
#define	W_XY_OVERLAY	0x0004
#define	W_Z				    0x0008
#define	W_TEXTURE		  0x0010
#define	W_Z_OVERLAY		0x0020
#define W_CONSOLE		  0x0040
#define W_ENTITY		  0x0080
#define W_CAMERA_IFON 0x0100
#define W_XZ          0x0200  //--| only used for patch vertex manip stuff
#define W_YZ          0x0400  //--|
#define W_GROUP       0x0800 
#define W_MEDIA       0x1000 
#define	W_ALL			0xFFFFFFFF

// used in some Drawing routines
enum VIEWTYPE {YZ, XZ, XY};

enum terrainnoise_t { NOISE_NONE, NOISE_PLUS, NOISE_PLUSMINUS };
enum terrainbrush_t { TERRAIN_BRUSH_CIRCLE, TERRAIN_BRUSH_SQUARE };
enum terrainfalloff_t { TERRAIN_FALLOFF_LINEAR, TERRAIN_FALLOFF_CURVED };

#endif