A WIP 3D game engine in C++ using OpenGL
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

68 lines
1.6 KiB

#ifndef MESH_H
#define MESH_H
#include <vector>
#include <string>
#include "shaders.h"
#include <glm/glm.hpp>
#include <assimp/scene.h>
#include <assimp/postprocess.h>
#include <assimp/Importer.hpp>
#include <assimp/material.h>
struct vertex {
glm::vec3 position;
glm::vec3 normal;
glm::vec2 texture_coords;
glm::vec3 tangent;
};
struct texture {
unsigned int id;
std::string type;
std::string path;
};
class Mesh {
public:
std::vector<struct vertex> vertices;
std::vector<unsigned int> indices;
std::vector<struct texture> textures;
Mesh(std::vector<struct vertex> vertices,
std::vector<unsigned int> indices,
std::vector<struct texture> textures);
void draw(Shader *shader);
~Mesh() = default;
glm::vec3 average_position;
private:
unsigned int VAO, VBO, EBO;
void setupMesh();
};
class Model {
public:
Model(std::string path) {
load_model(path);
}
void draw(Shader *shader);
~Model() = default;
Assimp::Importer importer;
std::vector<Mesh> meshes;
std::string directory;
std::vector<texture> textures_loaded;
private:
unsigned int texture_from_file(const char *fname, std::string directory);
void load_model(std::string path);
void process_node(aiNode *node, const aiScene *scene);
Mesh process_mesh(aiMesh *mesh, const aiScene *scene);
std::vector<texture> load_material_textures(aiMaterial *mat, aiTextureType type, std::string type_name);
};
#endif