Open Source Tomb Raider Engine
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TombRaiderData.h 44KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139
  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
  389. frame_end; //!< last frame in this animation (numframes = (End - Start) + 1)
  390. unsigned short next_animation;
  391. unsigned short next_frame;
  392. unsigned short num_state_changes;
  393. unsigned short state_change_offset; //!< offset into StateChanges[]
  394. unsigned short num_anim_commands;
  395. unsigned short anim_command; //!< offset into AnimCommands[]
  396. } __attribute__((packed)) tr2_animation_t;
  397. /*!
  398. * \brief Data for an animation structure (40 bytes in TR4 vice 32 in TR1/2/3)
  399. */
  400. typedef struct {
  401. unsigned int frame_offset; //!< same meaning as in TR3
  402. unsigned char frame_rate; //!< same meaning as in TR3
  403. unsigned char frame_size; //!< same meaning as in TR3
  404. unsigned short state_id; //!< same meaning as in TR3
  405. short unknown; //!< same meaning as in TR3
  406. short speed; //!< same meaning as in TR3
  407. unsigned short accel_lo; //!< same meaning as in TR3
  408. short accel_hi; //!< same meaning as in TR3
  409. unsigned char unknown2[8]; //!< new in TR4
  410. unsigned short frame_start; //!< same meaning as in TR3
  411. unsigned short frame_end; //!< same meaning as in TR3
  412. unsigned short next_animation; //!< same meaning as in TR3
  413. unsigned short next_frame; //!< same meaning as in TR3
  414. unsigned short num_state_changes; //!< same meaning as in TR3
  415. unsigned short state_change_offset; //!< same meaning as in TR3
  416. unsigned short num_anim_commands; //!< same meaning as in TR3
  417. unsigned short anim_command; //!< same meaning as in TR3
  418. } __attribute__((packed)) tr4_animation_t;
  419. /*!
  420. * \brief State Change structure
  421. */
  422. typedef struct {
  423. unsigned short state_id;
  424. unsigned short num_anim_dispatches; //!< Number of dispatches (seems to always be 1..5)
  425. unsigned short anim_dispatch; //!< Offset into AnimDispatches[]
  426. } __attribute__((packed)) tr2_state_change_t;
  427. /*!
  428. * \brief Animation Dispatch structure
  429. */
  430. typedef struct {
  431. short low;
  432. short high;
  433. short next_animation;
  434. short next_frame;
  435. } __attribute__((packed)) tr2_anim_dispatch_t;
  436. /*!
  437. * \brief AnimCommand structure
  438. */
  439. typedef struct {
  440. short value;
  441. } __attribute__((packed)) tr2_anim_command_t;
  442. /*!
  443. * \brief MeshTree structure.
  444. *
  445. * MeshTree[] is actually groups of four ints. The first one is a
  446. * "flags" word; bit 1 (0x0002) indicates "make previous mesh an
  447. * anchor (e.g. PUSH)"; bit 0 (0x0001) indicates "return to previous
  448. * anchor (e.g. POP)".
  449. * The next three ints are X, Y, Z offsets from the last mesh position.
  450. */
  451. typedef struct {
  452. int flags; //!< 0x0001 = POP, 0x0002 = PUSH
  453. int x;
  454. int y;
  455. int z;
  456. } __attribute__((packed)) tr2_meshtree_t;
  457. /*!
  458. * \brief Moveable structure.
  459. *
  460. * This defines a list of contiguous meshes that
  461. * comprise one object, e.g. in WALL.TR2,
  462. *
  463. * moveable[0] = Lara (StartingMesh 0, NumMeshes 15),
  464. * moveable[13] = Tiger (StartingMesh 215, NumMeshes 27)
  465. * moveable[15] = Spikes (StartingMesh 249, NumMeshes 1)
  466. * moveable[16] = Boulder (StartingMesh 250, NumMeshes 1)
  467. * moveable[20] = Rolling Blade (StartingMesh 254, NumMeshes 1)
  468. */
  469. typedef struct {
  470. unsigned int object_id; //!< Item Identifier
  471. unsigned short num_meshes; //!< number of meshes in this object
  472. unsigned short starting_mesh; //!< first mesh
  473. unsigned int mesh_tree; //!< offset into MeshTree[]
  474. unsigned int frame_offset; //!< byte offset into Frames[] (divide by 2 for Frames[i])
  475. unsigned short animation; //!< offset into Animations[]
  476. } __attribute__((packed)) tr2_moveable_t;
  477. /*!
  478. * \brief StaticMesh structure.
  479. *
  480. * This defines meshes that don't move (e.g. skeletons
  481. * lying on the floor, spiderwebs, etc.)
  482. */
  483. typedef struct {
  484. unsigned int object_id; //!< Item Identifier
  485. unsigned short starting_mesh; //!< first mesh
  486. tr2_vertex_t bounding_box[2][2];
  487. unsigned short flags;
  488. } __attribute__((packed)) tr2_staticmesh_t;
  489. /*!
  490. * \brief Object texture vertex structure.
  491. *
  492. * Maps coordinates into texture tiles.
  493. */
  494. typedef struct {
  495. unsigned char xcoordinate;
  496. unsigned char xpixel;
  497. unsigned char ycoordinate;
  498. unsigned char ypixel;
  499. } __attribute__((packed)) tr2_object_texture_vert_t;
  500. /*!
  501. * \brief Object texture structure.
  502. */
  503. typedef struct {
  504. unsigned short transparency_flags; /*!< * 0: Opaque
  505. * * 1: Use transparency
  506. * * 2: Use partial transparency
  507. * [grayscale intensity :: transparency]
  508. */
  509. unsigned short tile; //!< index into textile list
  510. tr2_object_texture_vert_t vertices[4]; //!< the four corners of the texture
  511. } __attribute__((packed)) tr2_object_texture_t;
  512. /*!
  513. * \brief Sprite texture structure.
  514. */
  515. typedef struct {
  516. unsigned short tile;
  517. unsigned char x;
  518. unsigned char y;
  519. unsigned short width; //!< Actually, (width * 256) + 255
  520. unsigned short height; //!< Actually, (height * 256) + 255
  521. short left_side;
  522. short top_side;
  523. short right_side;
  524. short bottom_side;
  525. } __attribute__((packed)) tr2_sprite_texture_t;
  526. /*!
  527. * \brief Sprite Sequence structure
  528. */
  529. typedef struct {
  530. int object_id; //!< Item identifier (same numbering as in tr2_moveable)
  531. short negative_length; //!< Negative of "how many sprites are in this sequence"
  532. short offset; //!< Where (in sprite texture list) this sequence starts
  533. } __attribute__((packed)) tr2_sprite_sequence_t;
  534. /*!
  535. * \brief Mesh structure.
  536. *
  537. * The mesh list contains the mesh info for Lara (in all her
  538. * various incarnations), blocks, enemies (tigers, birds, bad guys),
  539. * moveable blocks, zip line handles, boulders, spinning blades,
  540. * you name it.
  541. *
  542. * If NumNormals is negative, Normals[] represent vertex
  543. * lighting values (one per vertex).
  544. */
  545. typedef struct {
  546. tr2_vertex_t centre; /*!< \brief This seems to describe the
  547. * approximate geometric centre
  548. * of the mesh (possibly the centre of gravity?)
  549. * (relative coordinates, just like the vertices) */
  550. int collision_size; //!< radius of collisional sphere
  551. short num_vertices; //!< number of vertices in this mesh
  552. tr2_vertex_t* vertices; //!< list of vertices (relative coordinates)
  553. short num_normals; //!< number of normals in this mesh (should always equal NumVertices)
  554. tr2_vertex_t* normals; //!< list of normals (NULL if NumNormals < 0)
  555. short* mesh_lights; //!< if NumNormals < 0
  556. short num_textured_rectangles; //!< number of textured rectangles
  557. tr2_quad_t* textured_rectangles; //!< list of textured rectangles
  558. short num_textured_triangles; //!< number of textured triangles in this mesh
  559. tr2_tri_t* textured_triangles; //!< list of textured triangles
  560. short num_coloured_rectangles; //!< number of coloured rectangles
  561. tr2_quad_t* coloured_rectangles; //!< list of coloured rectangles
  562. short num_coloured_triangles; //!< number of coloured triangles in this mesh
  563. tr2_tri_t* coloured_triangles; //!< list of coloured triangles
  564. } __attribute__((packed)) tr2_mesh_t;
  565. /*!
  566. * \brief Frame structure.
  567. *
  568. * Frames indicates how composite meshes are positioned and rotated.
  569. * They work in conjunction with Animations[] and Bone2[].
  570. *
  571. * A given frame has the following format:
  572. *
  573. * short BB1x, BB1y, BB1z // bounding box (low)
  574. * short BB2x, BB2y, BB2z // bounding box (high)
  575. * short OffsetX, OffsetY, OffsetZ // starting offset for this moveable
  576. * (TR1 ONLY: short NumValues // number of angle sets to follow)
  577. * (TR2/3: NumValues is implicitly NumMeshes (from moveable))
  578. *
  579. * What follows next is a list of angle sets. In TR2/3, an angle set can
  580. * specify either one or three axes of rotation. If either of the high two
  581. * bits (0xc000) of the first angle unsigned short are set, it's one axis:
  582. *
  583. * only one unsigned short,
  584. * low 10 bits (0x03ff),
  585. * scale is 0x100 == 90 degrees;
  586. *
  587. * the high two bits are interpreted as follows:
  588. *
  589. * 0x4000 == X only, 0x8000 == Y only,
  590. * 0xC000 == Z only.
  591. *
  592. * If neither of the high bits are set, it's a three-axis rotation. The next
  593. * 10 bits (0x3ff0) are the X rotation, the next 10 (including the following
  594. * unsigned short) (0x000f, 0xfc00) are the Y rotation,
  595. * the next 10 (0x03ff) are the Z rotation, same scale as
  596. * before (0x100 == 90 degrees).
  597. *
  598. * Rotations are performed in Y, X, Z order.
  599. * TR1 ONLY: All angle sets are two words and interpreted like the two-word
  600. * sets in TR2/3, EXCEPT that the word order is reversed.
  601. */
  602. typedef struct {
  603. tr2_vertex_t vector[3];
  604. int num_words;
  605. unsigned short* words;
  606. } __attribute__((packed)) tr2_frame_t;
  607. /*!
  608. * \brief Item structure
  609. */
  610. typedef struct {
  611. short object_id;
  612. short room;
  613. int x;
  614. int y;
  615. int z;
  616. short angle;
  617. short intensity1;
  618. short intensity2;
  619. short flags; //!< 0x0100 indicates "inactive" or "invisible"
  620. } __attribute__((packed)) tr2_item_t;
  621. /*!
  622. * \brief SoundSource structure
  623. */
  624. typedef struct {
  625. int x; //!< position of sound source
  626. int y;
  627. int z;
  628. unsigned short sound_id; //!< internal sound index
  629. unsigned short flags; //!< 0x40, 0x80, or 0xc0
  630. } __attribute__((packed)) tr2_sound_source_t;
  631. /*!
  632. * \brief Boxes structure
  633. */
  634. typedef struct {
  635. unsigned char zmin; //!< sectors (* 1024 units)
  636. unsigned char zmax;
  637. unsigned char xmin;
  638. unsigned char xmax;
  639. short true_floor; //!< Y value (no scaling)
  640. short overlap_index; //!< index into Overlaps[]
  641. } __attribute__((packed)) tr2_box_t;
  642. /*!
  643. * \brief AnimatedTexture structure.
  644. *
  645. * - really should be simple short[], since it's variable length
  646. */
  647. typedef struct {
  648. short num_texture_ids; //!< Number of Texture IDs - 1
  649. short* texture_list; //!< list of textures to cycle through
  650. } __attribute__((packed)) tr2_animated_texture_t;
  651. /*!
  652. * \brief Camera structure
  653. */
  654. typedef struct {
  655. int x;
  656. int y;
  657. int z;
  658. short room;
  659. unsigned short unknown1; //!< correlates to Boxes[]?
  660. } __attribute__((packed)) tr2_camera_t;
  661. /*
  662. * \brief Data for a flyby camera (40 bytes)
  663. */
  664. typedef struct {
  665. int pos[6]; //!< Positions ? (x1,y1,z1,x2,y2,z2) roatations?
  666. unsigned char index[2]; //!< A pair of indices
  667. unsigned short unknown[5]; //!< ??
  668. int id; //!< Index of something
  669. } __attribute__((packed)) tr4_extra_camera_t;
  670. /*!
  671. * \brief Sound sample structure
  672. */
  673. typedef struct {
  674. short sample;
  675. short volume;
  676. short sound_range;
  677. short flags; /*!< \ brief bits 8-15: priority?, 2-7: number of sound samples
  678. * in this group, bits 0-1: channel number */
  679. } __attribute__((packed)) tr2_sound_details_t;
  680. /*!
  681. * \brief Cutscene Camera structure
  682. */
  683. typedef struct {
  684. short roty; //!< Rotation about Y axis, +/-32767 ::= +/- 180 degrees
  685. short rotz; //!< Rotation about Z axis, +/-32767 ::= +/- 180 degrees
  686. short rotz2; //!< Rotation about Z axis (why two?), +/-32767 ::= +/- 180 degrees
  687. short posz; //!< Z position of camera, relative to something
  688. short posy; //!< Y position of camera, relative to something
  689. short posx; //!< X position of camera, relative to something
  690. short unknown1;
  691. short rotx; //!< Rotation about X axis, +/-32767 ::= +/- 180 degrees
  692. } __attribute__((packed)) tr2_cinematic_frame_t;
  693. /*!
  694. * \brief Data for a AI object (24 bytes).
  695. *
  696. * this field replaces the bitu16 NumCinematicFrames of TR1/2/3 levels
  697. *
  698. * Used to read TR4 AI data
  699. */
  700. typedef struct {
  701. unsigned short int object_id; //!< the objectID from the AI object
  702. //!< (AI_FOLLOW is 402)
  703. unsigned short int room;
  704. int x, y, a;
  705. unsigned short int ocb;
  706. unsigned short int flags; //!< The trigger flags
  707. //!< (button 1-5, first button has value 2)
  708. int angle; //!< rotation
  709. } __attribute__((packed)) tr4_ai_object_t;
  710. /*!
  711. * \brief Used to read packed TR4 texels
  712. */
  713. typedef struct {
  714. unsigned short attribute; //!< same meaning as in TR3
  715. unsigned short tile; //!< same meaning as in TR3
  716. unsigned short flags; //!< new in TR4
  717. tr2_object_texture_vert_t vertices[4]; //!< same meaning as in TR3
  718. unsigned int unknown1, unknown2; //!< new in TR4: x & y offset in something
  719. unsigned int xsize, ysize; //!< new in TR4: width-1 & height-1 of the object texture
  720. } __attribute__((packed)) tr4_object_texture_t;
  721. /*!
  722. * \brief TR5 Room Layer (56 bytes)
  723. */
  724. typedef struct {
  725. uint32_t numLayerVertices; //!< number of vertices in this layer (4 bytes)
  726. uint16_t unknownL1; //!< unknown (2 bytes)
  727. uint16_t numLayerRectangles; //!< number of rectangles in this layer (2 bytes)
  728. uint16_t numLayerTriangles; //!< number of triangles in this layer (2 bytes)
  729. uint16_t unknownL2; //!< appears to be the number of 2 sided textures
  730. //!< in this layer, however is sometimes 1 off (2 bytes)
  731. uint16_t filler; //!< always 0 (2 bytes)
  732. uint16_t filler2; //!< always 0 (2 bytes)
  733. float layerBoundingBoxX1; //!< These 6 floats (4 bytes each) define the bounding box for the layer
  734. float layerBoundingBoxY1;
  735. float layerBoundingBoxZ1;
  736. float layerBoundingBoxX2;
  737. float layerBoundingBoxY2;
  738. float layerBoundingBoxZ2;
  739. uint32_t filler3; //!< always 0 (4 bytes)
  740. uint32_t unknownL6; //!< unknown (4 bytes)
  741. uint32_t unknownL7; //!< unknown (4 bytes)
  742. uint32_t unknownL8; //!< unknown. Always the same throughout the level. (4 bytes)
  743. } tr5_room_layer_t;
  744. /*!
  745. * \brief TR5 Quad (12 bytes)
  746. */
  747. typedef struct {
  748. uint16_t vertices[4]; //!< the values are the indices into the
  749. //!< appropriate layer vertice list. (2 bytes each)
  750. uint16_t texture; //!< the texture number for this face. Needs to be masked
  751. //!< with 0xFFF as the high 4 bits are flags (2 bytes)
  752. uint16_t unknownF4; //!< unknown (2 bytes)
  753. } tr5_face4_t;
  754. /*!
  755. * \brief TR5 triangular face (10 bytes)
  756. */
  757. typedef struct {
  758. uint16_t vertices[3]; //!< the values are the indices into the
  759. //!< appropriate layer vertice list (2 bytes each)
  760. uint16_t texture; //!< the texture number for this face. Needs to be masked
  761. //!< with 0xFFF as the high 4 bits are flags (2 bytes)
  762. uint16_t unknownF3; //!< unknown (2 bytes)
  763. } tr5_face3_t;
  764. /*!
  765. * \brief TR5 Vertex (28 bytes)
  766. */
  767. typedef struct {
  768. float x; //!< x of vertex (4 bytes)
  769. float y; //!< y of vertex (4 bytes)
  770. float z; //!< z of vertex (4 bytes)
  771. float nx; //!< x of vertex normal (4 bytes)
  772. float ny; //!< y of vertex normal (4 bytes)
  773. float nz; //!< z of vertex normal (4 bytes)
  774. uint32_t vColor; //!< vertex color ARGB format (4 bytes)
  775. } tr5_vertex_t;
  776. /*!
  777. * \brief This is to help store and manage TR5 layer based polgons for rooms
  778. */
  779. typedef struct {
  780. tr5_face4_t* quads;
  781. tr5_face3_t* tris;
  782. tr5_vertex_t* verts;
  783. } tr5_room_geometry_t;
  784. /*!
  785. * \brief TR5 light (88 bytes)
  786. */
  787. typedef struct {
  788. float x; //!< x position of light (4 bytes)
  789. float y; //!< y position of light (4 bytes)
  790. float z; //!< z position of light (4 bytes)
  791. /*!< Maybe wrong: The (x, y, z) floats specify the position of the light
  792. * in world coordinates.
  793. *
  794. * The sun type light should not use these but seems to have a
  795. * large x value (9 million, give or take)
  796. * a zero y value, and a small z value (4 - 20) in the original TR5 levels
  797. */
  798. float red; //!< color of red spectrum (4 bytes)
  799. float green; //!< color of green spectrum (4 bytes)
  800. float blue; //!< color of blue spectrum (4 bytes)
  801. uint32_t seperator; //!< not used 0xCDCDCDCD (4 bytes)
  802. float input; //!< cosine of the IN value for light / size of IN value (4 bytes)
  803. float output; //!< cosine of the OUT value for light / size of OUT value (4 bytes)
  804. /*!< At this point the info diverges dependant
  805. * on which type of light being used:
  806. *
  807. * 0 = sun, 1 = light, 2 = spot, 3 = shadow
  808. *
  809. * The sun type doesn't use input and output.
  810. *
  811. * For the spot type these are the hotspot and falloff angle cosines.
  812. *
  813. * For the light and shadow types these are the TR units
  814. * for the hotspot/falloff (1024=1sector).
  815. */
  816. float radInput; //!< (IN radians) * 2 (4 bytes)
  817. float radOutput; //!< (OUT radians) * 2 (4 bytes)
  818. //!< radInput and radOutput are only used by the spot type light
  819. float range; //!< Range of light (4 bytes), only used by the spot type light
  820. float directionVectorX; //!< light direction (4 bytes)
  821. float directionVectorY; //!< light direction (4 bytes)
  822. float directionVectorZ; //!< light direction (4 bytes)
  823. /*!< The 3 directionVector floats are used only by the 'sun' and 'spot' type lights.
  824. * They describe the directional vector of the light.
  825. * This can be obtained by:
  826. *
  827. * if both x and y LightDirectionVectorX = cosX * sinY
  828. *
  829. * LightDirectionVectorY = sinX
  830. * LightDirectionVectorZ = cosX * cosY
  831. */
  832. int32_t x2; //!< x position of light (4 bytes)
  833. int32_t y2; //!< y position of light (4 bytes)
  834. int32_t z2; //!< z position of light (4 bytes)
  835. /*!<
  836. * x2, y2, z2 and the directionVectors-2 repeat some of the
  837. * previous information in long data types vice floats
  838. */
  839. int32_t directionVectorX2; //!< light direction (4 bytes)
  840. int32_t directionVectorY2; //!< light direction (4 bytes)
  841. int32_t directionVectorZ2; //!< light direction (4 bytes)
  842. //!< 16384 = 1.0 for the rotations (1/16384)
  843. uint8_t lightType; //!< type of light as specified above (1 byte)
  844. uint8_t seperator2[3]; //!< 0xCDCDCD (3 bytes)
  845. } tr5_light_t;
  846. /*!
  847. * \brief TR5 Room.
  848. *
  849. * First number is offset in bytes from start of room structure.
  850. */
  851. typedef struct {
  852. uint32_t checkXELA; //!< "XELA" (4 bytes)
  853. uint32_t roomDataSize; /*!< size of the following data ( use this vice
  854. * 'walking thru' to get next room) (4 bytes) */
  855. uint32_t seperator; //!< 0xCDCDCDCD (4 bytes)
  856. uint32_t endSDOffset; /*!< usually this number + 216 will give you the
  857. * offset from the start of the room data to the end
  858. * of the Sector Data. HOWEVER have seen where this
  859. * bitu32 is equal to -1 so it is better to use the
  860. * following bitu32 and + 216 +
  861. * ((NumXSectors * NumZSectors)*8) if you need
  862. * to obtain this information. (4 bytes) */
  863. uint32_t startSDOffset; /*!< this number + 216 will give you the offset from
  864. * the start of the room to the start of the
  865. * sector data. (4 bytes) */
  866. uint32_t seperator2; //!< will either be 0x00000000 or 0xCDCDCDCD (4 bytes)
  867. uint32_t endPortalOffset; /*!< this number + 216 will give you the offset
  868. * from the start of the room to the end of the
  869. * portal data. (4 bytes) */
  870. int32_t x; //!< X position of room ( world coordinates) (4 bytes)
  871. int32_t seperator3; //!< 0x00000000 (4 bytes)
  872. int32_t z; //!< Z position of room (world coordinates) (4 bytes)
  873. int32_t yBottom; //!< lowest point in room (4 bytes)
  874. int32_t yTop; //!< highest point in room (4 bytes)
  875. uint16_t numZSectors; //!< sector table width (2 bytes)
  876. uint16_t numXSectors; //!< sector table height (2 bytes)
  877. uint32_t roomAmbientColor; //!< ARGB format (blue is least significant byte) (4 bytes)
  878. uint16_t numRoomLights; //!< number of lights in this room (2 bytes)
  879. uint16_t numStaticMeshes; //!< number of static meshes in this room (2 bytes)
  880. uint16_t unknownR1; //!< usually 0x0001 however high byte is sometimes non zero (2 bytes)
  881. uint16_t unknownR2; //!< usually 0x0000 however low byte is sometimes non zero (2 bytes)
  882. uint32_t filler; //!< always 0x00007FFF (4 bytes)
  883. uint32_t filler2; //!< always 0x00007FFF (4 bytes)
  884. uint32_t seperator4; //!< 0xCDCDCDCD (4 bytes)
  885. uint32_t seperator5; //!< 0xCDCDCDCD (4 bytes)
  886. unsigned char seperator6[6]; //!< 6 bytes 0xFF
  887. uint16_t roomFlag; //!< 0x01 = water, 0x20 = wind, others unknown (2 bytes)
  888. uint16_t unknownR5; //!< unknown (2 bytes)
  889. unsigned char seperator7[10]; //!< 10 bytes 0x00
  890. uint32_t seperator8; //!< 0xCDCDCDCD (4 bytes)
  891. uint32_t unknownR6; //!< unknown (4 bytes)
  892. float roomX; //!< X position of room in world coordinates
  893. //!< If null room then this data will be 0xCDCDCDCD (4 bytes)
  894. uint32_t seperator9; //!< 0x00000000 or 0xCDCDCDCD if null room. (4 bytes)
  895. float roomZ; //!< Z position of room in world coordinates
  896. //!< If null room then will be bitu32 0xCDCDCDCD (4 bytes)
  897. uint32_t seperator10; //!< 0xCDCDCDCD (4 bytes)
  898. uint32_t seperator11; //!< 0xCDCDCDCD (4 bytes)
  899. uint32_t seperator12; //!< 0xCDCDCDCD (4 bytes)
  900. uint32_t seperator13; //!< 0xCDCDCDCD (4 bytes)
  901. uint32_t seperator14; //!< 0x00000000 unless null room then 0xCDCDCDCD (4 bytes)
  902. uint32_t seperator15; //!< 0xCDCDCDCD (4 bytes)
  903. uint32_t numRoomTriangles; //!< total number of triangles this room (4 bytes)
  904. uint32_t numRoomRectangles; //!< total number of rectangles this room (4 bytes)
  905. uint32_t seperator16; //!< 0x00000000 (4 bytes)
  906. uint32_t lightSize; //!< size of light data (number of lights * 88) (4 bytes)
  907. uint32_t numTotalRoomLights; //!< total number of lights this room (4 bytes)
  908. uint32_t unknownR7; //!< unknown, usually equals 0, 1, 2, or 3 (4 bytes)
  909. int32_t unknownR8; //!< usually equals room yTop. Sometimes a few blocks off.
  910. //!< If null room then 0xCDCDCDCD
  911. int32_t lyBottom; //!< equals room yBottom. If null room then 0xCDCDCDCD (4 bytes)
  912. uint32_t numLayers; //!< number of layers (pieces) this room (4 bytes)
  913. uint32_t layerOffset; //!< this number + 216 will give you an offset from the start
  914. //!< of the room data to the start of the layer data (4 bytes)
  915. uint32_t verticesOffset; //!< this number + 216 will give you an offset from the start
  916. //!< of the room data to the start of the verex data (4 bytes)
  917. uint32_t polyOffset; //!< this number + 216 will give you an offset from the start
  918. //!< of the room data to the start of the rectangle/triangle data (4 bytes)
  919. uint32_t polyOffset2; //!< same as above ? (4 bytes)
  920. uint32_t verticesSize; //!< size of vertices data block (4 bytes)
  921. uint32_t seperator17; //!< 0xCDCDCDCD (4 bytes)
  922. uint32_t seperator18; //!< 0xCDCDCDCD (4 bytes)
  923. uint32_t seperator19; //!< 0xCDCDCDCD (4 bytes)
  924. uint32_t seperator20; //!< 0xCDCDCDCD (4 bytes)
  925. tr5_light_t* lights; //!< [LightSize];
  926. //!< data for the lights (88 bytes * NumRoomLights)
  927. tr2_room_sector_t* sectors; //!< Data[(NumXSectors * NumZSectors) * 8];
  928. //!< normal sector data structure
  929. uint16_t numDoors; //!< number of portals (2 bytes)
  930. tr2_room_portal_t* doors; //!< [NumDoors];
  931. //!< normal portal structure (32 bytes * NumDoors)
  932. uint16_t seperator21; //!< 0xCDCD (2 bytes)
  933. tr2_room_staticmesh_t* meshes; //!< [NumStaticMeshes];
  934. //!< normal room static mesh structure (20 bytes * NumRoomStaticMeshes)
  935. tr5_room_layer_t* layers; //!< [NumLayers];
  936. //!< data for the room layers (pieces) (56 bytes * NumLayers)
  937. tr5_room_geometry_t* faces; //!< [NumRoomRectangles + NumRoomTriangles];
  938. /* Data for the room polys (face4 and face3).
  939. * Structured as first layers rectangles
  940. * then triangles, followed by the
  941. * next layers rectangles and triangles, etc.,
  942. * until all layers are done.
  943. * (12 bytes each rectangle. 10 bytes each triangle)
  944. */
  945. tr5_vertex_t* vertices; //!< [VerticesSize];
  946. /*!< Data for the room vertices.
  947. * Structured as vertices for the first layer,
  948. * then vertices for the second layer, etc.,
  949. * until all layers are done.
  950. * (28 bytes each vertex.
  951. */
  952. } tr5_room_t;
  953. /*!
  954. * \brief TR5 Object Texture Vertex (4 bytes)
  955. */
  956. typedef struct {
  957. uint8_t xCoordinate; //!< 0 if Xpixel is the low value,
  958. //!< 255 if Xpixel is the high value in the object texture (1 byte)
  959. uint8_t xPixel; //!< (1 byte)
  960. uint8_t yCoordinate; //!< 0 if Ypixel is the low value,
  961. //!< 255 if Ypixel is the high value in the object texture (1 byte)
  962. uint8_t yPixel; //!< (1 byte)
  963. } tr5_object_texture_vertex_t;
  964. /*!
  965. * \brief TR5 Object Texture (40 bytes)
  966. */
  967. typedef struct {
  968. uint16_t attribute; //!< 0, 1, or 2 (2 means 2 sided) (2 bytes)
  969. uint32_t tile; //!< need to mask with 0xFF as other bits are flags.
  970. //!< ie int15_t seems to indicate triangle (4 bytes)
  971. tr5_object_texture_vertex_t vertices[4]; //!< Vertices[4] (16 bytes)
  972. uint32_t uv1; //!< unknown how used (4 bytes)
  973. uint32_t uv2; //!< unknown how used (4 bytes)
  974. uint32_t xSize; //!< unknown how used, x size (4 bytes)
  975. uint32_t ySize; //!< unknown how used, y size (4 bytes)
  976. uint16_t seperator; //!< always 0x0000 (2 bytes)
  977. } tr5_object_texture_t;
  978. /*!
  979. * \brief TR5 Flyby camera (40 bytes)
  980. */
  981. typedef struct {
  982. int32_t cameraX; //!< x position of camera in world coordinates (4 bytes)
  983. int32_t cameraY; //!< y position of camera in world coordinates (4 bytes)
  984. int32_t cameraZ; //!< z position of camera in world coordinates (4 bytes)
  985. int32_t targetX; //!< x position of aiming point in world coords (4 bytes)
  986. int32_t targetY; //!< y position of aiming point in world coords (4 bytes)
  987. int32_t targetZ; //!< z position of aiming point in world coords (4 bytes)
  988. int8_t sequence; //!< sequence # of camera (1 byte)
  989. int8_t cameraNumber; //!< camera # (1 byte)
  990. uint16_t fov; //!< fov of camera ( .0054945 for each degree ) (2 bytes)
  991. uint16_t roll; //!< roll of camera ( .0054945 for each degree ) (2 bytes)
  992. uint16_t timer; //!< timer number (2 bytes)
  993. uint16_t speed; //!< ( .000015259 each ) (2 bytes)
  994. uint16_t flags; //!< ( see your handy TRLE manual for the specs ) (2 bytes)
  995. uint32_t room; //!< room number (4 bytes)
  996. } tr5_flyby_camera_t;
  997. /*!
  998. * \brief TR5 Moveable (20 bytes).
  999. *
  1000. * Same as old structure but has uint16_t filler at the end
  1001. */
  1002. typedef struct {
  1003. uint32_t objectId; //!< object identifier ( matched in Items[] )
  1004. uint16_t numMeshes; //!< number of meshes in this object
  1005. uint16_t startingMesh; //!< starting mesh ( offset into MeshPointers[] )
  1006. uint32_t meshTree; //!< offset into MeshTree[] )
  1007. uint32_t frameOffset; //!< byte offset into Frames[] ( divide by 2 for Frames[i] )
  1008. uint16_t animation; //!< offset into Animations[]
  1009. uint16_t filler; //!< always equal to 65519 ( 0xFFEF )
  1010. } tr5_moveable_t;
  1011. typedef struct {
  1012. tr2_vertex_t center; //!< relative coordinates of mesh centre (6 bytes)
  1013. uint8_t unknown1[4]; //!< unknown (4 bytes)
  1014. int16_t numVertices; //!< number of vertices to follow (2 bytes)
  1015. tr2_vertex_t* vertices; //!< list of vertices (NumVertices * 6 bytes)
  1016. int16_t numNormals; //!< number of normals to follow (2 bytes)
  1017. tr2_vertex_t* normals; //!< list of normals (NumNormals * 6 bytes)
  1018. //!< (becomes Lights if NumNormals < 0; 2 bytes)
  1019. int16_t numTexturedRectangles; //!< number of textured rectangles to follow (2 bytes)
  1020. tr5_face4_t* texturedRectangles; //!< list of textured rectangles (NumTexturedRectangles * 12 bytes)
  1021. int16_t numTexturedTriangles; //!< number of textured triangles to follow (2 bytes)
  1022. tr5_face3_t* texturedTriangles; //!< list of textured triangles (NumTexturedTriangles * 10 bytes)
  1023. } tr5_mesh_t;
  1024. /*!
  1025. * \brief TR5 Animation (40 bytes).
  1026. *
  1027. * Same as old structure but has 8 bytes before FrameStart.
  1028. */
  1029. typedef struct {
  1030. uint32_t FrameOffset; //!< byte offset into Frames[] ( divide by 2 for Frames[i] )
  1031. uint8_t FrameRate; //!< Engine ticks per frame
  1032. uint8_t FrameSize; //!< number of int16_t's in Frames[] used by this animation
  1033. uint16_t StateId;
  1034. int16_t Unknown;
  1035. int16_t Speed; //!< Evengi Popov found this but I never seen what he said it was for
  1036. uint16_t AccelLo; //!< same as above
  1037. int16_t AccelHi; //!< same as above
  1038. uint8_t AUnknown[8]; //!< Unknown
  1039. uint16_t FrameStart; //!< first frame in this animation
  1040. uint16_t FrameEnd; //!< last frame in this animation ( numframes = ( End - Start) + 1 )
  1041. uint16_t NextAnimation;
  1042. uint16_t NextFrame;
  1043. uint16_t NumStateChanges;
  1044. uint16_t StateChangeOffset; //!< offset into StateChanges[]
  1045. uint16_t NumAnimCommands; //!< how many of them to use
  1046. uint16_t AnimCommand; //!< offset into AnimCommand[]
  1047. } tr5_animation_t;
  1048. typedef struct {
  1049. unsigned int unknown[24];
  1050. } tr5_cinematic_frame_t;
  1051. #ifdef _MSC_VER
  1052. #pragma pack(pop, tr2_h, 1)
  1053. #endif
  1054. #endif