Open Source Tomb Raider Engine
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

TombRaiderData.h 45KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138
  1. /*!
  2. * \file include/TombRaiderData.h
  3. * \brief Structs and enums for TombRaider
  4. *
  5. * \author Mongoose
  6. */
  7. #ifndef _TOMBRAIDERDATA_H_
  8. #define _TOMBRAIDERDATA_H_
  9. #include <cstdint>
  10. #ifdef _MSC_VER
  11. #pragma pack(push, tr2_h, 1)
  12. #endif
  13. #define TR_SOUND_FOOTSTEP0 1
  14. #define TR_SOUND_F_PISTOL 12
  15. #define TR_ANIMATION_RUN 0
  16. #define TR_ANIMATION_STAND 11
  17. #define TR_ANIMATION_TURN_L 12
  18. #define TR_ANIMATION_TURN_R 13
  19. #define TR_ANIMATION_HIT_WALL_FRONT 53
  20. #define TR_ANIMATION_SWIM_IDLE 87
  21. #define TR_ANIMATION_SWIM 86
  22. #define TR_ANIMATION_SWIM_L 143
  23. #define TR_ANIMATION_SWIM_R 144
  24. #define TR_ANIMATION_GRAB_LEDGE 96
  25. #define TR_ANIMATION_PULLING_UP 97
  26. typedef enum {
  27. TR_VERSION_UNKNOWN,
  28. TR_VERSION_1,
  29. TR_VERSION_2,
  30. TR_VERSION_3,
  31. TR_VERSION_4,
  32. TR_VERSION_5
  33. } tr2_version_type;
  34. typedef enum {
  35. TR_FREAD_NORMAL = 0,
  36. TR_FREAD_COMPRESSED
  37. } tr_fread_mode_t;
  38. typedef enum {
  39. tombraiderLight_typeDirectional = 1,
  40. tombraiderLight_typeSpot = 2,
  41. tombraiderLight_typePoint = 3
  42. } tombraiderLightType;
  43. typedef enum {
  44. tombraiderLight_useCutoff = 1,
  45. tombraiderLight_useAttenuation = 2
  46. } tombraiderLightFlags;
  47. typedef enum {
  48. tombraiderRoom_underWater = 1
  49. } tombraiderRoomFlags;
  50. typedef enum {
  51. tombraiderSector_wall = 1
  52. } tombraiderSectorFlags;
  53. typedef enum {
  54. tombraiderFace_Alpha = (1 << 0),
  55. tombraiderFace_Colored = (1 << 1),
  56. tombraiderFace_PartialAlpha = (1 << 2)
  57. } tombraiderFace_Flags;
  58. enum TR4_Objects {
  59. TR4_LARA = 0,
  60. TR4_PISTOLS_ANIM = 1,
  61. TR4_UZI_ANIM = 2,
  62. TR4_SHOTGUN_ANIM = 3,
  63. TR4_CROSSBOW_ANIM = 4,
  64. TR4_GRENADE_GUN_ANIM = 5,
  65. TR4_SIXSHOOTER_ANIM = 6,
  66. TR4_FLARE_ANIM = 7,
  67. TR4_LARA_SKIN = 8,
  68. TR4_LARA_SKIN_JOINTS = 9,
  69. TR4_LARA_SCREAM = 10,
  70. TR4_LARA_CROSSBOW_LASER = 11,
  71. TR4_LARA_REVOLVER_LASER = 12,
  72. TR4_LARA_HOLSTERS = 13,
  73. TR4_LARA_HOLSTERS_PISTOLS = 14,
  74. TR4_LARA_HOLSTERS_UZIS = 15,
  75. TR4_LARA_HOLSTERS_SIXSHOOTER = 16,
  76. TR4_LARA_SPEECH_HEAD1 = 17,
  77. TR4_LARA_SPEECH_HEAD2 = 18,
  78. TR4_LARA_SPEECH_HEAD3 = 19,
  79. TR4_LARA_SPEECH_HEAD4 = 20
  80. };
  81. /*!
  82. * \brief Basic 24-bit colour structure.
  83. *
  84. * It appears that only 6 bits per colour are actually
  85. * used, making it 18-bit colour.
  86. */
  87. typedef struct {
  88. unsigned char r; //!< Red part
  89. unsigned char g; //!< Green part
  90. unsigned char b; //!< Blue part
  91. } __attribute__ ((packed)) tr2_colour_t;
  92. /*!
  93. * \brief Basic vertex structure.
  94. *
  95. * Note that all vertices are relative coordinates;
  96. * each mesh (room, object, etc.) has its own offset by
  97. * which the vertex coordinates are translated.
  98. */
  99. typedef struct {
  100. short x;
  101. short y;
  102. short z;
  103. } __attribute__ ((packed)) tr2_vertex_t;
  104. /*!
  105. * \brief A rectangular (quad) face definition.
  106. *
  107. * Four vertices (the values are indices into the
  108. * appropriate vertex list) and a texture (an index
  109. * into the texture list) or colour (index into 8-bit palette).
  110. *
  111. * I've seen a few coloured polygons where Texture is
  112. * greater than 255, but ANDing the value with 0xFF
  113. * seems to produce acceptable results.
  114. */
  115. typedef struct {
  116. unsigned short vertices[4];
  117. unsigned short texture;
  118. } __attribute__ ((packed)) tr2_quad_t; // was tr2_face4
  119. typedef struct {
  120. unsigned short vertices[4]; //!< The 4 vertices of a quad
  121. unsigned short texture; //!< Object-texture index
  122. unsigned short lighting; //!< Transparency flag & strength of the highlight
  123. /*!<
  124. * Bit 0: if set, alpha channel = intensity (same meaning that when the
  125. * Attribute field of tr2_object_texture is 2. Cf TRosetta stone document)
  126. *
  127. * Bit 1-7: strength of the highlight. In TR4, objects can exhibit some kind
  128. * of light reflection when seen from some particular angles. These bits give
  129. * the strength of this effect:
  130. * the more bigger the value is, the more visible is the effect.
  131. */
  132. } __attribute__ ((packed)) tr4_quad_t;
  133. /*!
  134. * \brief A triangular face definition.
  135. *
  136. * Three vertices (the values are indices into the
  137. * appropriate vertex list) and a texture (an index into the
  138. * texture list) or colour (index into palette).
  139. *
  140. * In the case of a colour, (Texture & 0xff) is the index
  141. * into the 8-bit palette, while (Texture >> 8) is
  142. * the index into the 16-bit palette.
  143. */
  144. typedef struct {
  145. unsigned short vertices[3];
  146. unsigned short texture;
  147. } __attribute__ ((packed)) tr2_tri_t; // was tr2_face3
  148. typedef struct {
  149. unsigned short vertices[3]; //!< The 3 vertices of a tri
  150. unsigned short texture; //!< Object-texture index
  151. unsigned short lighting; //!< Transparency flag & strength of the highlight
  152. } __attribute__ ((packed)) tr4_tri_t;
  153. /*!
  154. * \brief An 8-bit texture tile (65536 bytes).
  155. *
  156. * Each byte represents a pixel whose colour
  157. * is in the 8-bit palette.
  158. */
  159. typedef struct {
  160. unsigned char tile[256 * 256];
  161. } __attribute__ ((packed)) tr2_textile8_t;
  162. /*!
  163. * \brief A 16-bit texture tile (131072 bytes).
  164. *
  165. * Each word represents a pixel
  166. * whose colour is of the form ARGB, MSB-to-LSB:
  167. *
  168. * * 1-bit transparency (0: transparent, 1: opaque)
  169. * * 5-bit red channel
  170. * * 5-bit green channel
  171. * * 5-bit blue channel
  172. */
  173. typedef struct {
  174. unsigned short tile[256 * 256];
  175. } __attribute__ ((packed)) tr2_textile16_t;
  176. /*!
  177. * \brief A 32-bit texture tile (262144 bytes).
  178. *
  179. * BGRA with 4bytes each channel.
  180. */
  181. typedef struct {
  182. unsigned int tile[256 * 256];
  183. } __attribute__ ((packed)) tr2_textile32_t;
  184. /*!
  185. * \brief The "header" of a room.
  186. *
  187. * X/Z indicate the base position of the room mesh in world coordinates.
  188. *
  189. * yLowest and yHighest indicate the lowest and highest points in this room
  190. * (even though their actual values appear to be reversed, since a "high"
  191. * point will have a smaller value than a "low" point).
  192. *
  193. * When positioning objects/items, as well as the room meshes
  194. * themselves, y is always 0-relative (not room-relative).
  195. */
  196. typedef struct {
  197. int x; //!< X-offset of room (world coordinates)
  198. int z; //!< Z-offset of room (world coordinates)
  199. int y_bottom; //!< Y-offset of lowest point in room (world coordinates, actually highest value)
  200. int y_top; //!< Y-offset of highest point in room (world coordinates, actually lowest value)
  201. } __attribute__ ((packed)) tr2_room_info_t;
  202. /*!
  203. * \brief Portal structure.
  204. *
  205. * This defines every viable exit from a given "room".
  206. *
  207. * Note that "rooms" are really just areas. They aren't
  208. * necessarily enclosed. The door structure below defines
  209. * areas of egress, not the actual moveable mesh,
  210. * texture, and action (if any).
  211. */
  212. typedef struct {
  213. unsigned short adjoining_room; //!< Which room this "door" leads to
  214. tr2_vertex_t normal; //!< Which way the "door" faces
  215. tr2_vertex_t vertices[4]; //!< The corners of the "door"
  216. } __attribute__ ((packed)) tr2_room_portal_t;
  217. /*!
  218. * \brief Room sector structure.
  219. *
  220. * Sectors are 1024 * 1024 (world coordinates). Floor and
  221. * Ceiling are signed number of 256 units of height
  222. * (relative to 0), e.g. Floor 0x04 corresponds to
  223. * Y = 1024 in world coordinates.
  224. *
  225. * Note: this implies that, while X and Z can be quite large,
  226. * Y is constrained to -32768..32512. Floor/Ceiling value of
  227. * 0x81 indicates impenetrable wall.
  228. *
  229. * Floor values are used by the game engine to determine what
  230. * objects Lara can traverse and how.
  231. *
  232. * Relative steps of 1 (-256) can be walked up;
  233. * steps of 2..7 (-512..-1792) can/must be climbed;
  234. * steps larger than 7 (-2048..-32768) cannot be climbed (too tall)
  235. *
  236. * In TR3, BoxIndex is more complicated. Only bits 4-14 are the
  237. * "real" index; bits 0-3 are most likely some kind of flag,
  238. * such as what kind of footstep sound to make (wood, metal, snow).
  239. * Furthermore, there is a special value of the "real" index,
  240. * 2047, or 0x7ff.
  241. *
  242. * RoomAbove and RoomBelow indicate what neighboring rooms are
  243. * in these directions; if RoomAbove is not "none", then the
  244. * ceiling is a collisional portal to that room, while if
  245. * RoomBelow is not "none", then the floor is a collisional
  246. * portal to that room.
  247. */
  248. typedef struct {
  249. unsigned short fd_index; //!< Index into FloorData[]
  250. unsigned short box_index; //!< Index into Boxes[]/Zones[] (-1 if none)
  251. unsigned char room_below; //!< The number of the room below this one (-1 or 255 if none)
  252. char floor; //!< Absolute height of floor (Multiply by 256 for world coordinates)
  253. unsigned char room_above; //!< The number of the room above this one (-1 or 255 if none)
  254. char ceiling; //!< Absolute height of ceiling (multiply by 256 for world coordinates)
  255. } __attribute__ ((packed)) tr2_room_sector_t;
  256. /*!
  257. * \brief Room lighting structure.
  258. *
  259. * X/Y/Z are in world coordinates.
  260. *
  261. * Lighting values seem to range from 0..8192.
  262. */
  263. typedef struct {
  264. int x;
  265. int y;
  266. int z;
  267. unsigned short intensity1;
  268. unsigned short intensity2;
  269. unsigned int fade1;
  270. unsigned int fade2;
  271. } __attribute__ ((packed)) tr2_room_light_t;
  272. typedef struct {
  273. int xPosition; //!< World coords
  274. int yPosition; //!< World coords
  275. int zPosition; //!< World coords
  276. tr2_colour_t color; //!< Three bytes rgb values
  277. unsigned char lightType; //!< Same as D3D (i.e. 2 is for spotlight)
  278. unsigned char unknown; //!< Always 0xff?
  279. unsigned char intensity;
  280. float in;
  281. float out;
  282. float length;
  283. float cutoff;
  284. float xDir, yDir, zDir; //!< Direction?
  285. } __attribute__ ((packed)) tr4_room_light_t;
  286. /*!
  287. * \brief Room vertex structure.
  288. *
  289. * This defines the vertices within a room.
  290. */
  291. typedef struct {
  292. tr2_vertex_t vertex;
  293. short lighting1; //!< Values range from 0 to 32767 in TR3, 0=dark.
  294. /*!< I think the values ranged from 0 to 8192
  295. * in TR1/2, 0=bright. */
  296. unsigned short attributes; /*!<
  297. * * 0x8000 Something to do with water surface
  298. * * 0x4000 Under water lighting modulation
  299. * and movement if viewed from
  300. * above water surface
  301. * * 0x2000 Water/quicksand surface movement
  302. * * 0x1fef Nothing?
  303. * * 0x0010 Everything?
  304. */
  305. short lighting2; //!< Seems to be the same as lighting1
  306. } __attribute__ ((packed)) tr2_vertex_room_t;
  307. /*!
  308. * \brief Sprite structure
  309. */
  310. typedef struct {
  311. short vertex; //!< Offset into vertex list
  312. short texture; //!< Offset into texture list
  313. } __attribute__ ((packed)) tr2_room_sprite_t;
  314. /*!
  315. * \brief Room mesh structure.
  316. *
  317. * This is the geometry of the "room," including
  318. * walls, floors, rocks, water, etc. It does _not_ include
  319. * objects that Lara can interact with (keyboxes,
  320. * moveable blocks, moveable doors, etc.)
  321. */
  322. typedef struct tr2_room_data_s {
  323. short num_vertices; //!< Number of vertices in the following list
  324. tr2_vertex_room_t *vertices; //!< List of vertices (relative coordinates)
  325. short num_rectangles; //!< Number of textured rectangles
  326. tr2_quad_t *rectangles; //!< List of textured rectangles
  327. short num_triangles; //!< Number of textured triangles
  328. tr2_tri_t *triangles; //!< List of textured triangles
  329. short num_sprites; //!< Number of sprites
  330. tr2_room_sprite_t *sprites; //!< List of sprites
  331. } __attribute__ ((packed)) tr2_room_data_t;
  332. /*!
  333. * \brief Room static mesh data.
  334. *
  335. * Positions and IDs of static meshes
  336. * (e.g. skeletons, spiderwebs, furniture)
  337. */
  338. typedef struct {
  339. int x; //!< Absolute position in world coordinates
  340. int y;
  341. int z;
  342. unsigned short rotation; //!< High two bits (0xc000) indicate steps of 90 degrees
  343. unsigned short intensity1;
  344. unsigned short intensity2;
  345. unsigned short object_id; //!< Which StaticMesh item to draw
  346. } __attribute__ ((packed)) tr2_room_staticmesh_t;
  347. /*!
  348. * \brief Room structure.
  349. *
  350. * Here's where all the room data comes together.
  351. */
  352. typedef struct {
  353. tr2_room_info_t info; //!< where the room exists, in world coordinates
  354. unsigned int num_data_words; //!< number of data words (bitu16)
  355. unsigned char *data; //!< the raw data from which the rest of this is derived
  356. tr2_room_data_t room_data; //!< the room mesh
  357. unsigned short num_portals; //!< number of visibility portals that leave this room
  358. tr2_room_portal_t *portals; //!< list of visibility portals
  359. unsigned short num_zsectors; //!< width of sector list
  360. unsigned short num_xsectors; //!< height of sector list
  361. tr2_room_sector_t *sector_list; //!< list of sectors in this room
  362. short intensity1;
  363. short intensity2;
  364. short light_mode;
  365. unsigned short num_lights; //!< number of lights in this room
  366. tr2_room_light_t *lights; //!< list of lights
  367. unsigned short num_static_meshes; //!< number of static meshes
  368. tr2_room_staticmesh_t *static_meshes; //!< static meshes
  369. short alternate_room;
  370. short flags; /*!< * 0x0001 - room is filled with water
  371. * * 0x0020 - Lara's ponytail gets blown by the wind */
  372. tr2_colour_t room_light_colour; //!< TR3 ONLY!
  373. tr4_room_light_t *tr4Lights; //!< TR4 ONLY!
  374. } __attribute__ ((packed)) tr2_room_t;
  375. /*!
  376. * \brief Animation structure up to TR3.
  377. */
  378. typedef struct {
  379. unsigned int frame_offset; //!< byte offset into Frames[] (divide by 2 for Frames[i])
  380. unsigned char frame_rate; //!< "ticks" per frame
  381. unsigned char frame_size; //!< number of words in Frames[] used by this animation
  382. short state_id;
  383. short unknown1;
  384. short unknown2;
  385. short unknown3;
  386. short unknown4;
  387. unsigned short frame_start; //!< first frame in this animation
  388. unsigned short frame_end; //!< last frame in this animation (numframes = (End - Start) + 1)
  389. unsigned short next_animation;
  390. unsigned short next_frame;
  391. unsigned short num_state_changes;
  392. unsigned short state_change_offset; //!< offset into StateChanges[]
  393. unsigned short num_anim_commands;
  394. unsigned short anim_command; //!< offset into AnimCommands[]
  395. } __attribute__ ((packed)) tr2_animation_t;
  396. /*!
  397. * \brief Data for an animation structure (40 bytes in TR4 vice 32 in TR1/2/3)
  398. */
  399. typedef struct {
  400. unsigned int frame_offset; //!< same meaning as in TR3
  401. unsigned char frame_rate; //!< same meaning as in TR3
  402. unsigned char frame_size; //!< same meaning as in TR3
  403. unsigned short state_id; //!< same meaning as in TR3
  404. short unknown; //!< same meaning as in TR3
  405. short speed; //!< same meaning as in TR3
  406. unsigned short accel_lo; //!< same meaning as in TR3
  407. short accel_hi; //!< same meaning as in TR3
  408. unsigned char unknown2[8]; //!< new in TR4
  409. unsigned short frame_start; //!< same meaning as in TR3
  410. unsigned short frame_end; //!< same meaning as in TR3
  411. unsigned short next_animation; //!< same meaning as in TR3
  412. unsigned short next_frame; //!< same meaning as in TR3
  413. unsigned short num_state_changes; //!< same meaning as in TR3
  414. unsigned short state_change_offset; //!< same meaning as in TR3
  415. unsigned short num_anim_commands; //!< same meaning as in TR3
  416. unsigned short anim_command; //!< same meaning as in TR3
  417. } __attribute__ ((packed)) tr4_animation_t;
  418. /*!
  419. * \brief State Change structure
  420. */
  421. typedef struct {
  422. unsigned short state_id;
  423. unsigned short num_anim_dispatches; //!< Number of dispatches (seems to always be 1..5)
  424. unsigned short anim_dispatch; //!< Offset into AnimDispatches[]
  425. } __attribute__ ((packed)) tr2_state_change_t;
  426. /*!
  427. * \brief Animation Dispatch structure
  428. */
  429. typedef struct {
  430. short low;
  431. short high;
  432. short next_animation;
  433. short next_frame;
  434. } __attribute__ ((packed)) tr2_anim_dispatch_t;
  435. /*!
  436. * \brief AnimCommand structure
  437. */
  438. typedef struct {
  439. short value;
  440. } __attribute__ ((packed)) tr2_anim_command_t;
  441. /*!
  442. * \brief MeshTree structure.
  443. *
  444. * MeshTree[] is actually groups of four ints. The first one is a
  445. * "flags" word; bit 1 (0x0002) indicates "make previous mesh an
  446. * anchor (e.g. PUSH)"; bit 0 (0x0001) indicates "return to previous
  447. * anchor (e.g. POP)".
  448. * The next three ints are X, Y, Z offsets from the last mesh position.
  449. */
  450. typedef struct {
  451. int flags; //!< 0x0001 = POP, 0x0002 = PUSH
  452. int x;
  453. int y;
  454. int z;
  455. } __attribute__ ((packed)) tr2_meshtree_t;
  456. /*!
  457. * \brief Moveable structure.
  458. *
  459. * This defines a list of contiguous meshes that
  460. * comprise one object, e.g. in WALL.TR2,
  461. *
  462. * moveable[0] = Lara (StartingMesh 0, NumMeshes 15),
  463. * moveable[13] = Tiger (StartingMesh 215, NumMeshes 27)
  464. * moveable[15] = Spikes (StartingMesh 249, NumMeshes 1)
  465. * moveable[16] = Boulder (StartingMesh 250, NumMeshes 1)
  466. * moveable[20] = Rolling Blade (StartingMesh 254, NumMeshes 1)
  467. */
  468. typedef struct {
  469. unsigned int object_id; //!< Item Identifier
  470. unsigned short num_meshes; //!< number of meshes in this object
  471. unsigned short starting_mesh; //!< first mesh
  472. unsigned int mesh_tree; //!< offset into MeshTree[]
  473. unsigned int frame_offset; //!< byte offset into Frames[] (divide by 2 for Frames[i])
  474. unsigned short animation; //!< offset into Animations[]
  475. } __attribute__ ((packed)) tr2_moveable_t;
  476. /*!
  477. * \brief StaticMesh structure.
  478. *
  479. * This defines meshes that don't move (e.g. skeletons
  480. * lying on the floor, spiderwebs, etc.)
  481. */
  482. typedef struct {
  483. unsigned int object_id; //!< Item Identifier
  484. unsigned short starting_mesh; //!< first mesh
  485. tr2_vertex_t bounding_box[2][2];
  486. unsigned short flags;
  487. } __attribute__ ((packed)) tr2_staticmesh_t;
  488. /*!
  489. * \brief Object texture vertex structure.
  490. *
  491. * Maps coordinates into texture tiles.
  492. */
  493. typedef struct {
  494. unsigned char xcoordinate;
  495. unsigned char xpixel;
  496. unsigned char ycoordinate;
  497. unsigned char ypixel;
  498. } __attribute__ ((packed)) tr2_object_texture_vert_t;
  499. /*!
  500. * \brief Object texture structure.
  501. */
  502. typedef struct {
  503. unsigned short transparency_flags; /*!< * 0: Opaque
  504. * * 1: Use transparency
  505. * * 2: Use partial transparency
  506. * [grayscale intensity :: transparency]
  507. */
  508. unsigned short tile; //!< index into textile list
  509. tr2_object_texture_vert_t vertices[4]; //!< the four corners of the texture
  510. } __attribute__ ((packed)) tr2_object_texture_t;
  511. /*!
  512. * \brief Sprite texture structure.
  513. */
  514. typedef struct {
  515. unsigned short tile;
  516. unsigned char x;
  517. unsigned char y;
  518. unsigned short width; //!< Actually, (width * 256) + 255
  519. unsigned short height; //!< Actually, (height * 256) + 255
  520. short left_side;
  521. short top_side;
  522. short right_side;
  523. short bottom_side;
  524. } __attribute__ ((packed)) tr2_sprite_texture_t;
  525. /*!
  526. * \brief Sprite Sequence structure
  527. */
  528. typedef struct {
  529. int object_id; //!< Item identifier (same numbering as in tr2_moveable)
  530. short negative_length; //!< Negative of "how many sprites are in this sequence"
  531. short offset; //!< Where (in sprite texture list) this sequence starts
  532. } __attribute__ ((packed)) tr2_sprite_sequence_t;
  533. /*!
  534. * \brief Mesh structure.
  535. *
  536. * The mesh list contains the mesh info for Lara (in all her
  537. * various incarnations), blocks, enemies (tigers, birds, bad guys),
  538. * moveable blocks, zip line handles, boulders, spinning blades,
  539. * you name it.
  540. *
  541. * If NumNormals is negative, Normals[] represent vertex
  542. * lighting values (one per vertex).
  543. */
  544. typedef struct {
  545. tr2_vertex_t centre; /*!< \brief This seems to describe the
  546. * approximate geometric centre
  547. * of the mesh (possibly the centre of gravity?)
  548. * (relative coordinates, just like the vertices) */
  549. int collision_size; //!< radius of collisional sphere
  550. short num_vertices; //!< number of vertices in this mesh
  551. tr2_vertex_t *vertices; //!< list of vertices (relative coordinates)
  552. short num_normals; //!< number of normals in this mesh (should always equal NumVertices)
  553. tr2_vertex_t *normals; //!< list of normals (NULL if NumNormals < 0)
  554. short *mesh_lights; //!< if NumNormals < 0
  555. short num_textured_rectangles; //!< number of textured rectangles
  556. tr2_quad_t *textured_rectangles; //!< list of textured rectangles
  557. short num_textured_triangles; //!< number of textured triangles in this mesh
  558. tr2_tri_t *textured_triangles; //!< list of textured triangles
  559. short num_coloured_rectangles; //!< number of coloured rectangles
  560. tr2_quad_t *coloured_rectangles; //!< list of coloured rectangles
  561. short num_coloured_triangles; //!< number of coloured triangles in this mesh
  562. tr2_tri_t *coloured_triangles; //!< list of coloured triangles
  563. } __attribute__ ((packed)) tr2_mesh_t;
  564. /*!
  565. * \brief Frame structure.
  566. *
  567. * Frames indicates how composite meshes are positioned and rotated.
  568. * They work in conjunction with Animations[] and Bone2[].
  569. *
  570. * A given frame has the following format:
  571. *
  572. * short BB1x, BB1y, BB1z // bounding box (low)
  573. * short BB2x, BB2y, BB2z // bounding box (high)
  574. * short OffsetX, OffsetY, OffsetZ // starting offset for this moveable
  575. * (TR1 ONLY: short NumValues // number of angle sets to follow)
  576. * (TR2/3: NumValues is implicitly NumMeshes (from moveable))
  577. *
  578. * What follows next is a list of angle sets. In TR2/3, an angle set can
  579. * specify either one or three axes of rotation. If either of the high two
  580. * bits (0xc000) of the first angle unsigned short are set, it's one axis:
  581. *
  582. * only one unsigned short,
  583. * low 10 bits (0x03ff),
  584. * scale is 0x100 == 90 degrees;
  585. *
  586. * the high two bits are interpreted as follows:
  587. *
  588. * 0x4000 == X only, 0x8000 == Y only,
  589. * 0xC000 == Z only.
  590. *
  591. * If neither of the high bits are set, it's a three-axis rotation. The next
  592. * 10 bits (0x3ff0) are the X rotation, the next 10 (including the following
  593. * unsigned short) (0x000f, 0xfc00) are the Y rotation,
  594. * the next 10 (0x03ff) are the Z rotation, same scale as
  595. * before (0x100 == 90 degrees).
  596. *
  597. * Rotations are performed in Y, X, Z order.
  598. * TR1 ONLY: All angle sets are two words and interpreted like the two-word
  599. * sets in TR2/3, EXCEPT that the word order is reversed.
  600. */
  601. typedef struct {
  602. tr2_vertex_t vector[3];
  603. int num_words;
  604. unsigned short *words;
  605. } __attribute__ ((packed)) tr2_frame_t;
  606. /*!
  607. * \brief Item structure
  608. */
  609. typedef struct {
  610. short object_id;
  611. short room;
  612. int x;
  613. int y;
  614. int z;
  615. short angle;
  616. short intensity1;
  617. short intensity2;
  618. short flags; //!< 0x0100 indicates "inactive" or "invisible"
  619. } __attribute__ ((packed)) tr2_item_t;
  620. /*!
  621. * \brief SoundSource structure
  622. */
  623. typedef struct {
  624. int x; //!< position of sound source
  625. int y;
  626. int z;
  627. unsigned short sound_id; //!< internal sound index
  628. unsigned short flags; //!< 0x40, 0x80, or 0xc0
  629. } __attribute__ ((packed)) tr2_sound_source_t;
  630. /*!
  631. * \brief Boxes structure
  632. */
  633. typedef struct {
  634. unsigned char zmin; //!< sectors (* 1024 units)
  635. unsigned char zmax;
  636. unsigned char xmin;
  637. unsigned char xmax;
  638. short true_floor; //!< Y value (no scaling)
  639. short overlap_index; //!< index into Overlaps[]
  640. } __attribute__ ((packed)) tr2_box_t;
  641. /*!
  642. * \brief AnimatedTexture structure.
  643. *
  644. * - really should be simple short[], since it's variable length
  645. */
  646. typedef struct {
  647. short num_texture_ids; //!< Number of Texture IDs - 1
  648. short *texture_list; //!< list of textures to cycle through
  649. } __attribute__ ((packed)) tr2_animated_texture_t;
  650. /*!
  651. * \brief Camera structure
  652. */
  653. typedef struct {
  654. int x;
  655. int y;
  656. int z;
  657. short room;
  658. unsigned short unknown1; //!< correlates to Boxes[]?
  659. } __attribute__ ((packed)) tr2_camera_t;
  660. /*
  661. * \brief Data for a flyby camera (40 bytes)
  662. */
  663. typedef struct {
  664. int pos[6]; //!< Positions ? (x1,y1,z1,x2,y2,z2) roatations?
  665. unsigned char index[2]; //!< A pair of indices
  666. unsigned short unknown[5]; //!< ??
  667. int id; //!< Index of something
  668. } __attribute__ ((packed)) tr4_extra_camera_t;
  669. /*!
  670. * \brief Sound sample structure
  671. */
  672. typedef struct {
  673. short sample;
  674. short volume;
  675. short sound_range;
  676. short flags; /*!< \ brief bits 8-15: priority?, 2-7: number of sound samples
  677. * in this group, bits 0-1: channel number */
  678. } __attribute__ ((packed)) tr2_sound_details_t;
  679. /*!
  680. * \brief Cutscene Camera structure
  681. */
  682. typedef struct {
  683. short roty; //!< Rotation about Y axis, +/-32767 ::= +/- 180 degrees
  684. short rotz; //!< Rotation about Z axis, +/-32767 ::= +/- 180 degrees
  685. short rotz2; //!< Rotation about Z axis (why two?), +/-32767 ::= +/- 180 degrees
  686. short posz; //!< Z position of camera, relative to something
  687. short posy; //!< Y position of camera, relative to something
  688. short posx; //!< X position of camera, relative to something
  689. short unknown1;
  690. short rotx; //!< Rotation about X axis, +/-32767 ::= +/- 180 degrees
  691. } __attribute__ ((packed)) tr2_cinematic_frame_t;
  692. /*!
  693. * \brief Data for a AI object (24 bytes).
  694. *
  695. * this field replaces the bitu16 NumCinematicFrames of TR1/2/3 levels
  696. *
  697. * Used to read TR4 AI data
  698. */
  699. typedef struct {
  700. unsigned short int object_id; //!< the objectID from the AI object
  701. //!< (AI_FOLLOW is 402)
  702. unsigned short int room;
  703. int x, y, a;
  704. unsigned short int ocb;
  705. unsigned short int flags; //!< The trigger flags
  706. //!< (button 1-5, first button has value 2)
  707. int angle; //!< rotation
  708. } __attribute__ ((packed)) tr4_ai_object_t;
  709. /*!
  710. * \brief Used to read packed TR4 texels
  711. */
  712. typedef struct {
  713. unsigned short attribute; //!< same meaning as in TR3
  714. unsigned short tile; //!< same meaning as in TR3
  715. unsigned short flags; //!< new in TR4
  716. tr2_object_texture_vert_t vertices[4]; //!< same meaning as in TR3
  717. unsigned int unknown1, unknown2; //!< new in TR4: x & y offset in something
  718. unsigned int xsize, ysize; //!< new in TR4: width-1 & height-1 of the object texture
  719. } __attribute__ ((packed)) tr4_object_texture_t;
  720. /*!
  721. * \brief TR5 Room Layer (56 bytes)
  722. */
  723. typedef struct {
  724. uint32_t numLayerVertices; //!< number of vertices in this layer (4 bytes)
  725. uint16_t unknownL1; //!< unknown (2 bytes)
  726. uint16_t numLayerRectangles; //!< number of rectangles in this layer (2 bytes)
  727. uint16_t numLayerTriangles; //!< number of triangles in this layer (2 bytes)
  728. uint16_t unknownL2; //!< appears to be the number of 2 sided textures
  729. //!< in this layer, however is sometimes 1 off (2 bytes)
  730. uint16_t filler; //!< always 0 (2 bytes)
  731. uint16_t filler2; //!< always 0 (2 bytes)
  732. float layerBoundingBoxX1; //!< These 6 floats (4 bytes each) define the bounding box for the layer
  733. float layerBoundingBoxY1;
  734. float layerBoundingBoxZ1;
  735. float layerBoundingBoxX2;
  736. float layerBoundingBoxY2;
  737. float layerBoundingBoxZ2;
  738. uint32_t filler3; //!< always 0 (4 bytes)
  739. uint32_t unknownL6; //!< unknown (4 bytes)
  740. uint32_t unknownL7; //!< unknown (4 bytes)
  741. uint32_t unknownL8; //!< unknown. Always the same throughout the level. (4 bytes)
  742. } tr5_room_layer_t;
  743. /*!
  744. * \brief TR5 Quad (12 bytes)
  745. */
  746. typedef struct {
  747. uint16_t vertices[4]; //!< the values are the indices into the
  748. //!< appropriate layer vertice list. (2 bytes each)
  749. uint16_t texture; //!< the texture number for this face. Needs to be masked
  750. //!< with 0xFFF as the high 4 bits are flags (2 bytes)
  751. uint16_t unknownF4; //!< unknown (2 bytes)
  752. } tr5_face4_t;
  753. /*!
  754. * \brief TR5 triangular face (10 bytes)
  755. */
  756. typedef struct {
  757. uint16_t vertices[3]; //!< the values are the indices into the
  758. //!< appropriate layer vertice list (2 bytes each)
  759. uint16_t texture; //!< the texture number for this face. Needs to be masked
  760. //!< with 0xFFF as the high 4 bits are flags (2 bytes)
  761. uint16_t unknownF3; //!< unknown (2 bytes)
  762. } tr5_face3_t;
  763. /*!
  764. * \brief TR5 Vertex (28 bytes)
  765. */
  766. typedef struct {
  767. float x; //!< x of vertex (4 bytes)
  768. float y; //!< y of vertex (4 bytes)
  769. float z; //!< z of vertex (4 bytes)
  770. float nx; //!< x of vertex normal (4 bytes)
  771. float ny; //!< y of vertex normal (4 bytes)
  772. float nz; //!< z of vertex normal (4 bytes)
  773. uint32_t vColor; //!< vertex color ARGB format (4 bytes)
  774. } tr5_vertex_t;
  775. /*!
  776. * \brief This is to help store and manage TR5 layer based polgons for rooms
  777. */
  778. typedef struct {
  779. tr5_face4_t *quads;
  780. tr5_face3_t *tris;
  781. tr5_vertex_t *verts;
  782. } tr5_room_geometry_t;
  783. /*!
  784. * \brief TR5 light (88 bytes)
  785. */
  786. typedef struct {
  787. float x; //!< x position of light (4 bytes)
  788. float y; //!< y position of light (4 bytes)
  789. float z; //!< z position of light (4 bytes)
  790. /*!< Maybe wrong: The (x, y, z) floats specify the position of the light
  791. * in world coordinates.
  792. *
  793. * The sun type light should not use these but seems to have a
  794. * large x value (9 million, give or take)
  795. * a zero y value, and a small z value (4 - 20) in the original TR5 levels
  796. */
  797. float red; //!< color of red spectrum (4 bytes)
  798. float green; //!< color of green spectrum (4 bytes)
  799. float blue; //!< color of blue spectrum (4 bytes)
  800. uint32_t seperator; //!< not used 0xCDCDCDCD (4 bytes)
  801. float input; //!< cosine of the IN value for light / size of IN value (4 bytes)
  802. float output; //!< cosine of the OUT value for light / size of OUT value (4 bytes)
  803. /*!< At this point the info diverges dependant
  804. * on which type of light being used:
  805. *
  806. * 0 = sun, 1 = light, 2 = spot, 3 = shadow
  807. *
  808. * The sun type doesn't use input and output.
  809. *
  810. * For the spot type these are the hotspot and falloff angle cosines.
  811. *
  812. * For the light and shadow types these are the TR units
  813. * for the hotspot/falloff (1024=1sector).
  814. */
  815. float radInput; //!< (IN radians) * 2 (4 bytes)
  816. float radOutput; //!< (OUT radians) * 2 (4 bytes)
  817. //!< radInput and radOutput are only used by the spot type light
  818. float range; //!< Range of light (4 bytes), only used by the spot type light
  819. float directionVectorX; //!< light direction (4 bytes)
  820. float directionVectorY; //!< light direction (4 bytes)
  821. float directionVectorZ; //!< light direction (4 bytes)
  822. /*!< The 3 directionVector floats are used only by the 'sun' and 'spot' type lights.
  823. * They describe the directional vector of the light.
  824. * This can be obtained by:
  825. *
  826. * if both x and y LightDirectionVectorX = cosX * sinY
  827. *
  828. * LightDirectionVectorY = sinX
  829. * LightDirectionVectorZ = cosX * cosY
  830. */
  831. int32_t x2; //!< x position of light (4 bytes)
  832. int32_t y2; //!< y position of light (4 bytes)
  833. int32_t z2; //!< z position of light (4 bytes)
  834. /*!<
  835. * x2, y2, z2 and the directionVectors-2 repeat some of the
  836. * previous information in long data types vice floats
  837. */
  838. int32_t directionVectorX2; //!< light direction (4 bytes)
  839. int32_t directionVectorY2; //!< light direction (4 bytes)
  840. int32_t directionVectorZ2; //!< light direction (4 bytes)
  841. //!< 16384 = 1.0 for the rotations (1/16384)
  842. uint8_t lightType; //!< type of light as specified above (1 byte)
  843. uint8_t seperator2[3]; //!< 0xCDCDCD (3 bytes)
  844. } tr5_light_t;
  845. /*!
  846. * \brief TR5 Room.
  847. *
  848. * First number is offset in bytes from start of room structure.
  849. */
  850. typedef struct {
  851. uint32_t checkXELA; //!< "XELA" (4 bytes)
  852. uint32_t roomDataSize; /*!< size of the following data ( use this vice
  853. * 'walking thru' to get next room) (4 bytes) */
  854. uint32_t seperator; //!< 0xCDCDCDCD (4 bytes)
  855. uint32_t endSDOffset; /*!< usually this number + 216 will give you the
  856. * offset from the start of the room data to the end
  857. * of the Sector Data. HOWEVER have seen where this
  858. * bitu32 is equal to -1 so it is better to use the
  859. * following bitu32 and + 216 +
  860. * ((NumXSectors * NumZSectors)*8) if you need
  861. * to obtain this information. (4 bytes) */
  862. uint32_t startSDOffset; /*!< this number + 216 will give you the offset from
  863. * the start of the room to the start of the
  864. * sector data. (4 bytes) */
  865. uint32_t seperator2; //!< will either be 0x00000000 or 0xCDCDCDCD (4 bytes)
  866. uint32_t endPortalOffset; /*!< this number + 216 will give you the offset
  867. * from the start of the room to the end of the
  868. * portal data. (4 bytes) */
  869. int32_t x; //!< X position of room ( world coordinates) (4 bytes)
  870. int32_t seperator3; //!< 0x00000000 (4 bytes)
  871. int32_t z; //!< Z position of room (world coordinates) (4 bytes)
  872. int32_t yBottom; //!< lowest point in room (4 bytes)
  873. int32_t yTop; //!< highest point in room (4 bytes)
  874. uint16_t numZSectors; //!< sector table width (2 bytes)
  875. uint16_t numXSectors; //!< sector table height (2 bytes)
  876. uint32_t roomAmbientColor; //!< ARGB format (blue is least significant byte) (4 bytes)
  877. uint16_t numRoomLights; //!< number of lights in this room (2 bytes)
  878. uint16_t numStaticMeshes; //!< number of static meshes in this room (2 bytes)
  879. uint16_t unknownR1; //!< usually 0x0001 however high byte is sometimes non zero (2 bytes)
  880. uint16_t unknownR2; //!< usually 0x0000 however low byte is sometimes non zero (2 bytes)
  881. uint32_t filler; //!< always 0x00007FFF (4 bytes)
  882. uint32_t filler2; //!< always 0x00007FFF (4 bytes)
  883. uint32_t seperator4; //!< 0xCDCDCDCD (4 bytes)
  884. uint32_t seperator5; //!< 0xCDCDCDCD (4 bytes)
  885. unsigned char seperator6[6]; //!< 6 bytes 0xFF
  886. uint16_t roomFlag; //!< 0x01 = water, 0x20 = wind, others unknown (2 bytes)
  887. uint16_t unknownR5; //!< unknown (2 bytes)
  888. unsigned char seperator7[10]; //!< 10 bytes 0x00
  889. uint32_t seperator8; //!< 0xCDCDCDCD (4 bytes)
  890. uint32_t unknownR6; //!< unknown (4 bytes)
  891. float roomX; //!< X position of room in world coordinates
  892. //!< If null room then this data will be 0xCDCDCDCD (4 bytes)
  893. uint32_t seperator9; //!< 0x00000000 or 0xCDCDCDCD if null room. (4 bytes)
  894. float roomZ; //!< Z position of room in world coordinates
  895. //!< If null room then will be bitu32 0xCDCDCDCD (4 bytes)
  896. uint32_t seperator10; //!< 0xCDCDCDCD (4 bytes)
  897. uint32_t seperator11; //!< 0xCDCDCDCD (4 bytes)
  898. uint32_t seperator12; //!< 0xCDCDCDCD (4 bytes)
  899. uint32_t seperator13; //!< 0xCDCDCDCD (4 bytes)
  900. uint32_t seperator14; //!< 0x00000000 unless null room then 0xCDCDCDCD (4 bytes)
  901. uint32_t seperator15; //!< 0xCDCDCDCD (4 bytes)
  902. uint32_t numRoomTriangles; //!< total number of triangles this room (4 bytes)
  903. uint32_t numRoomRectangles; //!< total number of rectangles this room (4 bytes)
  904. uint32_t seperator16; //!< 0x00000000 (4 bytes)
  905. uint32_t lightSize; //!< size of light data (number of lights * 88) (4 bytes)
  906. uint32_t numTotalRoomLights; //!< total number of lights this room (4 bytes)
  907. uint32_t unknownR7; //!< unknown, usually equals 0, 1, 2, or 3 (4 bytes)
  908. int32_t unknownR8; //!< usually equals room yTop. Sometimes a few blocks off.
  909. //!< If null room then 0xCDCDCDCD
  910. int32_t lyBottom; //!< equals room yBottom. If null room then 0xCDCDCDCD (4 bytes)
  911. uint32_t numLayers; //!< number of layers (pieces) this room (4 bytes)
  912. uint32_t layerOffset; //!< this number + 216 will give you an offset from the start
  913. //!< of the room data to the start of the layer data (4 bytes)
  914. uint32_t verticesOffset; //!< this number + 216 will give you an offset from the start
  915. //!< of the room data to the start of the verex data (4 bytes)
  916. uint32_t polyOffset; //!< this number + 216 will give you an offset from the start
  917. //!< of the room data to the start of the rectangle/triangle data (4 bytes)
  918. uint32_t polyOffset2; //!< same as above ? (4 bytes)
  919. uint32_t verticesSize; //!< size of vertices data block (4 bytes)
  920. uint32_t seperator17; //!< 0xCDCDCDCD (4 bytes)
  921. uint32_t seperator18; //!< 0xCDCDCDCD (4 bytes)
  922. uint32_t seperator19; //!< 0xCDCDCDCD (4 bytes)
  923. uint32_t seperator20; //!< 0xCDCDCDCD (4 bytes)
  924. tr5_light_t *lights; //!< [LightSize];
  925. //!< data for the lights (88 bytes * NumRoomLights)
  926. tr2_room_sector_t *sectors; //!< Data[(NumXSectors * NumZSectors) * 8];
  927. //!< normal sector data structure
  928. uint16_t numDoors; //!< number of portals (2 bytes)
  929. tr2_room_portal_t *doors; //!< [NumDoors];
  930. //!< normal portal structure (32 bytes * NumDoors)
  931. uint16_t seperator21; //!< 0xCDCD (2 bytes)
  932. tr2_room_staticmesh_t *meshes; //!< [NumStaticMeshes];
  933. //!< normal room static mesh structure (20 bytes * NumRoomStaticMeshes)
  934. tr5_room_layer_t *layers; //!< [NumLayers];
  935. //!< data for the room layers (pieces) (56 bytes * NumLayers)
  936. tr5_room_geometry_t *faces; //!< [NumRoomRectangles + NumRoomTriangles];
  937. /* Data for the room polys (face4 and face3).
  938. * Structured as first layers rectangles
  939. * then triangles, followed by the
  940. * next layers rectangles and triangles, etc.,
  941. * until all layers are done.
  942. * (12 bytes each rectangle. 10 bytes each triangle)
  943. */
  944. tr5_vertex_t *vertices; //!< [VerticesSize];
  945. /*!< Data for the room vertices.
  946. * Structured as vertices for the first layer,
  947. * then vertices for the second layer, etc.,
  948. * until all layers are done.
  949. * (28 bytes each vertex.
  950. */
  951. } tr5_room_t;
  952. /*!
  953. * \brief TR5 Object Texture Vertex (4 bytes)
  954. */
  955. typedef struct {
  956. uint8_t xCoordinate; //!< 0 if Xpixel is the low value,
  957. //!< 255 if Xpixel is the high value in the object texture (1 byte)
  958. uint8_t xPixel; //!< (1 byte)
  959. uint8_t yCoordinate; //!< 0 if Ypixel is the low value,
  960. //!< 255 if Ypixel is the high value in the object texture (1 byte)
  961. uint8_t yPixel; //!< (1 byte)
  962. } tr5_object_texture_vertex_t;
  963. /*!
  964. * \brief TR5 Object Texture (40 bytes)
  965. */
  966. typedef struct {
  967. uint16_t attribute; //!< 0, 1, or 2 (2 means 2 sided) (2 bytes)
  968. uint32_t tile; //!< need to mask with 0xFF as other bits are flags.
  969. //!< ie int15_t seems to indicate triangle (4 bytes)
  970. tr5_object_texture_vertex_t vertices[4]; //!< Vertices[4] (16 bytes)
  971. uint32_t uv1; //!< unknown how used (4 bytes)
  972. uint32_t uv2; //!< unknown how used (4 bytes)
  973. uint32_t xSize; //!< unknown how used, x size (4 bytes)
  974. uint32_t ySize; //!< unknown how used, y size (4 bytes)
  975. uint16_t seperator; //!< always 0x0000 (2 bytes)
  976. } tr5_object_texture_t;
  977. /*!
  978. * \brief TR5 Flyby camera (40 bytes)
  979. */
  980. typedef struct {
  981. int32_t cameraX; //!< x position of camera in world coordinates (4 bytes)
  982. int32_t cameraY; //!< y position of camera in world coordinates (4 bytes)
  983. int32_t cameraZ; //!< z position of camera in world coordinates (4 bytes)
  984. int32_t targetX; //!< x position of aiming point in world coords (4 bytes)
  985. int32_t targetY; //!< y position of aiming point in world coords (4 bytes)
  986. int32_t targetZ; //!< z position of aiming point in world coords (4 bytes)
  987. int8_t sequence; //!< sequence # of camera (1 byte)
  988. int8_t cameraNumber; //!< camera # (1 byte)
  989. uint16_t fov; //!< fov of camera ( .0054945 for each degree ) (2 bytes)
  990. uint16_t roll; //!< roll of camera ( .0054945 for each degree ) (2 bytes)
  991. uint16_t timer; //!< timer number (2 bytes)
  992. uint16_t speed; //!< ( .000015259 each ) (2 bytes)
  993. uint16_t flags; //!< ( see your handy TRLE manual for the specs ) (2 bytes)
  994. uint32_t room; //!< room number (4 bytes)
  995. } tr5_flyby_camera_t;
  996. /*!
  997. * \brief TR5 Moveable (20 bytes).
  998. *
  999. * Same as old structure but has uint16_t filler at the end
  1000. */
  1001. typedef struct {
  1002. uint32_t objectId; //!< object identifier ( matched in Items[] )
  1003. uint16_t numMeshes; //!< number of meshes in this object
  1004. uint16_t startingMesh; //!< starting mesh ( offset into MeshPointers[] )
  1005. uint32_t meshTree; //!< offset into MeshTree[] )
  1006. uint32_t frameOffset; //!< byte offset into Frames[] ( divide by 2 for Frames[i] )
  1007. uint16_t animation; //!< offset into Animations[]
  1008. uint16_t filler; //!< always equal to 65519 ( 0xFFEF )
  1009. } tr5_moveable_t;
  1010. typedef struct {
  1011. tr2_vertex_t center; //!< relative coordinates of mesh centre (6 bytes)
  1012. uint8_t unknown1[4]; //!< unknown (4 bytes)
  1013. int16_t numVertices; //!< number of vertices to follow (2 bytes)
  1014. tr2_vertex_t *vertices; //!< list of vertices (NumVertices * 6 bytes)
  1015. int16_t numNormals; //!< number of normals to follow (2 bytes)
  1016. tr2_vertex_t *normals; //!< list of normals (NumNormals * 6 bytes)
  1017. //!< (becomes Lights if NumNormals < 0; 2 bytes)
  1018. int16_t numTexturedRectangles; //!< number of textured rectangles to follow (2 bytes)
  1019. tr5_face4_t *texturedRectangles; //!< list of textured rectangles (NumTexturedRectangles * 12 bytes)
  1020. int16_t numTexturedTriangles; //!< number of textured triangles to follow (2 bytes)
  1021. tr5_face3_t *texturedTriangles; //!< list of textured triangles (NumTexturedTriangles * 10 bytes)
  1022. } tr5_mesh_t;
  1023. /*!
  1024. * \brief TR5 Animation (40 bytes).
  1025. *
  1026. * Same as old structure but has 8 bytes before FrameStart.
  1027. */
  1028. typedef struct {
  1029. uint32_t FrameOffset; //!< byte offset into Frames[] ( divide by 2 for Frames[i] )
  1030. uint8_t FrameRate; //!< Engine ticks per frame
  1031. uint8_t FrameSize; //!< number of int16_t's in Frames[] used by this animation
  1032. uint16_t StateId;
  1033. int16_t Unknown;
  1034. int16_t Speed; //!< Evengi Popov found this but I never seen what he said it was for
  1035. uint16_t AccelLo; //!< same as above
  1036. int16_t AccelHi; //!< same as above
  1037. uint8_t AUnknown[8]; //!< Unknown
  1038. uint16_t FrameStart; //!< first frame in this animation
  1039. uint16_t FrameEnd; //!< last frame in this animation ( numframes = ( End - Start) + 1 )
  1040. uint16_t NextAnimation;
  1041. uint16_t NextFrame;
  1042. uint16_t NumStateChanges;
  1043. uint16_t StateChangeOffset; //!< offset into StateChanges[]
  1044. uint16_t NumAnimCommands; //!< how many of them to use
  1045. uint16_t AnimCommand; //!< offset into AnimCommand[]
  1046. } tr5_animation_t;
  1047. typedef struct {
  1048. unsigned int unknown[24];
  1049. } tr5_cinematic_frame_t;
  1050. #ifdef _MSC_VER
  1051. #pragma pack(pop, tr2_h, 1)
  1052. #endif
  1053. #endif