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

TombRaider.h 29KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788
  1. /*!
  2. * \file include/TombRaider.h
  3. * \brief Loads maps, meshes, textures...
  4. *
  5. * \todo WARNING: No endian routines as of yet
  6. * \author Mongoose
  7. */
  8. #ifndef _TOMBRAIDER_H_
  9. #define _TOMBRAIDER_H_
  10. #include <cstdint>
  11. #ifdef WIN32
  12. typedef uint8_t u_int8_t;
  13. typedef uint16_t u_int16_t;
  14. typedef uint32_t u_int32_t;
  15. #endif
  16. #include "TombRaiderData.h"
  17. /*!
  18. * \brief Loads maps, meshes, textures...
  19. */
  20. class TombRaider {
  21. public:
  22. /*!
  23. * \brief Constructs an object of TombRaider
  24. */
  25. TombRaider();
  26. /*!
  27. * \brief Deconstructs an object of TombRaider
  28. */
  29. ~TombRaider();
  30. ////////////////////////////////////////
  31. // Wash me -- not part of cleaned API //
  32. ////////////////////////////////////////
  33. int NumRooms();
  34. int NumMoveables();
  35. int NumTextures();
  36. /*!
  37. * \brief Get number of _special_ textures/images
  38. * \returns number of special textures/images
  39. */
  40. int NumSpecialTextures();
  41. int NumAnimations();
  42. unsigned int NumFrames();
  43. int NumStaticMeshes();
  44. int NumSprites();
  45. int NumSpriteSequences();
  46. int NumItems();
  47. tr2_version_type Engine();
  48. unsigned short *Frame();
  49. tr2_animation_t *Animation();
  50. tr2_item_t *Item();
  51. tr2_object_texture_t *ObjectTextures();
  52. /*!
  53. * \brief Get number of boxes
  54. * \returns number of boxes
  55. */
  56. unsigned int getNumBoxes();
  57. tr2_box_t *Box();
  58. tr2_mesh_t *Mesh();
  59. /*!
  60. * \brief Get number of animations for a moveable
  61. * \param moveable_index valid moveable id
  62. * \returns number of animations for specified moveable
  63. */
  64. int getNumAnimsForMoveable(int moveable_index);
  65. tr2_staticmesh_t *StaticMesh();
  66. tr2_moveable_t *Moveable();
  67. tr2_meshtree_t *MeshTree();
  68. /*!
  69. * \brief Get the sprites
  70. * \returns the sprite array
  71. */
  72. tr2_sprite_texture_t *Sprite();
  73. tr2_sprite_sequence_t *SpriteSequence();
  74. /*!
  75. * \brief Makes a 32bit RGBA image from a stexture/bmap
  76. * \param texture valid index into tex_special list
  77. * \returns 32bit RGBA image or NULL on error
  78. */
  79. unsigned char *SpecialTexTile(int texture);
  80. /*!
  81. * \brief Get copies of texture and it's bumpmap
  82. * \param texture valid textile index
  83. * \param image will be set to texture if found, or NULL
  84. * \param bumpmap will be set to bumpmap if found, or NULL
  85. */
  86. void Texture(int texture, unsigned char **image, unsigned char **bumpmap);
  87. unsigned int *Palette16();
  88. unsigned char *Palette8();
  89. tr2_room_t *Room();
  90. /*!
  91. * \brief Check if a file is a TombRaider pak
  92. * \param filename file to check
  93. * \returns 0 if it is a TombRaider pak
  94. */
  95. static int checkMime(char *filename);
  96. /*!
  97. * \brief Loads TombRaider 1-5 pak into memory
  98. * and does some processing.
  99. * \param filename points to valid TombRaider pak
  100. * \returns 0 on success, < 0 on error
  101. * \sa TombRaider::loadTR5()
  102. */
  103. int Load(char *filename);
  104. /*!
  105. * \brief Makes a clamped 0.0 to 1.0 texel from coord pair
  106. * \param texel texel value, is modified, divided by 255.0 and returned
  107. * \param offset if offset is negative, texel is decreased by one, else increased
  108. * \returns modified texel divided by 255.0
  109. */
  110. float adjustTexel(unsigned char texel, char offset);
  111. /*!
  112. * \brief Compute rotation angles from moveable animation data
  113. * \param frame moveable animation data
  114. * \param frame_offset moveable animation data
  115. * \param angle_offset moveable animation data
  116. * \param x will be set to computed angle
  117. * \param y will be set to computed angle
  118. * \param z will be set to computed angle
  119. */
  120. void computeRotationAngles(unsigned short **frame,
  121. unsigned int *frame_offset,
  122. unsigned int *angle_offset,
  123. float *x, float *y, float *z);
  124. /*!
  125. * \brief Returns computed UV in u and v
  126. * \param st object texture vert, its coordinates are added to the pixels and divided by 255.0
  127. * \param u will contain calculated x value
  128. * \param v will contain calculated y value
  129. */
  130. void computeUV(tr2_object_texture_vert_t *st, float *u, float *v);
  131. /*!
  132. * \brief Get number of bump maps in loaded pak
  133. * \returns number of bump maps
  134. */
  135. int getBumpMapCount();
  136. void getColor(int index, float color[4]);
  137. tr2_version_type getEngine();
  138. /*!
  139. * \brief Get the collision sphere for a mesh
  140. * \param meshIndex mesh index
  141. * \param center will be filled with center coordinates, not NULL
  142. * \param radius will be filled with radius, not NULL
  143. */
  144. void getMeshCollisionInfo(unsigned int meshIndex,
  145. float center[3], float *radius);
  146. /*!
  147. * \brief Get SIGNED mesh count (TR encoded < 0 errors)
  148. * \returns signed mesh count
  149. */
  150. int getMeshCount();
  151. /*!
  152. * \brief This method is made to let you fill arrays or
  153. * create single faces. There may be an allocatin version that
  154. * passes back arrays later.
  155. * Returns Quads/Rects as 2 triangles,
  156. * because returning quads would be too trivial :)
  157. * \param meshIndex mesh index
  158. * \param faceIndex face index
  159. * \param index allocated RGBA
  160. * \param color allocated RGBA
  161. * \fixme This method interface may change later
  162. */
  163. void getMeshColoredRectangle(unsigned int meshIndex,
  164. unsigned int faceIndex,
  165. int index[6], float color[4]);
  166. /*!
  167. * \brief This method is made to let you fill arrays or
  168. * create single faces. There may be an allocating version that
  169. * passes back arrays later.
  170. * \param meshIndex mesh index
  171. * \param faceIndex face index
  172. * \param index allocated RGBA
  173. * \param color allocated RGBA
  174. * \fixme This method interface may change later
  175. */
  176. void getMeshColoredTriangle(unsigned int meshIndex,
  177. unsigned int faceIndex,
  178. int index[3], float color[4]);
  179. /*!
  180. * \brief This method is made to let you fill arrays or
  181. * create single faces. There may be an allocatin version that
  182. * passes back arrays later.
  183. * Returns Quads/Rects as 2 triangles,
  184. * because returning quads would be too trivial :)
  185. * \param meshIndex mesh index
  186. * \param faceIndex face index
  187. * \param index allocated
  188. * \param st allocated
  189. * \param texture allocated
  190. * \param transparency allocated
  191. * \fixme This method interface may change later
  192. */
  193. void getMeshTexturedRectangle(unsigned int meshIndex,
  194. unsigned int faceIndex,
  195. int index[6], float st[12], int *texture,
  196. unsigned short *transparency);
  197. /*!
  198. * \brief This method is made to let you fill arrays or
  199. * create single faces. There may be an allocatin version that
  200. * passes back arrays later.
  201. * \param meshIndex mesh index
  202. * \param faceIndex face index
  203. * \param index allocated
  204. * \param st allocated
  205. * \param texture allocated
  206. * \param transparency allocated
  207. * \fixme This method interface may change later
  208. */
  209. void getMeshTexturedTriangle(unsigned int meshIndex,
  210. unsigned int faceIndex,
  211. int index[3], float st[6], int *texture,
  212. unsigned short *transparency);
  213. /*!
  214. * \brief Get face counts for a given mesh.
  215. *
  216. * \todo This method interface may change later...
  217. * \param meshIndex mesh index
  218. * \returns number of textured triangles in mesh
  219. */
  220. int getMeshTexturedTriangleCount(unsigned int meshIndex);
  221. /*!
  222. * \brief Get face counts for a given mesh.
  223. * \param meshIndex mesh index
  224. * \returns number of colored triangles in mesh
  225. */
  226. int getMeshColoredTriangleCount(unsigned int meshIndex);
  227. /*!
  228. * \brief Get face counts for a given mesh.
  229. * \param meshIndex mesh index
  230. * \returns number of textured rectangles in mesh
  231. */
  232. int getMeshTexturedRectangleCount(unsigned int meshIndex);
  233. /*!
  234. * \brief Get face counts for a given mesh.
  235. * \returns number if colored rectangles in mesh
  236. */
  237. int getMeshColoredRectangleCount(unsigned int meshIndex);
  238. /*!
  239. * \brief Get vertex, normal and color arrays for a mesh
  240. * \param meshIndex mesh index
  241. * \param vertexCount will be set to length of vertex array
  242. * \param verts will be set to allocated vertex array (XYX)
  243. * \param normalCount will be set to length of normal array
  244. * \param norms will be set to allocated normal array (IJK)
  245. * \param colorCount will be set to length of color array
  246. * \param colors will be set to allocated color array (I)
  247. */
  248. void getMeshVertexArrays(unsigned int meshIndex,
  249. unsigned int *vertexCount, float **verts,
  250. unsigned int *normalCount, float **norms,
  251. unsigned int *colorCount, float **colors);
  252. /*!
  253. * \brief Get a single collision box from room (unified)
  254. * \param roomIndex room index
  255. * \param index index of box in room
  256. * \param xyzA will contain first corner of box
  257. * \param xyzB will contain second corner of box
  258. * \param xyzC will contain third corner of box
  259. * \param xyzD will contain fourth corner of box
  260. * \returns 0 on success, < 0 on error
  261. */
  262. int getRoomBox(unsigned int roomIndex, unsigned int index,
  263. float *xyzA, float *xyzB, float *xyzC, float *xyzD);
  264. /*!
  265. * \brief Get number of collision boxes in room (unified)
  266. * \param roomIndex room index
  267. * \returns number of collision boxes in room
  268. */
  269. unsigned int getRoomBoxCount(unsigned int roomIndex);
  270. void getRoomInfo(unsigned int index,
  271. unsigned int *flags, float pos[3],
  272. float bboxMin[3], float bboxMax[3]);
  273. /*!
  274. * \brief Get a single light from a room (unified)
  275. * \param roomIndex valid room index
  276. * \param index valid light index in room
  277. * \param pos allocated, will contain position
  278. * \param color allocated, will contain color
  279. * \param dir allocated, will contain direction
  280. * \param attenuation will contain attenuation
  281. * \param cutoffAngle will contain cutoff angle
  282. * \param type will contain type
  283. * \param flags will contain flags
  284. * \returns 0 on success, < 0 on error
  285. */
  286. int getRoomLight(unsigned int roomIndex, unsigned int index,
  287. float pos[4], float color[4], float dir[3],
  288. float *attenuation, float *cutoffAngle,
  289. unsigned int *type, unsigned int *flags);
  290. /*!
  291. * \brief Get number of lights in room (unified)
  292. * \param roomIndex room index
  293. * \returns number of lights in room
  294. */
  295. unsigned int getRoomLightCount(unsigned int roomIndex);
  296. /*!
  297. * \brief Get a single model info from a room
  298. * \param roomIndex valid room index
  299. * \param index valid model index in room
  300. * \param modelIndex will contain starting mesh
  301. * \param pos will contain pos
  302. * \param yaw will contain yaw angle
  303. * \returns 0 on success, < 0 on error
  304. */
  305. int getRoomModel(unsigned int roomIndex, unsigned int index,
  306. int *modelIndex, float pos[3], float *yaw);
  307. /*!
  308. * \brief Get number of room models in room (unified)
  309. * \param roomIndex room index
  310. * \returns number of room models in room
  311. */
  312. unsigned int getRoomModelCount(unsigned int roomIndex);
  313. /*!
  314. * \brief Get a single portal from room (unified)
  315. * \param roomIndex valid room index
  316. * \param index valid portal index in room
  317. * \param adjoiningRoom will contain adjoining room index
  318. * \param normal allocated, will contain normal vector
  319. * \param vertices allocated, will contain vertices
  320. * \returns 0 on success, < 0 on error
  321. */
  322. int getRoomPortal(unsigned int roomIndex, unsigned int index,
  323. int *adjoiningRoom, float normal[3], float vertices[12]);
  324. /*!
  325. * \brief Get number of portals from room (unified)
  326. * \param roomIndex room index
  327. * \returns number of portals from room
  328. */
  329. unsigned int getRoomPortalCount(unsigned int roomIndex);
  330. /*!
  331. * \brief Get rectangle data with texCoords for non-matching
  332. * vertex/uv for each vertex in TombRaider room (unified)
  333. * \param roomIndex valid room index
  334. * \param rectangleIndex rectangle index in room
  335. * \param indices will contain indices
  336. * \param texCoords will contain texCoords
  337. * \param texture will contain texture
  338. * \param flags will contain flags
  339. */
  340. void getRoomRectangle(unsigned int roomIndex, unsigned int rectangleIndex,
  341. unsigned int *indices, float *texCoords, int *texture,
  342. unsigned int *flags);
  343. /*!
  344. * \brief Get number of rectangles from room (unified)
  345. * \param roomIndex room index
  346. * \returns number of rectangles from room
  347. */
  348. unsigned int getRoomRectangleCount(unsigned int roomIndex);
  349. /*!
  350. * \brief Get a single sector from room (unified)
  351. * \param roomIndex room index
  352. * \param index sector index
  353. * \param flags will contain flags
  354. * \param ceiling will contain ceiling
  355. * \param floor will contain floor
  356. * \param floorDataIndex will contain floor data index
  357. * \param boxIndex will contain boxIndex
  358. * \param roomBelow will contain roomBelow
  359. * \param roomAbove will contain roomAbove
  360. * \return 0 on success, < 0 on error
  361. */
  362. int getRoomSector(unsigned int roomIndex, unsigned int index,
  363. unsigned int *flags, float *ceiling, float *floor,
  364. int *floorDataIndex, int *boxIndex,
  365. int *roomBelow, int *roomAbove);
  366. /*!
  367. * \brief Get number of sectors in room (unified)
  368. * \param roomIndex room index
  369. * \param zSectorsCount will contain width of sector list
  370. * \param xSectorsCount will contain height of sector list
  371. * \returns number of sectors in room
  372. */
  373. unsigned int getRoomSectorCount(unsigned int roomIndex,
  374. unsigned int *zSectorsCount,
  375. unsigned int *xSectorsCount);
  376. void getRoomSprite(unsigned int roomIndex, unsigned int index,
  377. float scale, int *texture,
  378. float *pos, float *vertices, float *texcoords);
  379. /*!
  380. * \brief Get number of sprites in room (unified)
  381. * \param roomIndex room index
  382. * \returns number of sprites in room
  383. */
  384. unsigned int getRoomSpriteCount(unsigned int roomIndex);
  385. /*!
  386. * \brief Gets triangle data with texCoords for non-matching
  387. * vertex/uv for each vertex in TombRaider room (unified)
  388. * \param roomIndex room index
  389. * \param triangleIndex triangle index
  390. * \param indices will contain indices
  391. * \param texCoords will contain texCoords
  392. * \param texture will contain texture
  393. * \param flags will contain flags
  394. */
  395. void getRoomTriangle(unsigned int roomIndex, unsigned int triangleIndex,
  396. unsigned int *indices, float *texCoords, int *texture,
  397. unsigned int *flags);
  398. /*!
  399. * \brief Gets triangle data with texCoords for non-matching
  400. * vertex/uv for each vertex in TombRaider room.
  401. *
  402. * This is used with vertices, colors, etc. to do partial array
  403. * rendering, since the texcoords will never match vertives
  404. * (Tomb Raider is textile based).
  405. * \param index room index
  406. * \param textureOffset texture offset
  407. * \param count will contain count
  408. * \param indices will contain indices
  409. * \param texCoords will contain texCoords
  410. * \param textures will contain textures
  411. * \param flags will contain flags
  412. */
  413. void getRoomTriangles(unsigned int index, int textureOffset,
  414. unsigned int *count, unsigned int **indices,
  415. float **texCoords, int **textures,
  416. unsigned int **flags);
  417. /*!
  418. * \brief Gets triangle data with duplicated vertex/color/normal
  419. * data for each face vertex to match the textile based texcoords.
  420. *
  421. * This uses more memory, but lets you do direct array rendering
  422. * with OpenGL, D3D, etc.
  423. * \param roomIndex room index
  424. * \param textureOffset texture offset
  425. * \param count will contain count
  426. * \param indices will contain indices
  427. * \param vertices will contain vertices
  428. * \param texCoords will contain texCoords
  429. * \param colors will contain colors
  430. * \param textures will contain textures
  431. * \param flags will contain flags
  432. */
  433. void getRoomTriangles(unsigned int roomIndex, int textureOffset,
  434. unsigned int *count,
  435. unsigned int **indices, float **vertices,
  436. float **texCoords, float **colors,
  437. int **textures, unsigned int **flags);
  438. /*!
  439. * \brief Get number of triangles from room (unified)
  440. * \param roomIndex room index
  441. * \returns number of triangles from room
  442. */
  443. unsigned int getRoomTriangleCount(unsigned int roomIndex);
  444. /*!
  445. * \brief Gets vertex position and color
  446. * \param roomIndex room index
  447. * \param vertexIndex vertex index
  448. * \param xyz will contain vertex position, has to be allocated
  449. * \param rgba will contain vertex color, has to be allocated
  450. */
  451. void getRoomVertex(unsigned int roomIndex, unsigned int vertexIndex,
  452. float *xyz, float *rgba);
  453. /*!
  454. * \brief Get allocated vertex and color arrays and their element counts (unified)
  455. * \param roomIndex valid room index
  456. * \param vertexCount will contain vertex array length
  457. * \param vertices will contain vertex array
  458. * \param normalCount will contain normal array length
  459. * \param normals will contain normal array
  460. * \param colorCount will contain color array length
  461. * \param colors will contain color array
  462. */
  463. void getRoomVertexArrays(unsigned int roomIndex,
  464. unsigned int *vertexCount, float **vertices,
  465. unsigned int *normalCount, float **normals,
  466. unsigned int *colorCount, float **colors);
  467. /*!
  468. * \brief Get number of lights in room (unified)
  469. * \param roomIndex room index
  470. * \returns number of lights in room
  471. */
  472. unsigned int getRoomVertexCount(unsigned int roomIndex);
  473. /*!
  474. * \brief Get sky mesh ID
  475. * \returns moveable id of sky mesh or -1 if none
  476. */
  477. int getSkyModelId();
  478. void getSprites();
  479. /*!
  480. * \brief Get a copy of a sound sample and its byte size
  481. * \param index sound sample index
  482. * \param bytes will contain byte size of sound sample
  483. * \param data will contain sound sample
  484. */
  485. void getSoundSample(unsigned int index,
  486. unsigned int *bytes, unsigned char **data);
  487. /*!
  488. * \brief Get number of loaded sound samples
  489. * \returns number of sound samples loaded
  490. */
  491. unsigned int getSoundSamplesCount();
  492. /*!
  493. * \brief Check if a mesh is valid
  494. * \param index mesh index (?)
  495. * \returns true if mesh is valid
  496. */
  497. bool isMeshValid(int index);
  498. /*!
  499. * \brief Check if a room is valid (TRC support)
  500. * \param index room index
  501. * \returns true if room is valid
  502. */
  503. bool isRoomValid(int index);
  504. /*!
  505. * \brief Load an external sound pak for TR2 and TR3
  506. * \param filename pak to load
  507. * \returns < 0 on error
  508. */
  509. int loadSFX(char *filename);
  510. void reset();
  511. void setDebug(bool toggle);
  512. /*!
  513. * \brief Sets lighting factor for each vertex color per room in TR3 paks
  514. * \param f new lighting factor
  515. */
  516. void setRoomVertexLightingFactor(float f);
  517. /*!
  518. * \brief Set scaling for sprite texel alignment, etc.
  519. * \param f new scaling factor
  520. */
  521. void setTexelScalingFactor(float f);
  522. private:
  523. void extractMeshes(unsigned char *mesh_data,
  524. unsigned int num_mesh_pointers,
  525. unsigned int *mesh_pointers);
  526. int Fread(void *buffer, size_t size, size_t count, FILE *f);
  527. /*!
  528. * \brief Get a copy of the sound samples
  529. * \param bytes will contain size of sound samples
  530. * \param data will contain sound samples themselves
  531. */
  532. void getRiffData(unsigned int *bytes, unsigned char **data);
  533. /*!
  534. * \brief Get a copy of a TR4 sound sample
  535. * \param index sound sample index
  536. * \param bytes will contain length of sound sample
  537. * \param data will contain sound sample itself
  538. */
  539. void getRiffDataTR4(unsigned int index,
  540. unsigned int *bytes, unsigned char **data);
  541. /*!
  542. * \brief Get an array of offsets for a contiguous RIFF data stream in chunks.
  543. *
  544. * Offsets will be allocated with enough space to hold expected
  545. * number of offsets. (Should be known number, otherwise not all RIFFs
  546. * will be parsed.)
  547. * \param riffData riff data
  548. * \param riffDataBytes length of riff data
  549. * \param offsets will contain offsets
  550. * \param numOffsets known number
  551. * \returns number of RIFFs found
  552. */
  553. int getRiffOffsets(unsigned char *riffData, unsigned int riffDataBytes,
  554. unsigned int **offsets, unsigned int numOffsets);
  555. /*!
  556. * \brief Makes a 32bit RGBA image from a textile.
  557. *
  558. * This handles all selection and conversion, including
  559. * alpha layering flags, now.
  560. * \param texture valid index into textile list
  561. * \returns 32bit RGBA image or NULL on error
  562. */
  563. unsigned char *getTexTile(int texture);
  564. /*!
  565. * \brief Loads a TR5 pak into memory.
  566. * \param f valid FILE
  567. * \returns 0 on success, < 0 on error
  568. */
  569. int loadTR5(FILE *f);
  570. static void print(const char *methodName, const char *s, ...) __attribute__((format(printf, 2, 3)));
  571. void printDebug(const char *methodName, const char *s, ...) __attribute__((format(printf, 3, 4)));
  572. bool mReset; //!< Guard multiple calls to reset()
  573. bool mDebug; //!< Debug output toggle
  574. unsigned int mPakVersion; //!< TombRaider pak file header version
  575. tr2_version_type mEngineVersion; //!< TombRaider engine version
  576. tr2_colour_t _palette8[256]; //!< 8-bit palette
  577. unsigned int _palette16[256]; //!< 16-bit palette
  578. unsigned int _num_textiles; //!< Total number of texture tiles
  579. unsigned short _num_room_textures; //!< Num textures only for room use?
  580. unsigned short _num_misc_textures; //!< Num of textures for misc use?
  581. unsigned short _num_bump_map_textures; //!< Num of textures that are bump map, texture pairs
  582. tr2_textile8_t *_textile8; //!< 8-bit (palettised) textiles
  583. tr2_textile16_t *_textile16; //!< 16-bit (ARGB) textiles
  584. tr2_textile32_t *_textile32; //!< 32-bit (BGRA) textiles
  585. unsigned int _num_tex_special; //!< Special textures and bump maps count
  586. unsigned char *_tex_special; //!< Special textures and bump maps
  587. unsigned int _unknown_t; //!< 32-bit unknown (always 0 in real TR2 levels)
  588. unsigned short _num_rooms; //!< Number of rooms in this level
  589. tr2_room_t *_rooms; //!< List of rooms (TR1,TR2,TR3,TR4)
  590. tr5_room_t *mRoomsTR5; //!< Rooms ( TR5 / TRC ) Only
  591. unsigned int _num_floor_data; //!< Num of words of floor data this level
  592. unsigned short *_floor_data; //!< Floor data
  593. int mMeshCount; //!< Number of meshes this level
  594. tr2_mesh_t *mMeshes; //!< list of meshes
  595. unsigned int _num_animations; //!< number of animations this level
  596. tr2_animation_t *_animations; //!< list of animations
  597. unsigned int _num_state_changes; //!< number of structures(?) this level
  598. tr2_state_change_t *_state_changes; //!< list of structures
  599. unsigned int _num_anim_dispatches; //!< number of ranges(?) this level
  600. tr2_anim_dispatch_t *_anim_dispatches; //!< list of ranges
  601. unsigned int _num_anim_commands; //!< number of Bone1s this level
  602. tr2_anim_command_t *_anim_commands; //!< list of Bone1s
  603. unsigned int _num_mesh_trees; //!< number of Bone2s this level
  604. tr2_meshtree_t *_mesh_trees; //!< list of Bone2s
  605. unsigned int _num_frames; //!< num of words of frame data this level
  606. unsigned short *_frames; //!< frame data
  607. unsigned int _num_moveables; //!< number of moveables this level
  608. tr2_moveable_t *_moveables; //!< list of moveables
  609. uint32_t numMoveablesTR5;
  610. tr5_moveable_t *moveablesTR5;
  611. uint32_t numAnimationsTR5;
  612. tr5_animation_t *animationsTR5;
  613. uint32_t numObjectTexturesTR5;
  614. tr5_object_texture_t *objectTexturesTR5;
  615. uint32_t numCinematicFramesTR5;
  616. tr5_cinematic_frame_t *cinematicFramesTR5;
  617. uint32_t numFlyByCamerasTR5;
  618. tr5_flyby_camera_t *flyByCamerasTR5;
  619. unsigned int _num_static_meshes; //!< number of static meshes this level
  620. tr2_staticmesh_t *_static_meshes; //!< static meshes
  621. unsigned int _num_object_textures; //!< number of object textures this level
  622. tr2_object_texture_t *_object_textures; //!< list of object textures
  623. unsigned int _num_sprite_textures; //!< num of sprite textures this level
  624. tr2_sprite_texture_t *_sprite_textures; //!< list of sprite textures
  625. unsigned int _num_sprite_sequences; //!< num of sprite sequences this level
  626. tr2_sprite_sequence_t *_sprite_sequences; //!< sprite sequence data
  627. int _num_cameras; //!< Number of Cameras
  628. tr2_camera_t *_cameras; //!< cameras
  629. int _num_sound_sources; //!< Number of Sounds
  630. tr2_sound_source_t *_sound_sources; //!< sounds
  631. int _num_boxes; //!< Number of Boxes
  632. tr2_box_t *_boxes; /*!< boxes - looks like
  633. * struct { unsigned short value[4]; }
  634. * - value[0..2] might be a vector;
  635. * value[3] seems to be index into
  636. * Overlaps[] */
  637. int _num_overlaps; //!< Number of Overlaps
  638. short *_overlaps; /*!< Overlaps -
  639. * looks like ushort; 0x8000 is flag
  640. * of some sort appears to be an
  641. * offset into Boxes[] and/or
  642. * Boxes2[] */
  643. short *_zones; //!< Boxes2
  644. int _num_animated_textures; //!< Number of AnimTextures
  645. short *_animated_textures; //!< Animtextures
  646. int _num_items; //!< Number of Items
  647. tr2_item_t *_items; //!< Items
  648. unsigned char *_light_map; //!< Colour-light maps
  649. unsigned int _num_cinematic_frames; //!< Number of cut-scene frames
  650. tr2_cinematic_frame_t *_cinematic_frames; //!< Cut-scene frames
  651. short _num_demo_data; //!< Number of Demo Data
  652. unsigned char *_demo_data; //!< Demo data
  653. float mRoomVertexLightingFactor;
  654. float mTexelScale;
  655. // Sound data
  656. short *mSoundMap; //!< Sound map
  657. int mNumSoundDetails; //!< Number of SampleModifiers
  658. tr2_sound_details_t *mSoundDetails; //!< Sample modifiers
  659. int mNumSampleIndices; //!< Number of Sample Indices
  660. int *mSampleIndices; //!< Sample indices
  661. unsigned int *mSampleIndicesTR5;
  662. bool mRiffAlternateLoaded; //!< Is a TR2,TR3 SFX loaded?
  663. unsigned int *mRiffAlternateOffsets; //!< After parsing this will
  664. //!< hold byte offsets for TR2,TR3
  665. //!< RIFFs in the buffered SFX
  666. int mRiffDataSz; //!< Byte size of a loaded SFX
  667. unsigned char *mRiffData; //!< SFX RIFF data in chunks
  668. unsigned int mNumTR4Samples;
  669. unsigned char **mTR4Samples;
  670. unsigned int *mTR4SamplesSz;
  671. // For packed Fread emu/wrapper
  672. unsigned char *mCompressedLevelData; //!< Buffer used to emulate fread with uncompressed libz data
  673. unsigned int mCompressedLevelDataOffset; //!< Offset into buffer
  674. unsigned int mCompressedLevelSize; //!< Size of buffer
  675. tr_fread_mode_t mFreadMode; //!< Fread mode file|buffer
  676. };
  677. #endif