QERTYPES.H 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  1. /*
  2. ===========================================================================
  3. Doom 3 GPL Source Code
  4. Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
  5. This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
  6. Doom 3 Source Code is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. Doom 3 Source Code is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
  16. In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
  17. If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
  18. ===========================================================================
  19. */
  20. #ifndef _QERTYPE_H
  21. #define _QERTYPE_H
  22. #define MAXPOINTS 16
  23. class texdef_t
  24. {
  25. public:
  26. texdef_t()
  27. {
  28. name = "";
  29. shift[0] = shift[1] = 0.0;
  30. rotate = 0;
  31. scale[0] = scale[1] = 0;
  32. value = 0;
  33. }
  34. ~texdef_t()
  35. {
  36. if ( name && name[0] ) {
  37. delete []name;
  38. }
  39. name = NULL;
  40. }
  41. void SetName( const char *p )
  42. {
  43. if ( name && name[0] ) {
  44. delete []name;
  45. }
  46. if ( p && p[0] ) {
  47. name = strcpy( new char[strlen(p)+1], p );
  48. }
  49. else {
  50. name = "";
  51. }
  52. }
  53. texdef_t& operator =(const texdef_t& rhs)
  54. {
  55. if ( &rhs != this ) {
  56. SetName(rhs.name);
  57. shift[0] = rhs.shift[0];
  58. shift[1] = rhs.shift[1];
  59. rotate = rhs.rotate;
  60. scale[0] = rhs.scale[0];
  61. scale[1] = rhs.scale[1];
  62. value = rhs.value;
  63. }
  64. return *this;
  65. }
  66. //char name[128];
  67. char * name;
  68. float shift[2];
  69. float rotate;
  70. float scale[2];
  71. int value;
  72. };
  73. // Timo
  74. // new brush primitive texdef
  75. //typedef struct brushprimit_texdef_s
  76. //{
  77. // float coords[2][3];
  78. //} brushprimit_texdef_t;
  79. class brushprimit_texdef_t {
  80. public:
  81. float coords[2][3];
  82. brushprimit_texdef_t() {
  83. memset(&coords, 0, sizeof(coords));
  84. coords[0][0] = 1.0;
  85. coords[1][1] = 1.0;
  86. }
  87. };
  88. class texturewin_t
  89. {
  90. public:
  91. texturewin_t() {
  92. memset(&brushprimit_texdef.coords, 0, sizeof(brushprimit_texdef.coords));
  93. brushprimit_texdef.coords[0][0] = 1.0;
  94. brushprimit_texdef.coords[1][1] = 1.0;
  95. }
  96. ~texturewin_t() {
  97. }
  98. int width, height;
  99. int originy;
  100. // add brushprimit_texdef_t for brush primitive coordinates storage
  101. brushprimit_texdef_t brushprimit_texdef;
  102. int m_nTotalHeight;
  103. // surface plugin, must be casted to a IPluginTexdef*
  104. void* pTexdef;
  105. texdef_t texdef;
  106. };
  107. #define QER_TRANS 0x00000001
  108. #define QER_NOCARVE 0x00000002
  109. typedef struct qtexture_s
  110. {
  111. struct qtexture_s *next;
  112. char name[64]; // includes partial directory and extension
  113. int width, height;
  114. int contents;
  115. int flags;
  116. int value;
  117. int texture_number; // gl bind number
  118. // name of the .shader file
  119. char shadername[1024]; // old shader stuff
  120. bool bFromShader; // created from a shader
  121. float fTrans; // amount of transparency
  122. int nShaderFlags; // qer_ shader flags
  123. idVec3 color; // for flat shade mode
  124. bool inuse; // true = is present on the level
  125. // cast this one to an IPluginQTexture if you are using it
  126. // NOTE: casting can be done with a GETPLUGINQTEXTURE defined in isurfaceplugin.h
  127. // TODO: if the __ISURFACEPLUGIN_H_ header is used, use a union { void *pData; IPluginQTexture *pPluginQTexture } kind of thing ?
  128. void *pData;
  129. //++timo FIXME: this is the actual filename of the texture
  130. // this will be removed after shader code cleanup
  131. char filename[64];
  132. } qtexture_t;
  133. //++timo texdef and brushprimit_texdef are static
  134. // TODO : do dynamic ?
  135. typedef struct face_s
  136. {
  137. struct face_s *next;
  138. struct face_s *original; //used for vertex movement
  139. idVec3 planepts[3];
  140. idVec3 orgplanepts[3]; // used for arbitrary rotation
  141. texdef_t texdef;
  142. idPlane plane;
  143. idPlane originalPlane;
  144. bool dirty;
  145. idWinding *face_winding;
  146. idVec3 d_color;
  147. const idMaterial *d_texture;
  148. // Timo new brush primit texdef
  149. brushprimit_texdef_t brushprimit_texdef;
  150. // cast this one to an IPluginTexdef if you are using it
  151. // NOTE: casting can be done with a GETPLUGINTEXDEF defined in isurfaceplugin.h
  152. // TODO: if the __ISURFACEPLUGIN_H_ header is used, use a union { void *pData; IPluginTexdef *pPluginTexdef } kind of thing ?
  153. void *pData;
  154. } face_t;
  155. typedef struct {
  156. idVec3 xyz;
  157. float sideST[2];
  158. float capST[2];
  159. } curveVertex_t;
  160. typedef struct {
  161. curveVertex_t v[2];
  162. } sideVertex_t;
  163. #define MIN_PATCH_WIDTH 3
  164. #define MIN_PATCH_HEIGHT 3
  165. #define MAX_PATCH_WIDTH 64
  166. #define MAX_PATCH_HEIGHT 64
  167. // patch type info
  168. // type in lower 16 bits, flags in upper
  169. // endcaps directly follow this patch in the list
  170. // types
  171. #define PATCH_GENERIC 0x00000000 // generic flat patch
  172. #define PATCH_CYLINDER 0x00000001 // cylinder
  173. #define PATCH_BEVEL 0x00000002 // bevel
  174. #define PATCH_ENDCAP 0x00000004 // endcap
  175. #define PATCH_HEMISPHERE 0x00000008 // hemisphere
  176. #define PATCH_CONE 0x00000010 // cone
  177. #define PATCH_TRIANGLE 0x00000020 // simple tri, assumes 3x3 patch
  178. // behaviour styles
  179. #define PATCH_CAP 0x00001000 // flat patch applied as a cap
  180. #define PATCH_SEAM 0x00002000 // flat patch applied as a seam
  181. #define PATCH_THICK 0x00004000 // patch applied as a thick portion
  182. // styles
  183. #define PATCH_BEZIER 0x00000000 // default bezier
  184. #define PATCH_BSPLINE 0x10000000 // bspline
  185. #define PATCH_TYPEMASK 0x00000fff //
  186. #define PATCH_BTYPEMASK 0x0000f000 //
  187. #define PATCH_STYLEMASK 0xffff0000 //
  188. struct brush_s;
  189. typedef struct brush_s brush_t;
  190. typedef struct {
  191. int width, height; // in control points, not patches
  192. int horzSubdivisions;
  193. int vertSubdivisions;
  194. bool explicitSubdivisions;
  195. int contents, flags, value, type;
  196. const idMaterial *d_texture;
  197. idDrawVert *verts;
  198. //idDrawVert *ctrl;
  199. brush_t * pSymbiot;
  200. bool bSelected;
  201. bool bOverlay;
  202. int nListID;
  203. int nListIDCam;
  204. int nListSelected;
  205. idDict * epairs;
  206. // cast this one to an IPluginTexdef if you are using it
  207. // NOTE: casting can be done with a GETPLUGINTEXDEF defined in isurfaceplugin.h
  208. // TODO: if the __ISURFACEPLUGIN_H_ header is used, use a union { void *pData; IPluginTexdef *pPluginTexdef } kind of thing ?
  209. void * pData;
  210. ID_INLINE idDrawVert &ctrl( int col, int row ) {
  211. if ( col < 0 || col >= width || row < 0 || row >= height ) {
  212. common->Warning( "patchMesh_t::ctrl: control point out of range" );
  213. return verts[0];
  214. }
  215. else {
  216. return verts[row * width + col];
  217. }
  218. }
  219. } patchMesh_t;
  220. enum {
  221. LIGHT_TARGET,
  222. LIGHT_RIGHT,
  223. LIGHT_UP,
  224. LIGHT_RADIUS,
  225. LIGHT_X,
  226. LIGHT_Y,
  227. LIGHT_Z,
  228. LIGHT_START,
  229. LIGHT_END,
  230. LIGHT_CENTER
  231. };
  232. typedef struct brush_s
  233. {
  234. struct brush_s *prev, *next; // links in active/selected
  235. struct brush_s *oprev, *onext; // links in entity
  236. brush_t * list; //keep a handy link to the list its in
  237. struct entity_s *owner;
  238. idVec3 mins, maxs;
  239. idVec3 lightCenter; // for moving the shading center of point lights
  240. idVec3 lightRight;
  241. idVec3 lightTarget;
  242. idVec3 lightUp;
  243. idVec3 lightRadius;
  244. idVec3 lightOffset;
  245. idVec3 lightColor;
  246. idVec3 lightStart;
  247. idVec3 lightEnd;
  248. bool pointLight;
  249. bool startEnd;
  250. int lightTexture;
  251. bool trackLightOrigin; // this brush is a special case light brush
  252. bool entityModel;
  253. face_t *brush_faces;
  254. bool bModelFailed;
  255. //
  256. // curve brush extensions
  257. // all are derived from brush_faces
  258. bool hiddenBrush;
  259. bool forceWireFrame;
  260. bool forceVisibile;
  261. patchMesh_t *pPatch;
  262. struct entity_s *pUndoOwner;
  263. int undoId; //undo ID
  264. int redoId; //redo ID
  265. int ownerId; //entityId of the owner entity for undo
  266. // TTimo: HTREEITEM is MFC, some plugins really don't like it
  267. #ifdef QERTYPES_USE_MFC
  268. int numberId; // brush number
  269. HTREEITEM itemOwner; // owner for grouping
  270. #else
  271. int numberId;
  272. DWORD itemOwner;
  273. #endif
  274. idRenderModel *modelHandle;
  275. // brush primitive only
  276. idDict epairs;
  277. } brush_t;
  278. #define MAX_FLAGS 8
  279. typedef struct trimodel_t
  280. {
  281. idVec3 v[3];
  282. float st[3][2];
  283. } trimodel;
  284. // eclass show flags
  285. #define ECLASS_LIGHT 0x00000001
  286. #define ECLASS_ANGLE 0x00000002
  287. #define ECLASS_PATH 0x00000004
  288. #define ECLASS_MISCMODEL 0x00000008
  289. #define ECLASS_PLUGINENTITY 0x00000010
  290. #define ECLASS_PROJECTEDLIGHT 0x00000020
  291. #define ECLASS_WORLDSPAWN 0x00000040
  292. #define ECLASS_SPEAKER 0x00000080
  293. #define ECLASS_PARTICLE 0x00000100
  294. #define ECLASS_ROTATABLE 0x00000200
  295. #define ECLASS_CAMERAVIEW 0x00000400
  296. #define ECLASS_MOVER 0x00000800
  297. #define ECLASS_ENV 0x00001000
  298. #define ECLASS_COMBATNODE 0x00002000
  299. #define ECLASS_LIQUID 0x00004000
  300. enum EVAR_TYPES {
  301. EVAR_STRING,
  302. EVAR_INT,
  303. EVAR_FLOAT,
  304. EVAR_BOOL,
  305. EVAR_COLOR,
  306. EVAR_MATERIAL,
  307. EVAR_MODEL,
  308. EVAR_GUI,
  309. EVAR_SOUND
  310. };
  311. typedef struct evar_s {
  312. int type;
  313. idStr name;
  314. idStr desc;
  315. } evar_t;
  316. typedef struct eclass_s
  317. {
  318. struct eclass_s *next;
  319. idStr name;
  320. bool fixedsize;
  321. bool unknown; // wasn't found in source
  322. idVec3 mins, maxs;
  323. idVec3 color;
  324. texdef_t texdef;
  325. idStr comments;
  326. idStr desc;
  327. idRenderModel *modelHandle;
  328. idRenderModel *entityModel;
  329. int nFrame;
  330. unsigned int nShowFlags;
  331. idStr defMaterial;
  332. idDict args;
  333. idDict defArgs;
  334. idList<evar_t> vars;
  335. HMODULE hPlug;
  336. } eclass_t;
  337. extern eclass_t *eclass;
  338. /*
  339. ** window bits
  340. */
  341. #define W_CAMERA 0x0001
  342. #define W_XY 0x0002
  343. #define W_XY_OVERLAY 0x0004
  344. #define W_Z 0x0008
  345. #define W_TEXTURE 0x0010
  346. #define W_Z_OVERLAY 0x0020
  347. #define W_CONSOLE 0x0040
  348. #define W_ENTITY 0x0080
  349. #define W_CAMERA_IFON 0x0100
  350. #define W_XZ 0x0200 //--| only used for patch vertex manip stuff
  351. #define W_YZ 0x0400 //--|
  352. #define W_MEDIA 0x1000
  353. #define W_GAME 0x2000
  354. #define W_ALL 0xFFFFFFFF
  355. // used in some Drawing routines
  356. enum VIEWTYPE {YZ, XZ, XY};
  357. #endif