Add some very fancy tooling

This commit is contained in:
jordan4ibanez 2023-11-26 09:51:43 -05:00
parent 2a16c10eba
commit 9f93cf312f
2 changed files with 32 additions and 15 deletions

View File

@ -2,6 +2,8 @@
"files.associations": { "files.associations": {
"iostream": "cpp", "iostream": "cpp",
"fstream": "cpp", "fstream": "cpp",
"new": "cpp" "new": "cpp",
"unordered_map": "cpp",
"unordered_set": "cpp"
} }
} }

View File

@ -48,17 +48,15 @@ bool CB3DJSONMeshFileLoader::isALoadableFileExtension(
return core::hasFileExtension(fileName, "json"); return core::hasFileExtension(fileName, "json");
} }
// Returns if errored. /**
bool parseNode(json data, SMeshBuffer* meshBuffer) { * Returns true if failure occurs.
*/
bool grabVec3f(json data, std::string key, irr::core::vector3df& refVec) {
auto position = irr::core::vector3df{0,0,0}; if (data.contains(key) && data[key].is_array() && data[key].size() == 3) {
auto scale = irr::core::vector3df{1,1,1}; auto jsonVec3 = data[key];
auto rotation = irr::core::quaternion{0,0,0,1};
if (data.contains("position") && data["position"].is_array() && data["position"].size() == 3) {
auto positionJSON = data["position"];
int i = 0; int i = 0;
for (auto reference = positionJSON.begin(); reference != positionJSON.end(); ++reference) { for (auto reference = jsonVec3.begin(); reference != jsonVec3.end(); ++reference) {
auto value = *reference; auto value = *reference;
if (!value.is_number_integer()) { if (!value.is_number_integer()) {
os::Printer::log("Error, position in NODE must be an array of 3 integers!", ELL_WARNING); os::Printer::log("Error, position in NODE must be an array of 3 integers!", ELL_WARNING);
@ -66,22 +64,39 @@ bool parseNode(json data, SMeshBuffer* meshBuffer) {
} }
switch (i){ switch (i){
case 0: case 0:
position.X = value; refVec.X = value;
println(std::string("x is: ").append(std::to_string(position.X)).c_str());
break; break;
case 1: case 1:
position.Y = value; refVec.Y = value;
break; break;
case 2: case 2:
position.Z = value; refVec.Z = value;
break; break;
} }
i++; i++;
} }
} else { } else {
os::Printer::log("Error, position in NODE must be an array of 3 integers!", ELL_WARNING); const auto stringWarning = std::string("Error, ").append(key).append(" in NODE must be an array of 3 integers!");
os::Printer::log(stringWarning.c_str(), ELL_WARNING);
return true; return true;
} }
return false;
}
// Returns if errored.
bool parseNode(json data, SMeshBuffer* meshBuffer) {
auto position = irr::core::vector3df{0,0,0};
auto scale = irr::core::vector3df{1,1,1};
auto rotation = irr::core::quaternion{0,0,0,1};
//!FIXME: These should really be functions.
return false; return false;
} }