mirror of
https://github.com/minetest/irrlicht.git
synced 2025-02-23 06:10:22 +01:00
Add a whole bunch of random things
This commit is contained in:
parent
1ca05bbdde
commit
e0331595fa
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"files.associations": {
|
"files.associations": {
|
||||||
"iostream": "cpp",
|
"iostream": "cpp",
|
||||||
"fstream": "cpp"
|
"fstream": "cpp",
|
||||||
|
"new": "cpp"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,6 +1,13 @@
|
|||||||
#include "CB3DJSONMeshFileLoader.h"
|
#include "CB3DJSONMeshFileLoader.h"
|
||||||
#include "coreutil.h"
|
#include "coreutil.h"
|
||||||
#include "IAnimatedMesh.h"
|
#include "IAnimatedMesh.h"
|
||||||
|
#include "S3DVertex.h"
|
||||||
|
#include "SAnimatedMesh.h"
|
||||||
|
#include "SColor.h"
|
||||||
|
#include "CMeshBuffer.h"
|
||||||
|
#include "SMesh.h"
|
||||||
|
#include "vector3d.h"
|
||||||
|
#include "quaternion.h"
|
||||||
#include "IReadFile.h"
|
#include "IReadFile.h"
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@ -42,11 +49,76 @@ bool CB3DJSONMeshFileLoader::isALoadableFileExtension(
|
|||||||
return core::hasFileExtension(fileName, "json");
|
return core::hasFileExtension(fileName, "json");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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};
|
||||||
|
|
||||||
|
if (data.contains("position") && data["position"].is_array()) {
|
||||||
|
|
||||||
|
auto positionJSON = data["position"].array();
|
||||||
|
|
||||||
|
if (!positionJSON.size() == 3) {
|
||||||
|
os::Printer::log("Error, position in NODE must be an array of 3 integers!", ELL_WARNING);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
println("found a position data!");
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
for (auto p = positionJSON.begin(); p != positionJSON.end(); ++p) {
|
||||||
|
|
||||||
|
auto dereffed = *p;
|
||||||
|
|
||||||
|
if (!dereffed.is_number_integer()) {
|
||||||
|
os::Printer::log("Error, position in NODE must be an array of 3 integers!", ELL_WARNING);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (i){
|
||||||
|
case 0:
|
||||||
|
position.X = dereffed;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
position.Y = dereffed;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
position.Z = dereffed;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
IAnimatedMesh* parseModel(json data) {
|
IAnimatedMesh* parseModel(json data) {
|
||||||
|
|
||||||
|
//! Remember: This is basically a linked tree.
|
||||||
|
|
||||||
|
SMesh* baseMesh(new SMesh {});
|
||||||
|
|
||||||
|
SMeshBuffer* meshBuffer(new SMeshBuffer {});
|
||||||
|
|
||||||
|
// And now we begin the recursion!
|
||||||
|
|
||||||
|
std::cout << data["NODE"] << "\n";
|
||||||
|
|
||||||
|
if (data.contains("NODE") && data["NODE"].is_object()) {
|
||||||
|
println("Yep, that's a node!");
|
||||||
|
|
||||||
|
if (parseNode(data["NODE"], meshBuffer)) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SAnimatedMesh* animatedMesh(new SAnimatedMesh {});
|
||||||
|
animatedMesh->addMesh(baseMesh);
|
||||||
|
|
||||||
|
return animatedMesh;
|
||||||
|
}
|
||||||
|
|
||||||
IAnimatedMesh* CB3DJSONMeshFileLoader::createMesh(io::IReadFile* file) {
|
IAnimatedMesh* CB3DJSONMeshFileLoader::createMesh(io::IReadFile* file) {
|
||||||
|
|
||||||
@ -85,7 +157,7 @@ IAnimatedMesh* CB3DJSONMeshFileLoader::createMesh(io::IReadFile* file) {
|
|||||||
IAnimatedMesh* finalizedModel = parseModel(data);
|
IAnimatedMesh* finalizedModel = parseModel(data);
|
||||||
|
|
||||||
|
|
||||||
return finalizedModel;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace scene
|
} // namespace scene
|
||||||
|
Loading…
x
Reference in New Issue
Block a user