Object.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #include <irrlicht/irrlicht.h>
  2. #include <iostream>
  3. #include <fstream>
  4. #include <nlohmann/json.hpp>
  5. #include "Object.h"
  6. using json = nlohmann::json;
  7. Object::Object (json json_data)
  8. {
  9. json::const_iterator angles = json_data.find ("angles");
  10. json::const_iterator image = json_data.find ("image");
  11. json::const_iterator id = json_data.find ("id");
  12. json::const_iterator visible = json_data.find ("visible");
  13. json::const_iterator model = json_data.find ("model");
  14. if (angles != json_data.end () && angles.value ().is_null() == false)
  15. {
  16. this->m_angles = json_data ["angles"];
  17. }
  18. if (image != json_data.end () && image.value ().is_null() == false)
  19. {
  20. this->m_image = json_data ["image"];
  21. }
  22. if (id != json_data.end () && id.value ().is_null() == false)
  23. {
  24. this->m_id = json_data ["id"];
  25. }
  26. if (visible != json_data.end () && visible.value ().is_null() == false)
  27. {
  28. this->m_visible = json_data ["visible"];
  29. }
  30. else
  31. {
  32. this->m_visible = true;
  33. }
  34. if (model != json_data.end () && model.value ().is_null() == false)
  35. {
  36. this->m_model = json_data ["model"];
  37. }
  38. }