Now we're climbing up the ladder

This commit is contained in:
jordan4ibanez 2023-11-26 05:10:04 -05:00
parent 9483f17816
commit aad38e8a49
2 changed files with 32 additions and 11 deletions

6
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,6 @@
{
"files.associations": {
"iostream": "cpp",
"fstream": "cpp"
}
}

View File

@ -3,9 +3,13 @@
#include "IAnimatedMesh.h" #include "IAnimatedMesh.h"
#include "IReadFile.h" #include "IReadFile.h"
#include "path.h" #include "path.h"
#include "json/json.hpp" #include <iostream>
#include "os.h" #include "os.h"
#include "string.h"
#include "json/json.hpp"
#include <array>
using json = nlohmann::json; using json = nlohmann::json;
using namespace nlohmann::literals;
namespace irr namespace irr
{ {
@ -38,6 +42,10 @@ bool CB3DJSONMeshFileLoader::isALoadableFileExtension(
return core::hasFileExtension(fileName, "json"); return core::hasFileExtension(fileName, "json");
} }
void parseModel(json model) {
}
IAnimatedMesh* CB3DJSONMeshFileLoader::createMesh(io::IReadFile* file) { IAnimatedMesh* CB3DJSONMeshFileLoader::createMesh(io::IReadFile* file) {
// Less than zero? What is this file a black hole? // Less than zero? What is this file a black hole?
@ -57,22 +65,29 @@ IAnimatedMesh* CB3DJSONMeshFileLoader::createMesh(io::IReadFile* file) {
// std::string err {}; // std::string err {};
// std::string warn {}; // std::string warn {};
// Try changing the type from auto to see why it's auto. // auto buffer = std::make_unique<char[]>(file->getSize());
auto buffer = std::make_unique<char[]>(file->getSize()); char* buffer = new char[file->getSize()];
// Now we read that dang JSON. // Now we read that dang JSON.
file->read(buffer.get(), file->getSize()); file->read(buffer, file->getSize());
const json data = json::parse("{\"hi\": 1}"); char* clone = strdup(buffer);
const auto test = data["hi"]; // Dereference then borrow it.
printf("is this a number? "); json data = json::parse(&*clone);
println(boolToString(test.is_number()));
println(test.dump().c_str()); if (!data.contains("format") || !data["format"].is_string() || data["format"] != "BB3DJSON") {
os::Printer::log("No format in B3D JSON!", ELL_WARNING);
return nullptr;
}
if (!data.contains("version") || !data["version"].is_number_integer() || data["version"] != 1) {
os::Printer::log("Wrong version in B3D JSON!", ELL_WARNING);
return nullptr;
}
parseModel(data);
//! I'm sure this isn't a horrible idea!
return nullptr; return nullptr;
} }