CVelocityRandom.cpp 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #include "CVelocityRandom.h"
  2. #include "../../../../core.h"
  3. using namespace wp::core::Objects::Particles::Initializers;
  4. CVelocityRandom* CVelocityRandom::fromJSON (json data, irr::u32 id)
  5. {
  6. json::const_iterator min_it = data.find ("min");
  7. json::const_iterator max_it = data.find ("max");
  8. if (min_it == data.end ())
  9. {
  10. throw std::runtime_error ("Velocityrandom initializer must have a minimum value");
  11. }
  12. if (max_it == data.end ())
  13. {
  14. throw std::runtime_error ("Velocityrandom initializer must have a maximum value");
  15. }
  16. return new CVelocityRandom (
  17. id,
  18. wp::core::ato3vf (*min_it),
  19. wp::core::ato3vf (*max_it)
  20. );
  21. }
  22. CVelocityRandom::CVelocityRandom (irr::u32 id, irr::core::vector3df min, irr::core::vector3df max) :
  23. CInitializer (id, "velocityrandom"),
  24. m_min (min),
  25. m_max (max)
  26. {
  27. }
  28. irr::core::vector3df* CVelocityRandom::getMinimum ()
  29. {
  30. return &this->m_min;
  31. }
  32. irr::core::vector3df* CVelocityRandom::getMaximum ()
  33. {
  34. return &this->m_max;
  35. }