mirror of
https://github.com/vonhyou/ray-tracer-comp371.git
synced 2025-08-13 17:08:04 +00:00
move output factors to Scene class
This commit is contained in:
parent
8550abf235
commit
baea2db514
2 changed files with 41 additions and 0 deletions
18
src/Scene.cc
Normal file
18
src/Scene.cc
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
#include "Scene.h"
|
||||||
|
|
||||||
|
Scene::Scene(const nlohmann::json &output) {
|
||||||
|
for (auto i = output.begin(); i != output.end(); ++i) {
|
||||||
|
if (i->contains("filename")) {
|
||||||
|
this->name = (*i)["filename"].get<string>();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i->contains("size")) {
|
||||||
|
this->width = (*i)["size"].at(0).get<int>();
|
||||||
|
this->height = (*i)["size"].at(1).get<int>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
string Scene::getName() { return this->name; }
|
||||||
|
int Scene::getWidth() { return this->width; }
|
||||||
|
int Scene::getHeight() { return this->height; }
|
23
src/Scene.h
Normal file
23
src/Scene.h
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
#ifndef SCENE_H_
|
||||||
|
#define SCENE_H_
|
||||||
|
|
||||||
|
#include "../external/json.hpp"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
using std::string;
|
||||||
|
|
||||||
|
class Scene {
|
||||||
|
public:
|
||||||
|
Scene(const nlohmann::json &);
|
||||||
|
string getName();
|
||||||
|
int getWidth();
|
||||||
|
int getHeight();
|
||||||
|
|
||||||
|
private:
|
||||||
|
string name;
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // !SCENE_H_
|
Loading…
Add table
Add a link
Reference in a new issue