/MTA10/sdk/game/RenderWare.h

http://mtasa-blue.googlecode.com/ · C Header · 420 lines · 375 code · 19 blank · 26 comment · 0 complexity · fe7faf23b5094baa12025f1698435a8f MD5 · raw file

  1. /*****************************************************************************
  2. *
  3. * PROJECT: Multi Theft Auto v1.0
  4. * LICENSE: See LICENSE in the top level directory
  5. * FILE: sdk/game/RenderWare.h
  6. * PURPOSE: RenderWare-compatible definitions for
  7. * Grand Theft Auto: San Andreas
  8. *
  9. * Multi Theft Auto is available from http://www.multitheftauto.com/
  10. * RenderWare is Š Criterion Software
  11. *
  12. *****************************************************************************/
  13. #ifndef __RENDERWARE_COMPAT
  14. #define __RENDERWARE_COMPAT
  15. /*****************************************************************************/
  16. /** RenderWare rendering types **/
  17. /*****************************************************************************/
  18. // RenderWare definitions
  19. #define RW_STRUCT_ALIGN ((int)((~((unsigned int)0))>>1))
  20. #define RW_TEXTURE_NAME_LENGTH 32
  21. #define RW_MAX_TEXTURE_COORDS 8
  22. typedef struct RwV2d RwV2d;
  23. typedef struct RwV3d RwV3d;
  24. typedef struct RwPlane RwPlane;
  25. typedef struct RwBBox RwBBox;
  26. typedef struct RpGeometry RpGeometry;
  27. typedef void RpWorld;
  28. typedef struct RpClump RpClump;
  29. typedef struct RwRaster RwRaster;
  30. typedef struct RpMaterialLighting RpMaterialLighting;
  31. typedef struct RpMaterialList RpMaterialList;
  32. typedef struct RpMaterial RpMaterial;
  33. typedef struct RpTriangle RpTriangle;
  34. typedef struct RwTextureCoordinates RwTextureCoordinates;
  35. typedef struct RwColor RwColor;
  36. typedef struct RwColorFloat RwColorFloat;
  37. typedef struct RwObjectFrame RwObjectFrame;
  38. typedef struct RpAtomic RpAtomic;
  39. typedef struct RwCamera RwCamera;
  40. typedef struct RpLight RpLight;
  41. typedef RwCamera *(*RwCameraPreCallback) (RwCamera * camera);
  42. typedef RwCamera *(*RwCameraPostCallback) (RwCamera * camera);
  43. typedef RpAtomic *(*RpAtomicCallback) (RpAtomic * atomic);
  44. typedef RpClump *(*RpClumpCallback) (RpClump * clump, void *data);
  45. // RenderWare primitive types
  46. struct RwV2d
  47. { // 8-byte
  48. float x,y;
  49. };
  50. struct RwV3d
  51. { // 12-byte
  52. float x,y,z;
  53. };
  54. struct RwPlane
  55. {
  56. RwV3d normal;
  57. float length;
  58. };
  59. struct RwBBox
  60. {
  61. RwV3d max;
  62. RwV3d min;
  63. };
  64. struct RwSphere
  65. {
  66. RwV3d position;
  67. float radius;
  68. };
  69. struct RwMatrix
  70. { // 16-byte padded
  71. RwV3d right; // 0
  72. unsigned int flags; // 12
  73. RwV3d up; // 16
  74. unsigned int pad1; // 28
  75. RwV3d at; // 32
  76. unsigned int pad2; // 44
  77. RwV3d pos; // 48
  78. unsigned int pad3; // 60
  79. };
  80. // RenderWare enumerations
  81. enum RwPrimitiveType
  82. {
  83. PRIMITIVE_NULL = 0,
  84. PRIMITIVE_LINE_SEGMENT = 1,
  85. PRIMITIVE_LINE_SEGMENT_CONNECTED = 2,
  86. PRIMITIVE_TRIANGLE = 3,
  87. PRIMITIVE_TRIANGLE_STRIP = 4,
  88. PRIMITIVE_TRIANGLE_FAN = 5,
  89. PRIMITIVE_POINT = 6,
  90. PRIMITIVE_LAST = RW_STRUCT_ALIGN
  91. };
  92. enum RwCameraType
  93. {
  94. RW_CAMERA_NULL = 0,
  95. RW_CAMERA_PERSPECTIVE = 1,
  96. RW_CAMERA_ORTHOGRAPHIC = 2,
  97. RW_CAMERA_LAST = RW_STRUCT_ALIGN
  98. };
  99. enum RpAtomicFlags
  100. {
  101. ATOMIC_COLLISION = 1,
  102. ATOMIC_VISIBLE = 4,
  103. ATOMIC_LAST = RW_STRUCT_ALIGN
  104. };
  105. enum RwRasterLockFlags
  106. {
  107. RASTER_LOCK_WRITE = 1,
  108. RASTER_LOCK_READ = 2,
  109. RASTER_LOCK_LAST = RW_STRUCT_ALIGN
  110. };
  111. enum RwTransformOrder
  112. {
  113. TRANSFORM_INITIAL = 0,
  114. TRANSFORM_BEFORE = 1,
  115. TRANSFORM_AFTER = 2,
  116. TRANSFORM_LAST = RW_STRUCT_ALIGN
  117. };
  118. enum RpLightType
  119. {
  120. LIGHT_TYPE_NULL = 0,
  121. LIGHT_TYPE_DIRECTIONAL = 1,
  122. LIGHT_TYPE_AMBIENT = 2,
  123. LIGHT_TYPE_POINT = 0x80,
  124. LIGHT_TYPE_SPOT_1 = 0x81,
  125. LIGHT_TYPE_SPOT_2 = 0x82,
  126. LIGHT_TYPE_LAST = RW_STRUCT_ALIGN
  127. };
  128. enum RpLightFlags
  129. {
  130. LIGHT_ILLUMINATES_ATOMICS = 1,
  131. LIGHT_ILLUMINATES_GEOMETRY = 2,
  132. LIGHT_FLAGS_LAST = RW_STRUCT_ALIGN
  133. };
  134. // RenderWare/plugin base types
  135. struct RwObject
  136. {
  137. unsigned char type;
  138. unsigned char subtype;
  139. unsigned char flags;
  140. unsigned char privateFlags;
  141. void *parent; // should be RwFrame with RpClump
  142. };
  143. struct RwVertex
  144. {
  145. RwV3d position;
  146. RwV3d normal;
  147. unsigned int color;
  148. float u,v;
  149. };
  150. struct RwListEntry
  151. {
  152. RwListEntry *next,*prev;
  153. };
  154. struct RwList
  155. {
  156. RwListEntry root;
  157. };
  158. struct RwFrame
  159. {
  160. RwObject object; // 0
  161. void *pad1,*pad2; // 8
  162. RwMatrix modelling; // 16
  163. RwMatrix ltm; // 32
  164. RwList objects; // 48
  165. struct RwFrame *child; // 56
  166. struct RwFrame *next; // 60
  167. struct RwFrame *root; // 64
  168. // Rockstar Frame extension (0x253F2FE) (24 bytes)
  169. unsigned char pluginData[8]; // padding
  170. char szName[16]; // name (as stored in the frame extension)
  171. };
  172. struct RwTexDictionary
  173. {
  174. RwObject object;
  175. RwList textures;
  176. RwListEntry globalTXDs;
  177. };
  178. struct RwTexture
  179. {
  180. RwRaster *raster;
  181. RwTexDictionary *txd;
  182. RwListEntry TXDList;
  183. char name[RW_TEXTURE_NAME_LENGTH];
  184. char mask[RW_TEXTURE_NAME_LENGTH];
  185. unsigned int flags;
  186. int refs;
  187. };
  188. struct RwTextureCoordinates
  189. {
  190. float u,v;
  191. };
  192. struct RwRaster
  193. {
  194. RwRaster *parent; // 0
  195. unsigned char *pixels; // 4
  196. unsigned char *palette; // 8
  197. int width, height, depth; // 12, 16 / 0x10, 20
  198. int stride; // 24 / 0x18
  199. short u, v;
  200. unsigned char type;
  201. unsigned char flags;
  202. unsigned char privateFlags;
  203. unsigned char format;
  204. unsigned char *origPixels;
  205. int origWidth, origHeight, origDepth;
  206. void* renderResource;
  207. };
  208. struct RwColorFloat
  209. {
  210. float r,g,b,a;
  211. };
  212. struct RwColor
  213. {
  214. unsigned char r,g,b,a;
  215. };
  216. struct RwObjectFrame
  217. {
  218. RwObject object;
  219. RwListEntry lFrame;
  220. void *callback;
  221. };
  222. struct RwCameraFrustum
  223. {
  224. RwPlane plane;
  225. unsigned char x,y,z;
  226. unsigned char unknown1;
  227. };
  228. struct RwCamera
  229. {
  230. RwObjectFrame object;
  231. RwCameraType type;
  232. RwCameraPreCallback preCallback;
  233. RwCameraPostCallback postCallback;
  234. RwMatrix matrix;
  235. RwRaster *bufferColor;
  236. RwRaster *bufferDepth;
  237. RwV2d screen;
  238. RwV2d screenInverse;
  239. RwV2d screenOffset;
  240. float nearplane;
  241. float farplane;
  242. float fog;
  243. float unknown1;
  244. float unknown2;
  245. RwCameraFrustum frustum4D[6];
  246. RwBBox viewBBox;
  247. RwV3d frustum3D[8];
  248. };
  249. struct RpInterpolation
  250. {
  251. unsigned int unknown1;
  252. unsigned int unknown2;
  253. float unknown3;
  254. float unknown4;
  255. float unknown5;
  256. };
  257. struct RpAtomic
  258. {
  259. RwObjectFrame object;
  260. void *info;
  261. RpGeometry *geometry;
  262. RwSphere bsphereLocal;
  263. RwSphere bsphereWorld;
  264. RpClump *clump;
  265. RwListEntry globalClumps;
  266. RpAtomicCallback renderCallback;
  267. RpInterpolation interpolation;
  268. unsigned short frame;
  269. unsigned short unknown7;
  270. RwList sectors;
  271. void *render;
  272. };
  273. struct RpAtomicContainer {
  274. RpAtomic *atomic;
  275. char szName[17];
  276. };
  277. struct RpLight
  278. {
  279. RwObjectFrame object;
  280. float radius;
  281. RwColorFloat color;
  282. float unknown1;
  283. RwList sectors;
  284. RwListEntry globalLights;
  285. unsigned short frame;
  286. unsigned short unknown2;
  287. };
  288. struct RpClump
  289. { // RenderWare (plugin) Clump (used by GTA)
  290. RwObject object;
  291. RwList atomics;
  292. RwList lights;
  293. RwList cameras;
  294. RwListEntry globalClumps;
  295. RpClumpCallback callback;
  296. };
  297. struct RpMaterialLighting
  298. {
  299. float ambient, specular, diffuse;
  300. };
  301. struct RpMaterial
  302. {
  303. RwTexture* texture;
  304. RwColor color;
  305. void *render;
  306. RpMaterialLighting lighting;
  307. short refs;
  308. short id;
  309. };
  310. struct RpMaterials
  311. {
  312. RpMaterial **materials;
  313. int entries;
  314. int unknown;
  315. };
  316. struct RpTriangle
  317. {
  318. unsigned short v1, v2, v3;
  319. unsigned short materialId;
  320. };
  321. struct RpGeometry
  322. {
  323. RwObject object;
  324. unsigned int flags;
  325. unsigned short unknown1;
  326. short refs;
  327. int triangles_size;
  328. int vertices_size;
  329. int unknown_size;
  330. int texcoords_size;
  331. RpMaterials materials;
  332. RpTriangle *triangles;
  333. RwColor *colors;
  334. RwTextureCoordinates *texcoords[RW_MAX_TEXTURE_COORDS];
  335. void *unknown2;
  336. void *info;
  337. void *unknown3;
  338. };
  339. /*****************************************************************************/
  340. /** RenderWare I/O **/
  341. /*****************************************************************************/
  342. // RenderWare type definitions
  343. typedef int (* RwIOCallbackClose) (void *data);
  344. typedef unsigned int (* RwIOCallbackRead) (void *data, void *buffer, unsigned int length);
  345. typedef int (* RwIOCallbackWrite) (void *data, const void *buffer, unsigned int length);
  346. typedef int (* RwIOCallbackOther) (void *data, unsigned int offset);
  347. // RenderWare enumerations
  348. enum RwStreamType
  349. {
  350. STREAM_TYPE_NULL = 0,
  351. STREAM_TYPE_FILE = 1,
  352. STREAM_TYPE_FILENAME = 2,
  353. STREAM_TYPE_BUFFER = 3,
  354. STREAM_TYPE_CALLBACK = 4,
  355. STREAM_TYPE_LAST = RW_STRUCT_ALIGN
  356. };
  357. enum RwStreamMode
  358. {
  359. STREAM_MODE_NULL = 0,
  360. STREAM_MODE_READ = 1,
  361. STREAM_MODE_WRITE = 2,
  362. STREAM_MODE_APPEND = 3,
  363. STREAM_MODE_LAST = RW_STRUCT_ALIGN
  364. };
  365. // RenderWare base types
  366. struct RwBuffer
  367. {
  368. void *ptr;
  369. unsigned int size;
  370. };
  371. union RwStreamTypeData
  372. {
  373. struct {
  374. unsigned int position;
  375. unsigned int size;
  376. void *ptr_file;
  377. };
  378. struct {
  379. void *file;
  380. };
  381. struct {
  382. RwIOCallbackClose callbackClose;
  383. RwIOCallbackRead callbackRead;
  384. RwIOCallbackWrite callbackWrite;
  385. RwIOCallbackOther callbackOther;
  386. void *ptr_callback;
  387. };
  388. };
  389. struct RwStream
  390. {
  391. RwStreamType type;
  392. RwStreamMode mode;
  393. int pos;
  394. RwStreamTypeData data;
  395. int id;
  396. };
  397. struct RwError
  398. {
  399. int err1,err2;
  400. };
  401. #endif