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.

LoaderTR3.cpp 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*!
  2. * \file src/loader/LoaderTR3.cpp
  3. * \brief TR3 level file loader
  4. *
  5. * \author xythobuz
  6. */
  7. #include "global.h"
  8. #include "loader/LoaderTR3.h"
  9. int LoaderTR3::load(std::string f) {
  10. if (file.open(f) != 0) {
  11. return 1; // Could not open file
  12. }
  13. uint32_t version = file.readU32();
  14. if ((version != 0xFF080038) && (version != 0xFF180038)) {
  15. return 2; // Not a TR3 level?!
  16. }
  17. loadPalette();
  18. loadTextures();
  19. file.seek(file.tell() + 4); // Unused value?
  20. loadRooms();
  21. loadFloorData();
  22. loadMeshes();
  23. loadMoveables();
  24. loadStaticMeshes();
  25. loadSprites();
  26. loadCameras();
  27. loadSoundSources();
  28. loadBoxesOverlapsZones();
  29. loadAnimatedTextures();
  30. loadTextiles();
  31. loadItems();
  32. file.seek(file.tell() + 8192); // Skip Light map, only for 8bit coloring
  33. loadCinematicFrames();
  34. loadDemoData();
  35. loadSoundMap();
  36. loadSoundDetails();
  37. loadSampleIndices();
  38. loadExternalSoundFile(f);
  39. // TODO load TR3 PC version CDAUDIO.WAD file
  40. // TODO load TR3 Mac version CDAudio.db and WAV files
  41. return 0;
  42. }
  43. void LoaderTR3::loadRoomLights() {
  44. int16_t intensity1 = file.read16();
  45. int16_t intensity2 = file.read16();
  46. uint16_t numLights = file.readU16();
  47. for (unsigned int l = 0; l < numLights; l++) {
  48. // Position of light, in world coordinates
  49. int32_t x = file.read32();
  50. int32_t y = file.read32();
  51. int32_t z = file.read32();
  52. uint16_t intensity1 = file.readU16();
  53. uint16_t intensity2 = file.readU16(); // Almost always equal to intensity1
  54. uint32_t fade1 = file.readU32(); // Falloff value?
  55. uint32_t fade2 = file.readU32(); // Falloff value?
  56. // TODO store light somewhere
  57. }
  58. }
  59. void LoaderTR3::loadRoomDataEnd(int16_t& alternateRoom, unsigned int& roomFlags) {
  60. LoaderTR2::loadRoomDataEnd(alternateRoom, roomFlags);
  61. uint8_t r = file.readU8();
  62. uint8_t g = file.readU8();
  63. uint8_t b = file.readU8();
  64. // TODO store room-light color (?) somewhere
  65. }