From 42b9658c8d3b975f908078c29b6256b51100cb40 Mon Sep 17 00:00:00 2001 From: jordan4ibanez Date: Tue, 28 Nov 2023 06:08:17 -0500 Subject: [PATCH] Start work on TEXS --- source/Irrlicht/CB3DJSONMeshFileLoader.cpp | 40 ++++++++++++++++++++++ source/Irrlicht/CB3DJSONMeshFileLoader.h | 3 ++ 2 files changed, 43 insertions(+) diff --git a/source/Irrlicht/CB3DJSONMeshFileLoader.cpp b/source/Irrlicht/CB3DJSONMeshFileLoader.cpp index 03925c79..99150d52 100644 --- a/source/Irrlicht/CB3DJSONMeshFileLoader.cpp +++ b/source/Irrlicht/CB3DJSONMeshFileLoader.cpp @@ -1,6 +1,7 @@ #include "CB3DJSONMeshFileLoader.h" #include "coreutil.h" #include "IAnimatedMesh.h" +#include "SB3DStructs.h" #include "S3DVertex.h" #include "SAnimatedMesh.h" #include "SColor.h" @@ -160,6 +161,42 @@ bool parseNode(json data, SMeshBuffer* meshBuffer) { return true; } +/** + * Returns (success, failure reason). + * This is an optional component of B3D. +*/ +std::tuple CB3DJSONMeshFileLoader::readChunkTEXS() { + + // We're checking the root of the JSON structure here. So we can just peak directly into the root. + json texs; + if (JSONDataContainer.contains("TEXS")) { + // We're referencing static memory. + texs = JSONDataContainer["TEXS"]; + } { + // Since it's optional, it succeeds if it's not there. + return {true, nullptr}; + } + + if (texs.contains("textures") && texs["textures"].is_array()) { + + json textureArray = texs["textures"]; + + // t stands for texture. :D Come back next week for more knowledge. + for (auto t = textureArray.begin(); t != textureArray.end(); ++t) { + + // This is a very strange way to do this but I won't complain. + Textures.push_back(SB3dTexture()); + SB3dTexture& B3DTexture = Textures.getLast(); + + + + + + } + } +} + + /** * Returns (success, failure reason). */ @@ -173,6 +210,9 @@ std::tuple CB3DJSONMeshFileLoader::load() { return {false, "Wrong version in B3D JSON! Expected: 1"}; } + // Success, failure reason + std::tuple texturesSuccess = this->readChunkTEXS(); + // return animatedMesh; diff --git a/source/Irrlicht/CB3DJSONMeshFileLoader.h b/source/Irrlicht/CB3DJSONMeshFileLoader.h index d500be59..54b0c835 100644 --- a/source/Irrlicht/CB3DJSONMeshFileLoader.h +++ b/source/Irrlicht/CB3DJSONMeshFileLoader.h @@ -4,6 +4,7 @@ #include "IMeshLoader.h" #include "CSkinnedMesh.h" #include "IReadFile.h" +#include "SB3DStructs.h" #include "path.h" #include "json/json.hpp" #include @@ -21,6 +22,7 @@ class CB3DJSONMeshFileLoader : public IMeshLoader private: // Fields. CSkinnedMesh* AnimatedMesh; + core::array Textures; /* Quick note about JSON. This is static memory, it's a static memory address so I do not think @@ -34,6 +36,7 @@ private: CSkinnedMesh* cleanUp(std::string); std::tuple parseJSONFile(io::IReadFile* file); std::tuple load(); + std::tuple readChunkTEXS(); public: