Clone of Bael'Zharon's Respite @ https://github.com/boardwalk/bzr

ParticleEmitter.cpp 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*
  2. * Bael'Zharon's Respite
  3. * Copyright (C) 2014 Daniel Skorupski
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along
  15. * with this program; if not, write to the Free Software Foundation, Inc.,
  16. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  17. */
  18. #include "resource/ParticleEmitter.h"
  19. #include "BinReader.h"
  20. #include "util.h"
  21. enum class EmitterType : uint32_t
  22. {
  23. kUnknown = 0x0000,
  24. kBirthratePerSec = 0x0001,
  25. kBirthratePerMeter = 0x0002
  26. };
  27. enum class ParticleType : uint32_t
  28. {
  29. kUnknown = 0x0000,
  30. kStill = 0x0001,
  31. kLocalVelocity = 0x0002,
  32. kParabolicLVGA = 0x0003,
  33. kParabolicLVGAGR = 0x0004,
  34. kSwarm = 0x0005,
  35. kExplode = 0x0006,
  36. kImplode = 0x0007,
  37. kParabolicLVLA = 0x0008,
  38. kParabolicLVLALR = 0x0009,
  39. kParabolicGVGA = 0x000a,
  40. kParabolicGVGAGR = 0x000b,
  41. kGlobalVelocity = 0x000c
  42. };
  43. ParticleEmitter::ParticleEmitter(uint32_t id, const void* data, size_t size) : ResourceImpl{id}
  44. {
  45. BinReader reader(data, size);
  46. uint32_t resourceId = reader.readInt();
  47. assert(resourceId == id);
  48. UNUSED(resourceId);
  49. uint32_t unk1 = reader.readInt();
  50. assert(unk1 == 0);
  51. UNUSED(unk1);
  52. uint32_t emitterType = reader.readInt();
  53. assert(emitterType >= 0x1 && emitterType <= 0x2);
  54. UNUSED(emitterType);
  55. uint32_t particleType = reader.readInt();
  56. assert(particleType >= 0x1 && particleType <= 0xc);
  57. UNUSED(particleType);
  58. uint32_t gfxobjId = reader.readInt();
  59. assert(gfxobjId == 0 || (gfxobjId & 0xFF000000) == static_cast<uint32_t>(ResourceType::kModel));
  60. UNUSED(gfxobjId);
  61. uint32_t hwGfxobjId = reader.readInt();
  62. assert(hwGfxobjId == 0 || (hwGfxobjId & 0xFF000000) == static_cast<uint32_t>(ResourceType::kModel));
  63. UNUSED(hwGfxobjId);
  64. /*birthrate*/ reader.readDouble();
  65. /*maxParticles*/ reader.readInt();
  66. /*initialParticles*/ reader.readInt();
  67. /*totalParticles*/ reader.readInt();
  68. /*totalSeconds*/ reader.readDouble();
  69. /*lifespanRand*/ reader.readDouble();
  70. /*lifespan*/ reader.readDouble();
  71. // sorting sphere
  72. /*r*/ reader.readFloat();
  73. glm::vec3 offsetDir;
  74. read(reader, offsetDir);
  75. /*minOffset*/ reader.readFloat();
  76. /*maxOffset*/ reader.readFloat();
  77. glm::vec3 a;
  78. read(reader, a);
  79. glm::vec3 b;
  80. read(reader, b);
  81. glm::vec3 c;
  82. read(reader, c);
  83. /*minA*/ reader.readFloat();
  84. /*maxA*/ reader.readFloat();
  85. /*minB*/ reader.readFloat();
  86. /*maxB*/ reader.readFloat();
  87. /*minC*/ reader.readFloat();
  88. /*maxC*/ reader.readFloat();
  89. /*scaleRand*/ reader.readFloat();
  90. /*startScale*/ reader.readFloat();
  91. /*finalScale*/ reader.readFloat();
  92. /*transRand*/ reader.readFloat();
  93. /*startTrans*/ reader.readFloat();
  94. /*finalTrans*/ reader.readFloat();
  95. assert(reader.remaining() == 0);
  96. }