set boundary in loop

This commit is contained in:
ayachi3 2022-12-13 15:54:19 +08:00
parent a7212b893e
commit b145dbc567
2 changed files with 13 additions and 7 deletions

View File

@ -65,9 +65,16 @@ Mesh Model::processMesh(aiMesh* mesh, const aiScene* scene) {
glm::vec3 vertexBitangent = glm::vec3(0.0f);
// Process vertex positions
vertexPosition.x = mesh->mVertices[i].x;
vertexPosition.y = mesh->mVertices[i].y;
vertexPosition.z = mesh->mVertices[i].z;
// 使用循环避免代码重复,如果可行的话,可以在此循环中确定法向量等信息
for (int j = 0; j < 3; j++) {
vertexPosition[j] = mesh->mVertices[i][j];
left_down_back[j] = left_down_back[j] < vertexPosition[j] ? left_down_back[j] : vertexPosition[j];
right_up_front[j] = right_up_front[j] > vertexPosition[j] ? right_up_front[j] : vertexPosition[j];
}
//vertexPosition.x = mesh->mVertices[i].x;
//vertexPosition.y = mesh->mVertices[i].y;
//vertexPosition.z = mesh->mVertices[i].z;
// Process vertex normals
if (mesh->mNormals) {

View File

@ -19,11 +19,10 @@ private:
std::string _directory;
MODELSTATUS _status = LOADING;
// largest point
glm::vec3 right_up_front = glm::vec3(3e37f, 3e37f, 3e37f);
// smallest point
glm::vec3 left_down_back = -right_up_front;
glm::vec3 left_down_back = glm::vec3(3e37f, 3e37f, 3e37f);
// largest point
glm::vec3 right_up_front = -left_down_back;
public:
Model(std::string path);