ADD: Centroid in meshSection
This commit is contained in:
parent
1a2b6ae364
commit
5d1da184e0
@ -19,6 +19,7 @@ namespace engine {
|
|||||||
std::string name;
|
std::string name;
|
||||||
unsigned int indexOffset; // in Indizes, nicht Bytes
|
unsigned int indexOffset; // in Indizes, nicht Bytes
|
||||||
unsigned int indexCount;
|
unsigned int indexCount;
|
||||||
|
glm::vec3 centroid;
|
||||||
std::shared_ptr<Material> material;
|
std::shared_ptr<Material> material;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -9,6 +9,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include "Material.h"
|
#include "Material.h"
|
||||||
|
#include "glm/vec3.hpp"
|
||||||
#include "loader/textures/TextureUploader.h"
|
#include "loader/textures/TextureUploader.h"
|
||||||
#include "spdlog/spdlog.h"
|
#include "spdlog/spdlog.h"
|
||||||
|
|
||||||
@ -98,6 +99,12 @@ engine::Model engine::ModelUploader::uploadSections(const std::vector<RawMeshSec
|
|||||||
texCoords.insert(texCoords.end(), section.textureCoords.begin(), section.textureCoords.end());
|
texCoords.insert(texCoords.end(), section.textureCoords.begin(), section.textureCoords.end());
|
||||||
for (int localIndex : section.indices) indices.push_back(vertexOffset + static_cast<unsigned int>(localIndex));
|
for (int localIndex : section.indices) indices.push_back(vertexOffset + static_cast<unsigned int>(localIndex));
|
||||||
|
|
||||||
|
glm::vec3 centroidSum(0.0f);
|
||||||
|
for (size_t i = 0; i < section.vertices.size(); i += 3) {
|
||||||
|
centroidSum += glm::vec3(section.vertices[i], section.vertices[i+1], section.vertices[i+2]);
|
||||||
|
}
|
||||||
|
meshSection.centroid = centroidSum / static_cast<float>(section.vertices.size() / 3);
|
||||||
|
|
||||||
vertexOffset += static_cast<unsigned int>(section.vertices.size() / 3);
|
vertexOffset += static_cast<unsigned int>(section.vertices.size() / 3);
|
||||||
meshSections.push_back(std::move(meshSection));
|
meshSections.push_back(std::move(meshSection));
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user