Open Source Tomb Raider Engine
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

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. #include <cstdio>
  12. #ifdef WIN32
  13. typedef uint8_t u_int8_t;
  14. typedef uint16_t u_int16_t;
  15. typedef uint32_t u_int32_t;
  16. #endif
  17. #include "TombRaiderData.h"
  18. /*!
  19. * \brief Loads maps, meshes, textures...
  20. */
  21. class TombRaider {
  22. public:
  23. /*!
  24. * \brief Constructs an object of TombRaider
  25. */
  26. TombRaider();
  27. /*!
  28. * \brief Deconstructs an object of TombRaider
  29. */
  30. ~TombRaider();
  31. ////////////////////////////////////////
  32. // Wash me -- not part of cleaned API //
  33. ////////////////////////////////////////
  34. int NumRooms();
  35. int NumMoveables();
  36. int NumTextures();
  37. /*!
  38. * \brief Get number of _special_ textures/images
  39. * \returns number of special textures/images
  40. */
  41. int NumSpecialTextures();
  42. int NumAnimations();
  43. unsigned int NumFrames();
  44. int NumStaticMeshes();
  45. int NumSprites();
  46. int NumSpriteSequences();
  47. int NumItems();
  48. tr2_version_type Engine();
  49. unsigned short *Frame();
  50. tr2_animation_t *Animation();
  51. tr2_item_t *Item();
  52. tr2_object_texture_t *ObjectTextures();
  53. /*!
  54. * \brief Get number of boxes
  55. * \returns number of boxes
  56. */
  57. unsigned int getNumBoxes();
  58. tr2_box_t *Box();
  59. tr2_mesh_t *Mesh();
  60. /*!
  61. * \brief Get number of animations for a moveable
  62. * \param moveable_index valid moveable id
  63. * \returns number of animations for specified moveable
  64. */
  65. int getNumAnimsForMoveable(int moveable_index);
  66. tr2_staticmesh_t *StaticMesh();
  67. tr2_moveable_t *Moveable();
  68. tr2_meshtree_t *MeshTree();
  69. /*!
  70. * \brief Get the sprites
  71. * \returns the sprite array
  72. */
  73. tr2_sprite_texture_t *Sprite();
  74. tr2_sprite_sequence_t *SpriteSequence();
  75. /*!
  76. * \brief Makes a 32bit RGBA image from a stexture/bmap
  77. * \param texture valid index into tex_special list
  78. * \returns 32bit RGBA image or NULL on error
  79. */
  80. unsigned char *SpecialTexTile(int texture);
  81. /*!
  82. * \brief Get copies of texture and it's bumpmap
  83. * \param texture valid textile index
  84. * \param image will be set to texture if found, or NULL
  85. * \param bumpmap will be set to bumpmap if found, or NULL
  86. */
  87. void Texture(int texture, unsigned char **image, unsigned char **bumpmap);
  88. unsigned int *Palette16();
  89. unsigned char *Palette8();
  90. tr2_room_t *Room();
  91. /*!
  92. * \brief Check if a file is a TombRaider pak
  93. * \param filename file to check
  94. * \returns 0 if it is a TombRaider pak
  95. */
  96. static int checkMime(char *filename);
  97. /*!
  98. * \brief Loads TombRaider 1-5 pak into memory
  99. * and does some processing.
  100. * \param filename points to valid TombRaider pak
  101. * \returns 0 on success, < 0 on error
  102. * \sa TombRaider::loadTR5()
  103. */
  104. int Load(char *filename);
  105. /*!
  106. * \brief Makes a clamped 0.0 to 1.0 texel from coord pair
  107. * \param texel texel value, is modified, divided by 255.0 and returned
  108. * \param offset if offset is negative, texel is decreased by one, else increased
  109. * \returns modified texel divided by 255.0
  110. */
  111. float adjustTexel(unsigned char texel, char offset);
  112. /*!
  113. * \brief Compute rotation angles from moveable animation data
  114. * \param frame moveable animation data
  115. * \param frame_offset moveable animation data
  116. * \param angle_offset moveable animation data
  117. * \param x will be set to computed angle
  118. * \param y will be set to computed angle
  119. * \param z will be set to computed angle
  120. */
  121. void computeRotationAngles(unsigned short **frame,
  122. unsigned int *frame_offset,
  123. unsigned int *angle_offset,
  124. float *x, float *y, float *z);
  125. /*!
  126. * \brief Returns computed UV in u and v
  127. * \param st object texture vert, its coordinates are added to the pixels and divided by 255.0
  128. * \param u will contain calculated x value
  129. * \param v will contain calculated y value
  130. */
  131. void computeUV(tr2_object_texture_vert_t *st, float *u, float *v);
  132. /*!
  133. * \brief Get number of bump maps in loaded pak
  134. * \returns number of bump maps
  135. */
  136. int getBumpMapCount();
  137. void getColor(int index, float color[4]);
  138. tr2_version_type getEngine();
  139. /*!
  140. * \brief Get the collision sphere for a mesh
  141. * \param meshIndex mesh index
  142. * \param center will be filled with center coordinates, not NULL
  143. * \param radius will be filled with radius, not NULL
  144. */
  145. void getMeshCollisionInfo(unsigned int meshIndex,
  146. float center[3], float *radius);
  147. /*!
  148. * \brief Get SIGNED mesh count (TR encoded < 0 errors)
  149. * \returns signed mesh count
  150. */
  151. int getMeshCount();
  152. /*!
  153. * \brief This method is made to let you fill arrays or
  154. * create single faces. There may be an allocatin version that
  155. * passes back arrays later.
  156. * Returns Quads/Rects as 2 triangles,
  157. * because returning quads would be too trivial :)
  158. * \param meshIndex mesh index
  159. * \param faceIndex face index
  160. * \param index allocated RGBA
  161. * \param color allocated RGBA
  162. * \fixme This method interface may change later
  163. */
  164. void getMeshColoredRectangle(unsigned int meshIndex,
  165. unsigned int faceIndex,
  166. int index[6], float color[4]);
  167. /*!
  168. * \brief This method is made to let you fill arrays or
  169. * create single faces. There may be an allocating version that
  170. * passes back arrays later.
  171. * \param meshIndex mesh index
  172. * \param faceIndex face index
  173. * \param index allocated RGBA
  174. * \param color allocated RGBA
  175. * \fixme This method interface may change later
  176. */
  177. void getMeshColoredTriangle(unsigned int meshIndex,
  178. unsigned int faceIndex,
  179. int index[3], float color[4]);
  180. /*!
  181. * \brief This method is made to let you fill arrays or
  182. * create single faces. There may be an allocatin version that
  183. * passes back arrays later.
  184. * Returns Quads/Rects as 2 triangles,
  185. * because returning quads would be too trivial :)
  186. * \param meshIndex mesh index
  187. * \param faceIndex face index
  188. * \param index allocated
  189. * \param st allocated
  190. * \param texture allocated
  191. * \param transparency allocated
  192. * \fixme This method interface may change later
  193. */
  194. void getMeshTexturedRectangle(unsigned int meshIndex,
  195. unsigned int faceIndex,
  196. int index[6], float st[12], int *texture,
  197. unsigned short *transparency);
  198. /*!
  199. * \brief This method is made to let you fill arrays or
  200. * create single faces. There may be an allocatin version that
  201. * passes back arrays later.
  202. * \param meshIndex mesh index
  203. * \param faceIndex face index
  204. * \param index allocated
  205. * \param st allocated
  206. * \param texture allocated
  207. * \param transparency allocated
  208. * \fixme This method interface may change later
  209. */
  210. void getMeshTexturedTriangle(unsigned int meshIndex,
  211. unsigned int faceIndex,
  212. int index[3], float st[6], int *texture,
  213. unsigned short *transparency);
  214. /*!
  215. * \brief Get face counts for a given mesh.
  216. *
  217. * \todo This method interface may change later...
  218. * \param meshIndex mesh index
  219. * \returns number of textured triangles in mesh
  220. */
  221. int getMeshTexturedTriangleCount(unsigned int meshIndex);
  222. /*!
  223. * \brief Get face counts for a given mesh.
  224. * \param meshIndex mesh index
  225. * \returns number of colored triangles in mesh
  226. */
  227. int getMeshColoredTriangleCount(unsigned int meshIndex);
  228. /*!
  229. * \brief Get face counts for a given mesh.
  230. * \param meshIndex mesh index
  231. * \returns number of textured rectangles in mesh
  232. */
  233. int getMeshTexturedRectangleCount(unsigned int meshIndex);
  234. /*!
  235. * \brief Get face counts for a given mesh.
  236. * \returns number if colored rectangles in mesh
  237. */
  238. int getMeshColoredRectangleCount(unsigned int meshIndex);
  239. /*!
  240. * \brief Get vertex, normal and color arrays for a mesh
  241. * \param meshIndex mesh index
  242. * \param vertexCount will be set to length of vertex array
  243. * \param verts will be set to allocated vertex array (XYX)
  244. * \param normalCount will be set to length of normal array
  245. * \param norms will be set to allocated normal array (IJK)
  246. * \param colorCount will be set to length of color array
  247. * \param colors will be set to allocated color array (I)
  248. */
  249. void getMeshVertexArrays(unsigned int meshIndex,
  250. unsigned int *vertexCount, float **verts,
  251. unsigned int *normalCount, float **norms,
  252. unsigned int *colorCount, float **colors);
  253. /*!
  254. * \brief Get a single collision box from room (unified)
  255. * \param roomIndex room index
  256. * \param index index of box in room
  257. * \param xyzA will contain first corner of box
  258. * \param xyzB will contain second corner of box
  259. * \param xyzC will contain third corner of box
  260. * \param xyzD will contain fourth corner of box
  261. * \returns 0 on success, < 0 on error
  262. */
  263. int getRoomBox(unsigned int roomIndex, unsigned int index,
  264. float *xyzA, float *xyzB, float *xyzC, float *xyzD);
  265. /*!
  266. * \brief Get number of collision boxes in room (unified)
  267. * \param roomIndex room index
  268. * \returns number of collision boxes in room
  269. */
  270. unsigned int getRoomBoxCount(unsigned int roomIndex);
  271. void getRoomInfo(unsigned int index,
  272. unsigned int *flags, float pos[3],
  273. float bboxMin[3], float bboxMax[3]);
  274. /*!
  275. * \brief Get a single light from a room (unified)
  276. * \param roomIndex valid room index
  277. * \param index valid light index in room
  278. * \param pos allocated, will contain position
  279. * \param color allocated, will contain color
  280. * \param dir allocated, will contain direction
  281. * \param attenuation will contain attenuation
  282. * \param cutoffAngle will contain cutoff angle
  283. * \param type will contain type
  284. * \param flags will contain flags
  285. * \returns 0 on success, < 0 on error
  286. */
  287. int getRoomLight(unsigned int roomIndex, unsigned int index,
  288. float pos[4], float color[4], float dir[3],
  289. float *attenuation, float *cutoffAngle,
  290. unsigned int *type, unsigned int *flags);
  291. /*!
  292. * \brief Get number of lights in room (unified)
  293. * \param roomIndex room index
  294. * \returns number of lights in room
  295. */
  296. unsigned int getRoomLightCount(unsigned int roomIndex);
  297. /*!
  298. * \brief Get a single model info from a room
  299. * \param roomIndex valid room index
  300. * \param index valid model index in room
  301. * \param modelIndex will contain starting mesh
  302. * \param pos will contain pos
  303. * \param yaw will contain yaw angle
  304. * \returns 0 on success, < 0 on error
  305. */
  306. int getRoomModel(unsigned int roomIndex, unsigned int index,
  307. int *modelIndex, float pos[3], float *yaw);
  308. /*!
  309. * \brief Get number of room models in room (unified)
  310. * \param roomIndex room index
  311. * \returns number of room models in room
  312. */
  313. unsigned int getRoomModelCount(unsigned int roomIndex);
  314. /*!
  315. * \brief Get a single portal from room (unified)
  316. * \param roomIndex valid room index
  317. * \param index valid portal index in room
  318. * \param adjoiningRoom will contain adjoining room index
  319. * \param normal allocated, will contain normal vector
  320. * \param vertices allocated, will contain vertices
  321. * \returns 0 on success, < 0 on error
  322. */
  323. int getRoomPortal(unsigned int roomIndex, unsigned int index,
  324. int *adjoiningRoom, float normal[3], float vertices[12]);
  325. /*!
  326. * \brief Get number of portals from room (unified)
  327. * \param roomIndex room index
  328. * \returns number of portals from room
  329. */
  330. unsigned int getRoomPortalCount(unsigned int roomIndex);
  331. /*!
  332. * \brief Get rectangle data with texCoords for non-matching
  333. * vertex/uv for each vertex in TombRaider room (unified)
  334. * \param roomIndex valid room index
  335. * \param rectangleIndex rectangle index in room
  336. * \param indices will contain indices
  337. * \param texCoords will contain texCoords
  338. * \param texture will contain texture
  339. * \param flags will contain flags
  340. */
  341. void getRoomRectangle(unsigned int roomIndex, unsigned int rectangleIndex,
  342. unsigned int *indices, float *texCoords, int *texture,
  343. unsigned int *flags);
  344. /*!
  345. * \brief Get number of rectangles from room (unified)
  346. * \param roomIndex room index
  347. * \returns number of rectangles from room
  348. */
  349. unsigned int getRoomRectangleCount(unsigned int roomIndex);
  350. /*!
  351. * \brief Get a single sector from room (unified)
  352. * \param roomIndex room index
  353. * \param index sector index
  354. * \param flags will contain flags
  355. * \param ceiling will contain ceiling
  356. * \param floor will contain floor
  357. * \param floorDataIndex will contain floor data index
  358. * \param boxIndex will contain boxIndex
  359. * \param roomBelow will contain roomBelow
  360. * \param roomAbove will contain roomAbove
  361. * \return 0 on success, < 0 on error
  362. */
  363. int getRoomSector(unsigned int roomIndex, unsigned int index,
  364. unsigned int *flags, float *ceiling, float *floor,
  365. int *floorDataIndex, int *boxIndex,
  366. int *roomBelow, int *roomAbove);
  367. /*!
  368. * \brief Get number of sectors in room (unified)
  369. * \param roomIndex room index
  370. * \param zSectorsCount will contain width of sector list
  371. * \param xSectorsCount will contain height of sector list
  372. * \returns number of sectors in room
  373. */
  374. unsigned int getRoomSectorCount(unsigned int roomIndex,
  375. unsigned int *zSectorsCount,
  376. unsigned int *xSectorsCount);
  377. void getRoomSprite(unsigned int roomIndex, unsigned int index,
  378. float scale, int *texture,
  379. float *pos, float *vertices, float *texcoords);
  380. /*!
  381. * \brief Get number of sprites in room (unified)
  382. * \param roomIndex room index
  383. * \returns number of sprites in room
  384. */
  385. unsigned int getRoomSpriteCount(unsigned int roomIndex);
  386. /*!
  387. * \brief Gets triangle data with texCoords for non-matching
  388. * vertex/uv for each vertex in TombRaider room (unified)
  389. * \param roomIndex room index
  390. * \param triangleIndex triangle index
  391. * \param indices will contain indices
  392. * \param texCoords will contain texCoords
  393. * \param texture will contain texture
  394. * \param flags will contain flags
  395. */
  396. void getRoomTriangle(unsigned int roomIndex, unsigned int triangleIndex,
  397. unsigned int *indices, float *texCoords, int *texture,
  398. unsigned int *flags);
  399. /*!
  400. * \brief Gets triangle data with texCoords for non-matching
  401. * vertex/uv for each vertex in TombRaider room.
  402. *
  403. * This is used with vertices, colors, etc. to do partial array
  404. * rendering, since the texcoords will never match vertives
  405. * (Tomb Raider is textile based).
  406. * \param index room index
  407. * \param textureOffset texture offset
  408. * \param count will contain count
  409. * \param indices will contain indices
  410. * \param texCoords will contain texCoords
  411. * \param textures will contain textures
  412. * \param flags will contain flags
  413. */
  414. void getRoomTriangles(unsigned int index, int textureOffset,
  415. unsigned int *count, unsigned int **indices,
  416. float **texCoords, int **textures,
  417. unsigned int **flags);
  418. /*!
  419. * \brief Gets triangle data with duplicated vertex/color/normal
  420. * data for each face vertex to match the textile based texcoords.
  421. *
  422. * This uses more memory, but lets you do direct array rendering
  423. * with OpenGL, D3D, etc.
  424. * \param roomIndex room index
  425. * \param textureOffset texture offset
  426. * \param count will contain count
  427. * \param indices will contain indices
  428. * \param vertices will contain vertices
  429. * \param texCoords will contain texCoords
  430. * \param colors will contain colors
  431. * \param textures will contain textures
  432. * \param flags will contain flags
  433. */
  434. void getRoomTriangles(unsigned int roomIndex, int textureOffset,
  435. unsigned int *count,
  436. unsigned int **indices, float **vertices,
  437. float **texCoords, float **colors,
  438. int **textures, unsigned int **flags);
  439. /*!
  440. * \brief Get number of triangles from room (unified)
  441. * \param roomIndex room index
  442. * \returns number of triangles from room
  443. */
  444. unsigned int getRoomTriangleCount(unsigned int roomIndex);
  445. /*!
  446. * \brief Gets vertex position and color
  447. * \param roomIndex room index
  448. * \param vertexIndex vertex index
  449. * \param xyz will contain vertex position, has to be allocated
  450. * \param rgba will contain vertex color, has to be allocated
  451. */
  452. void getRoomVertex(unsigned int roomIndex, unsigned int vertexIndex,
  453. float *xyz, float *rgba);
  454. /*!
  455. * \brief Get allocated vertex and color arrays and their element counts (unified)
  456. * \param roomIndex valid room index
  457. * \param vertexCount will contain vertex array length
  458. * \param vertices will contain vertex array
  459. * \param normalCount will contain normal array length
  460. * \param normals will contain normal array
  461. * \param colorCount will contain color array length
  462. * \param colors will contain color array
  463. */
  464. void getRoomVertexArrays(unsigned int roomIndex,
  465. unsigned int *vertexCount, float **vertices,
  466. unsigned int *normalCount, float **normals,
  467. unsigned int *colorCount, float **colors);
  468. /*!
  469. * \brief Get number of lights in room (unified)
  470. * \param roomIndex room index
  471. * \returns number of lights in room
  472. */
  473. unsigned int getRoomVertexCount(unsigned int roomIndex);
  474. /*!
  475. * \brief Get sky mesh ID
  476. * \returns moveable id of sky mesh or -1 if none
  477. */
  478. int getSkyModelId();
  479. void getSprites();
  480. /*!
  481. * \brief Get a copy of a sound sample and its byte size
  482. * \param index sound sample index
  483. * \param bytes will contain byte size of sound sample
  484. * \param data will contain sound sample
  485. */
  486. void getSoundSample(unsigned int index,
  487. unsigned int *bytes, unsigned char **data);
  488. /*!
  489. * \brief Get number of loaded sound samples
  490. * \returns number of sound samples loaded
  491. */
  492. unsigned int getSoundSamplesCount();
  493. /*!
  494. * \brief Check if a mesh is valid
  495. * \param index mesh index (?)
  496. * \returns true if mesh is valid
  497. */
  498. bool isMeshValid(int index);
  499. /*!
  500. * \brief Check if a room is valid (TRC support)
  501. * \param index room index
  502. * \returns true if room is valid
  503. */
  504. bool isRoomValid(int index);
  505. /*!
  506. * \brief Load an external sound pak for TR2 and TR3
  507. * \param filename pak to load
  508. * \returns < 0 on error
  509. */
  510. int loadSFX(char *filename);
  511. void reset();
  512. void setDebug(bool toggle);
  513. /*!
  514. * \brief Sets lighting factor for each vertex color per room in TR3 paks
  515. * \param f new lighting factor
  516. */
  517. void setRoomVertexLightingFactor(float f);
  518. /*!
  519. * \brief Set scaling for sprite texel alignment, etc.
  520. * \param f new scaling factor
  521. */
  522. void setTexelScalingFactor(float f);
  523. private:
  524. void extractMeshes(unsigned char *mesh_data,
  525. unsigned int num_mesh_pointers,
  526. unsigned int *mesh_pointers);
  527. int Fread(void *buffer, size_t size, size_t count, FILE *f);
  528. /*!
  529. * \brief Get a copy of the sound samples
  530. * \param bytes will contain size of sound samples
  531. * \param data will contain sound samples themselves
  532. */
  533. void getRiffData(unsigned int *bytes, unsigned char **data);
  534. /*!
  535. * \brief Get a copy of a TR4 sound sample
  536. * \param index sound sample index
  537. * \param bytes will contain length of sound sample
  538. * \param data will contain sound sample itself
  539. */
  540. void getRiffDataTR4(unsigned int index,
  541. unsigned int *bytes, unsigned char **data);
  542. /*!
  543. * \brief Get an array of offsets for a contiguous RIFF data stream in chunks.
  544. *
  545. * Offsets will be allocated with enough space to hold expected
  546. * number of offsets. (Should be known number, otherwise not all RIFFs
  547. * will be parsed.)
  548. * \param riffData riff data
  549. * \param riffDataBytes length of riff data
  550. * \param offsets will contain offsets
  551. * \param numOffsets known number
  552. * \returns number of RIFFs found
  553. */
  554. int getRiffOffsets(unsigned char *riffData, unsigned int riffDataBytes,
  555. unsigned int **offsets, unsigned int numOffsets);
  556. /*!
  557. * \brief Makes a 32bit RGBA image from a textile.
  558. *
  559. * This handles all selection and conversion, including
  560. * alpha layering flags, now.
  561. * \param texture valid index into textile list
  562. * \returns 32bit RGBA image or NULL on error
  563. */
  564. unsigned char *getTexTile(int texture);
  565. /*!
  566. * \brief Loads a TR5 pak into memory.
  567. * \param f valid FILE
  568. * \returns 0 on success, < 0 on error
  569. */
  570. int loadTR5(FILE *f);
  571. static void print(const char *methodName, const char *s, ...) __attribute__((format(printf, 2, 3)));
  572. void printDebug(const char *methodName, const char *s, ...) __attribute__((format(printf, 3, 4)));
  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