Core.cpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #include <irrlicht/irrlicht.h>
  2. #include "Core.h"
  3. irr::core::vector3df WallpaperEngine::Core::ato3vf(const char *str)
  4. {
  5. irr::f32 x = irr::core::fast_atof (str, &str); while (*str == ' ') str ++;
  6. irr::f32 y = irr::core::fast_atof (str, &str); while (*str == ' ') str ++;
  7. irr::f32 z = irr::core::fast_atof (str, &str);
  8. return irr::core::vector3df (x, y, z);
  9. }
  10. irr::core::vector2df WallpaperEngine::Core::ato2vf (const char *str)
  11. {
  12. irr::f32 x = irr::core::fast_atof (str, &str); while (*str == ' ') str ++;
  13. irr::f32 y = irr::core::fast_atof (str, &str);
  14. return irr::core::vector2df (x, y);
  15. }
  16. irr::core::vector3df WallpaperEngine::Core::ato3vf (const std::string& str)
  17. {
  18. return WallpaperEngine::Core::ato3vf (str.c_str ());
  19. }
  20. irr::core::vector2df WallpaperEngine::Core::ato2vf (const std::string& str)
  21. {
  22. return WallpaperEngine::Core::ato2vf (str.c_str ());
  23. }
  24. irr::video::SColorf WallpaperEngine::Core::atoSColorf (const char *str)
  25. {
  26. irr::core::vector3df vector = WallpaperEngine::Core::ato3vf (str);
  27. return irr::video::SColorf (
  28. vector.X,
  29. vector.Y,
  30. vector.Z
  31. );
  32. }
  33. irr::video::SColorf WallpaperEngine::Core::atoSColorf (const std::string& str)
  34. {
  35. return WallpaperEngine::Core::atoSColorf (str.c_str ());
  36. }
  37. irr::video::SColor WallpaperEngine::Core::atoSColor (const char *str)
  38. {
  39. irr::f32 r = irr::core::strtoul10 (str, &str); while (*str == ' ') str ++;
  40. irr::f32 g = irr::core::strtoul10 (str, &str); while (*str == ' ') str ++;
  41. irr::f32 b = irr::core::strtoul10 (str, &str);
  42. return irr::video::SColor (255, r, g, b);
  43. }
  44. irr::video::SColor WallpaperEngine::Core::atoSColor (const std::string& str)
  45. {
  46. return WallpaperEngine::Core::atoSColor (str.c_str ());
  47. }