mirror of
https://github.com/minetest/irrlicht.git
synced 2024-11-15 23:10:26 +01:00
Start work on TEXS
This commit is contained in:
parent
9dace24987
commit
42b9658c8d
|
@ -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<bool, std::string> 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<bool, std::string> CB3DJSONMeshFileLoader::load() {
|
|||
return {false, "Wrong version in B3D JSON! Expected: 1"};
|
||||
}
|
||||
|
||||
// Success, failure reason
|
||||
std::tuple<bool, std::string> texturesSuccess = this->readChunkTEXS();
|
||||
|
||||
|
||||
|
||||
// return animatedMesh;
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "IMeshLoader.h"
|
||||
#include "CSkinnedMesh.h"
|
||||
#include "IReadFile.h"
|
||||
#include "SB3DStructs.h"
|
||||
#include "path.h"
|
||||
#include "json/json.hpp"
|
||||
#include <tuple>
|
||||
|
@ -21,6 +22,7 @@ class CB3DJSONMeshFileLoader : public IMeshLoader
|
|||
private:
|
||||
// Fields.
|
||||
CSkinnedMesh* AnimatedMesh;
|
||||
core::array<SB3dTexture> 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<bool, std::string> parseJSONFile(io::IReadFile* file);
|
||||
std::tuple<bool, std::string> load();
|
||||
std::tuple<bool, std::string> readChunkTEXS();
|
||||
|
||||
public:
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user