05/include/Model.h

43 lines
2.1 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef MODEL_H
#define MODEL_H
#include "Buffers.h"
#include "Texture.h"
#include <GLM/glm.hpp>
#include <vector>
#define DEFAULT_MTL_DIR "./"
void loadOBJtoVector(const char* filename, std::vector<class Model>& scene, const char* mtl_directory = DEFAULT_MTL_DIR, const char* texture_directory = DEFAULT_MTL_DIR);
class Model
{
public:
Model(); // Конструктор без параметров
Model(const Model& copy); // Конструктор копирования
~Model();
void render(const GLuint &mvp_uniform); // Вызов отрисовки
void load_verteces(glm::vec3* verteces, GLuint count); // Загрузка вершин в буфер
void load_indices(GLuint* indices, GLuint count); // Загрузка индексов в буфер
void load_texCoords(glm::vec2* texCoords, GLuint count); // Загрузка текстурных координат в буфер
void load_normals(glm::vec3* normals, GLuint count); // Загрузка нормалей в буфер
void set_texture(Texture& texture); // Привязка текстуры к модели
void set_index_range(size_t first_byteOffset, size_t count); // Ограничение диапазона из буфера индексов
glm::vec3 position; // позиция модели
glm::vec3 rotation; // поворот модели
glm::vec3 scale; // мастабирование модели
glm::mat4 getTransformMatrix(); // Матрица трансформации модели
private:
VAO vao;
BO vertex_vbo, index_vbo; // вершинный и индексный буферы
BO normals_vbo, texCoords_vbo; // буферы с нормалями и текстурными координатами
size_t verteces_count; // Количество вершин
size_t first_index_byteOffset, indices_count; // Сдвиг в байтах для первого и количество индексов
Texture texture_diffuse; // Диффузная текстура
};
#endif // MODEL_H