Open Source Tomb Raider Engine
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

LoaderTR3.cpp 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. loadPaletteTextiles();
  18. file.seek(file.tell() + 4); // Unused value?
  19. loadRooms();
  20. loadFloorData();
  21. loadMeshes();
  22. loadMoveables();
  23. loadStaticMeshes();
  24. loadSprites();
  25. loadCameras();
  26. loadSoundSources();
  27. loadBoxesOverlapsZones();
  28. loadAnimatedTextures();
  29. loadTextures();
  30. loadItems();
  31. file.seek(file.tell() + 8192); // Skip Light map, only for 8bit coloring
  32. loadCinematicFrames();
  33. loadDemoData();
  34. loadSoundMap();
  35. loadSoundDetails();
  36. loadSampleIndices();
  37. loadExternalSoundFile(f);
  38. // TODO load TR3 PC version CDAUDIO.WAD file
  39. // TODO load TR3 Mac version CDAudio.db and WAV files
  40. return 0;
  41. }
  42. void LoaderTR3::loadRoomLights() {
  43. int16_t intensity1 = file.read16();
  44. int16_t intensity2 = file.read16();
  45. uint16_t numLights = file.readU16();
  46. for (unsigned int l = 0; l < numLights; l++) {
  47. // Position of light, in world coordinates
  48. int32_t x = file.read32();
  49. int32_t y = file.read32();
  50. int32_t z = file.read32();
  51. uint16_t intensity1 = file.readU16();
  52. uint16_t intensity2 = file.readU16(); // Almost always equal to intensity1
  53. uint32_t fade1 = file.readU32(); // Falloff value?
  54. uint32_t fade2 = file.readU32(); // Falloff value?
  55. // TODO store light somewhere
  56. }
  57. }
  58. void LoaderTR3::loadRoomDataEnd(int16_t& alternateRoom, unsigned int& roomFlags) {
  59. LoaderTR2::loadRoomDataEnd(alternateRoom, roomFlags);
  60. uint8_t r = file.readU8();
  61. uint8_t g = file.readU8();
  62. uint8_t b = file.readU8();
  63. // TODO store room-light color (?) somewhere
  64. }