Skip to content
Snippets Groups Projects
Commit 322651da authored by Alexander Gauggel's avatar Alexander Gauggel
Browse files

[#63] Fix scene mesh translation

parent 3d6878e2
No related branches found
No related tags found
1 merge request!51Resolve "Laden mehrer Meshes mit Materials und Textures"
Pipeline #25755 passed
......@@ -330,13 +330,13 @@ int loadScene(const std::string &path, Scene &scene){
std::vector<Sampler> samplers;
std::vector<Mesh> meshes;
std::vector<VertexGroup> vertexGroups;
std::vector<int> vertexGroupsIndex;
int groupCount = 0;
Mesh mesh = {};
for(int i = 0; i < sceneObjects.meshes.size(); i++){
std::vector<int> vertexGroupsIndices;
fx::gltf::Mesh const &objectMesh = sceneObjects.meshes[i];
for(int j = 0; j < objectMesh.primitives.size(); j++){
......@@ -440,12 +440,12 @@ int loadScene(const std::string &path, Scene &scene){
static_cast<uint8_t>(objectPrimitive.material)
});
vertexGroupsIndices.push_back(groupCount);
groupCount++;
vertexGroupsIndex.push_back(groupCount);
}
mesh.name = sceneObjects.meshes[i].name;
mesh.vertexGroups = vertexGroupsIndex;
mesh.vertexGroups = vertexGroupsIndices;
meshes.push_back(mesh);
}
......
......@@ -180,11 +180,14 @@ int main(int argc, const char** argv) {
}
std::vector<glm::mat4> modelMatrices;
modelMatrices.clear();
for(int m = 0; m < scene.meshes.size(); m++){
modelMatrices.push_back(arrayTo4x4Matrix(scene.meshes[m].modelMatrix));
modelMatrices.resize(scene.vertexGroups.size(), glm::mat4(1.f));
for (const auto &mesh : scene.meshes) {
const glm::mat4 m = arrayTo4x4Matrix(mesh.modelMatrix);
for (const auto &vertexGroupIndex : mesh.vertexGroups) {
modelMatrices[vertexGroupIndex] = m;
}
}
std::vector<glm::mat4> mvp;
std::vector<glm::mat4> mvp;
auto start = std::chrono::system_clock::now();
while (window.isWindowOpen()) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment