Open Source Tomb Raider Engine
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

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