add JObject
This commit is contained in:
54
src/modules/Archimedes-Modules/Sandbox/JObject.h
Normal file
54
src/modules/Archimedes-Modules/Sandbox/JObject.h
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
#include "pch.hpp"
|
||||||
|
|
||||||
|
#include "Object.h"
|
||||||
|
|
||||||
|
namespace Archimedes {
|
||||||
|
|
||||||
|
using json = nlohmann::json;
|
||||||
|
|
||||||
|
class JObject {
|
||||||
|
|
||||||
|
public:
|
||||||
|
JObject(std::string path) {
|
||||||
|
|
||||||
|
std::ifstream file(path);
|
||||||
|
if (!file.is_open()) goodJSON = false;
|
||||||
|
document = json::parse(file);
|
||||||
|
file.close();
|
||||||
|
templates = document["Templates"];
|
||||||
|
objects = document["Objects"];
|
||||||
|
setup = document["Set Up"];
|
||||||
|
cameras = document["Cameras"];
|
||||||
|
lights = document["Lights"];
|
||||||
|
actions = document["Actions"];
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isValid() const { return goodJSON; }
|
||||||
|
|
||||||
|
std::vector<Object> buildObjects() {
|
||||||
|
|
||||||
|
std::vector<Object> v;
|
||||||
|
|
||||||
|
|
||||||
|
for (json::const_iterator it = templates.cbegin(); it != templates.cend(); it++)
|
||||||
|
{
|
||||||
|
json element = *it;
|
||||||
|
std::string name = element["name"];
|
||||||
|
std::string type = element["type"];
|
||||||
|
if (type == "CIRCLE") {}
|
||||||
|
if (type == "SQUARE") {}
|
||||||
|
if (type == "RECTANGLE") {}
|
||||||
|
if (type == "POLYGON") {}
|
||||||
|
if (type == "TEXT") {}
|
||||||
|
}
|
||||||
|
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
bool goodJSON = true;
|
||||||
|
|
||||||
|
json document, templates, objects, setup, cameras, lights, actions;
|
||||||
|
};
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user