scene.cpp 757 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #include "scene.h"
  2. #include "project.h"
  3. #include "../fs/utils.h"
  4. using namespace wp::core;
  5. scene::scene (scenes::camera* camera) :
  6. m_camera (camera)
  7. {
  8. }
  9. scene* scene::fromFile (irr::io::path filename)
  10. {
  11. json content = json::parse (wp::fs::utils::loadFullFile (filename));
  12. json::const_iterator camera_it = content.find ("camera");
  13. if (camera_it == content.end ())
  14. {
  15. throw std::runtime_error ("Scenes must have a defined camera");
  16. }
  17. return new scene (
  18. scenes::camera::fromJSON (*camera_it)
  19. );
  20. }
  21. project* scene::getProject ()
  22. {
  23. return this->m_project;
  24. }
  25. void scene::setProject (project* project)
  26. {
  27. this->m_project = project;
  28. }
  29. scenes::camera* scene::getCamera ()
  30. {
  31. return this->m_camera;
  32. }