mirror of
https://github.com/minetest/irrlicht.git
synced 2025-02-23 06:10:22 +01:00
Extract loadPrimitives method from createMesh
This commit is contained in:
parent
3930bd8c85
commit
0896aae906
@ -92,7 +92,18 @@ IAnimatedMesh* CGLTFMeshFileLoader::createMesh(io::IReadFile* file)
|
|||||||
|
|
||||||
MeshExtractor parser(std::move(model));
|
MeshExtractor parser(std::move(model));
|
||||||
SMesh* baseMesh(new SMesh {});
|
SMesh* baseMesh(new SMesh {});
|
||||||
|
loadPrimitives(parser, baseMesh);
|
||||||
|
|
||||||
|
SAnimatedMesh* animatedMesh(new SAnimatedMesh {});
|
||||||
|
animatedMesh->addMesh(baseMesh);
|
||||||
|
|
||||||
|
return animatedMesh;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CGLTFMeshFileLoader::loadPrimitives(
|
||||||
|
const MeshExtractor& parser,
|
||||||
|
SMesh* mesh)
|
||||||
|
{
|
||||||
for (std::size_t i = 0; i < parser.getMeshCount(); ++i) {
|
for (std::size_t i = 0; i < parser.getMeshCount(); ++i) {
|
||||||
for (std::size_t j = 0; j < parser.getPrimitiveCount(i); ++j) {
|
for (std::size_t j = 0; j < parser.getPrimitiveCount(i); ++j) {
|
||||||
auto indices = parser.getIndices(i, j);
|
auto indices = parser.getIndices(i, j);
|
||||||
@ -101,14 +112,9 @@ IAnimatedMesh* CGLTFMeshFileLoader::createMesh(io::IReadFile* file)
|
|||||||
SMeshBuffer* meshbuf(new SMeshBuffer {});
|
SMeshBuffer* meshbuf(new SMeshBuffer {});
|
||||||
meshbuf->append(vertices.data(), vertices.size(),
|
meshbuf->append(vertices.data(), vertices.size(),
|
||||||
indices.data(), indices.size());
|
indices.data(), indices.size());
|
||||||
baseMesh->addMeshBuffer(meshbuf);
|
mesh->addMeshBuffer(meshbuf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SAnimatedMesh* animatedMesh(new SAnimatedMesh {});
|
|
||||||
animatedMesh->addMesh(baseMesh);
|
|
||||||
|
|
||||||
return animatedMesh;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CGLTFMeshFileLoader::MeshExtractor::MeshExtractor(
|
CGLTFMeshFileLoader::MeshExtractor::MeshExtractor(
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include "irrTypes.h"
|
#include "irrTypes.h"
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
#include "S3DVertex.h"
|
#include "S3DVertex.h"
|
||||||
|
#include "SMesh.h"
|
||||||
#include "vector2d.h"
|
#include "vector2d.h"
|
||||||
#include "vector3d.h"
|
#include "vector3d.h"
|
||||||
|
|
||||||
@ -119,6 +120,8 @@ private:
|
|||||||
const std::size_t primitiveIdx) const;
|
const std::size_t primitiveIdx) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void loadPrimitives(const MeshExtractor& parser, SMesh* mesh);
|
||||||
|
|
||||||
static bool tryParseGLTF(io::IReadFile* file,
|
static bool tryParseGLTF(io::IReadFile* file,
|
||||||
tinygltf::Model& model);
|
tinygltf::Model& model);
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user