ParticleEmitterDictionary.cpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * Copyright (C) 2022 The V-Gears Team
  3. *
  4. * This file is part of V-Gears
  5. *
  6. * V-Gears is free software: you can redistribute it and/or modify it under
  7. * terms of the GNU General Public License as published by the Free Software
  8. * Foundation, version 3.0 (GPLv3) of the License.
  9. *
  10. * V-Gears is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. */
  15. #include <OgreStringConverter.h>
  16. #include "engine/particles/ParticleEmitterDictionary.h"
  17. #include "engine/particles/ParticleEmitter.h"
  18. #include "common/Logger.h"
  19. #include "common/Utilities.h"
  20. namespace ParticleEmitterDictionary{
  21. void EmissionRate::doSet(void* target, const Ogre::String& val){
  22. static_cast<ParticleEmitter*>(target)->SetEmissionRate(
  23. Ogre::StringConverter::parseInt(val)
  24. );
  25. }
  26. void TotalTimeToLive::doSet(void* target, const Ogre::String& val){
  27. static_cast<ParticleEmitter*>(target)->SetEmitTotalTimeToLive(
  28. Ogre::StringConverter::parseReal(val)
  29. );
  30. }
  31. void Direction::doSet(void* target, const Ogre::String& val){
  32. Ogre::StringVector strings = StringTokenise(val);
  33. if (strings.size() == 1){
  34. static_cast<ParticleEmitter*>(target)->SetEmitDirection(
  35. Ogre::StringConverter::parseVector3(strings[0])
  36. );
  37. }
  38. else if (strings.size() > 1){
  39. static_cast<ParticleEmitter*>(target)->SetEmitDirectionRange(
  40. Ogre::StringConverter::parseVector3(strings[0]),
  41. Ogre::StringConverter::parseVector3(strings[1])
  42. );
  43. }
  44. else{
  45. LOG_WARNING(
  46. "The direction of a particle emitter must have at least a value."
  47. );
  48. }
  49. }
  50. }