QERTYPES.H 10 KB

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