07/include/Model.h

60 lines
2.7 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 "./"
class GrouptedModel loadOBJtoGroupted(const char* filename, const char* mtl_directory = DEFAULT_MTL_DIR, const char* texture_directory = DEFAULT_MTL_DIR);
// Класс определяющий положение, вращение и размер объекта
class Movable
{
public:
Movable(); // Конструктор без параметров
Movable(const Movable& copy); // Конструктор копирования
glm::vec3 position; // позиция модели
glm::vec3 rotation; // поворот модели
glm::vec3 scale; // масштабирование модели
glm::mat4 getTransformMatrix(); // Матрица трансформации модели
};
// Класс модели с примененным материалом
class Model : public Movable
{
public:
Model(); // Конструктор без параметров
Model(const Model& copy); // Конструктор копирования
~Model();
void render(const GLuint &model_uniform, const glm::mat4& global_tranform = glm::mat4(1)); // Вызов отрисовки
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(GLuint beg, GLuint count); // Ограничение диапазона из буфера индексов
private:
VAO vao;
BO vertex_vbo, index_vbo; // вершинный и индексный буферы
BO normals_vbo, texCoords_vbo; // буферы с нормалями и текстурными координатами
GLuint verteces_count; // Количество вершин
GLuint first_index, indices_count; // Первый и количество индексов
Texture texture_diffuse; // Диффузная текстура
};
// Класс сгруппированной модели
class GrouptedModel: public Movable
{
public:
void render(const GLuint &model_uniform); // Вызов отрисовки
std::vector<Model> parts;
};
#endif // MODEL_H