add JObject

This commit is contained in:
2026-02-16 22:41:42 -06:00
parent fda88a906b
commit e9f1f49416

View 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;
};
}