mirror of
https://github.com/Linloir/SceneEditor.git
synced 2025-12-17 15:38:11 +08:00
define function to get boundary
This commit is contained in:
parent
b145dbc567
commit
30fe45b773
@ -68,8 +68,8 @@ Mesh Model::processMesh(aiMesh* mesh, const aiScene* scene) {
|
||||
// 使用循环避免代码重复,如果可行的话,可以在此循环中确定法向量等信息
|
||||
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];
|
||||
_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;
|
||||
|
||||
@ -20,9 +20,9 @@ private:
|
||||
MODELSTATUS _status = LOADING;
|
||||
|
||||
// smallest point
|
||||
glm::vec3 left_down_back = glm::vec3(3e37f, 3e37f, 3e37f);
|
||||
glm::vec3 _left_down_back = glm::vec3(3e37f, 3e37f, 3e37f);
|
||||
// largest point
|
||||
glm::vec3 right_up_front = -left_down_back;
|
||||
glm::vec3 _right_up_front = -_left_down_back;
|
||||
|
||||
public:
|
||||
Model(std::string path);
|
||||
@ -31,6 +31,13 @@ public:
|
||||
public:
|
||||
inline MODELSTATUS status() const { return _status; }
|
||||
|
||||
inline glm::vec3 get_upper_bound() {
|
||||
return _right_up_front;
|
||||
}
|
||||
inline glm::vec3 get_lower_bound() {
|
||||
return _left_down_back;
|
||||
}
|
||||
|
||||
private:
|
||||
void loadModel(std::string path);
|
||||
void processNode(aiNode* node, const aiScene* scene);
|
||||
|
||||
42
enc_temp_folder/253395836ff6e468d34a6e0bb41a535/model.h
Normal file
42
enc_temp_folder/253395836ff6e468d34a6e0bb41a535/model.h
Normal file
@ -0,0 +1,42 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <Assimp/Importer.hpp>
|
||||
#include <Assimp/scene.h>
|
||||
#include <Assimp/postprocess.h>
|
||||
|
||||
#include "mesh.h"
|
||||
#include "shader.h"
|
||||
#include <limits>
|
||||
class Model {
|
||||
public:
|
||||
enum MODELSTATUS { LOADING, LOADED, ERR };
|
||||
|
||||
private:
|
||||
std::vector<Mesh> _meshes;
|
||||
std::vector<Texture> _texturesLoaded;
|
||||
std::string _directory;
|
||||
MODELSTATUS _status = LOADING;
|
||||
|
||||
// smallest point
|
||||
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);
|
||||
~Model();
|
||||
|
||||
public:
|
||||
inline MODELSTATUS status() const { return _status; }
|
||||
|
||||
private:
|
||||
void loadModel(std::string path);
|
||||
void processNode(aiNode* node, const aiScene* scene);
|
||||
Mesh processMesh(aiMesh* mesh, const aiScene* scene);
|
||||
std::vector<Texture> loadMaterialTextures(aiMaterial* mat, aiTextureType type, TextureType textureType);
|
||||
|
||||
public:
|
||||
void render(const ShaderProgram& shader) const;
|
||||
};
|
||||
Loading…
x
Reference in New Issue
Block a user