mirror of
https://github.com/minetest/irrlicht.git
synced 2024-11-17 15:58:21 +01:00
I'm actually having fun with C++
This commit is contained in:
parent
aad38e8a49
commit
e0577ace2b
@ -42,8 +42,9 @@ bool CB3DJSONMeshFileLoader::isALoadableFileExtension(
|
|||||||
return core::hasFileExtension(fileName, "json");
|
return core::hasFileExtension(fileName, "json");
|
||||||
}
|
}
|
||||||
|
|
||||||
void parseModel(json model) {
|
IAnimatedMesh* parseModel(json model) {
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
IAnimatedMesh* CB3DJSONMeshFileLoader::createMesh(io::IReadFile* file) {
|
IAnimatedMesh* CB3DJSONMeshFileLoader::createMesh(io::IReadFile* file) {
|
||||||
@ -54,17 +55,13 @@ IAnimatedMesh* CB3DJSONMeshFileLoader::createMesh(io::IReadFile* file) {
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
println("I am loading your cool file, yay");
|
// println("I am loading your cool file, yay");
|
||||||
|
|
||||||
printf("the file is called: ");
|
// printf("the file is called: ");
|
||||||
println(file->getFileName().c_str());
|
// println(file->getFileName().c_str());
|
||||||
|
|
||||||
// So here we turn this mangled disaster into a C string.
|
// So here we turn this mangled disaster into a C string.
|
||||||
|
|
||||||
// These two hold error message pointers, basically.
|
|
||||||
// std::string err {};
|
|
||||||
// std::string warn {};
|
|
||||||
|
|
||||||
// auto buffer = std::make_unique<char[]>(file->getSize());
|
// auto buffer = std::make_unique<char[]>(file->getSize());
|
||||||
char* buffer = new char[file->getSize()];
|
char* buffer = new char[file->getSize()];
|
||||||
|
|
||||||
@ -76,19 +73,21 @@ IAnimatedMesh* CB3DJSONMeshFileLoader::createMesh(io::IReadFile* file) {
|
|||||||
// Dereference then borrow it.
|
// Dereference then borrow it.
|
||||||
json data = json::parse(&*clone);
|
json data = json::parse(&*clone);
|
||||||
|
|
||||||
|
// Now check some real basic elements of the JSON file.
|
||||||
if (!data.contains("format") || !data["format"].is_string() || data["format"] != "BB3DJSON") {
|
if (!data.contains("format") || !data["format"].is_string() || data["format"] != "BB3DJSON") {
|
||||||
os::Printer::log("No format in B3D JSON!", ELL_WARNING);
|
os::Printer::log("No format in B3D JSON! Expected: BB3DJSON", ELL_WARNING);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if (!data.contains("version") || !data["version"].is_number_integer() || data["version"] != 1) {
|
if (!data.contains("version") || !data["version"].is_number_integer() || data["version"] != 1) {
|
||||||
os::Printer::log("Wrong version in B3D JSON!", ELL_WARNING);
|
os::Printer::log("Wrong version in B3D JSON! Expected: 1", ELL_WARNING);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
parseModel(data);
|
// Now we can start doing things with it.
|
||||||
|
IAnimatedMesh* finalizedModel = parseModel(data);
|
||||||
|
|
||||||
|
|
||||||
return nullptr;
|
return finalizedModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace scene
|
} // namespace scene
|
||||||
|
Loading…
Reference in New Issue
Block a user