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

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