2021-12-07 19:51:12 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "shader.h"
|
|
|
|
#include "vao.h"
|
|
|
|
#include "vbo.h"
|
|
|
|
#include "../vertex.h"
|
|
|
|
#include "../renderable.h"
|
|
|
|
#include "../transformable.h"
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace simpleengine::gfx {
|
|
|
|
class Model : public simpleengine::Renderable, public simpleengine::Transformable {
|
|
|
|
public:
|
2022-08-18 20:03:51 +00:00
|
|
|
std::vector<LitVertex> vertices;
|
2021-12-07 19:51:12 +00:00
|
|
|
std::vector<GLuint> indicies;
|
|
|
|
gfx::VBO ebo;
|
|
|
|
gfx::VBO vbo;
|
|
|
|
gfx::VAO vao;
|
|
|
|
|
|
|
|
gfx::Shader shader;
|
|
|
|
|
2022-08-18 20:03:51 +00:00
|
|
|
Model(GLFWwindow* window, gfx::Shader shader, std::vector<LitVertex> vertices, std::vector<GLuint> indicies = std::vector<GLuint>());
|
|
|
|
Model(GLFWwindow* window, GLuint shader_program, std::vector<LitVertex> vertices,
|
2021-12-07 19:51:12 +00:00
|
|
|
std::vector<GLuint> indicies = std::vector<GLuint>());
|
|
|
|
protected:
|
2022-08-18 15:34:05 +00:00
|
|
|
virtual void setup_vertices();
|
2021-12-07 19:51:12 +00:00
|
|
|
public:
|
|
|
|
virtual void update(const float& delta_time) override;
|
|
|
|
virtual void render(GLFWwindow* target) override;
|
2022-08-18 20:03:51 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
glm::vec3 compute_face_normal(const glm::vec3& p1, const glm::vec3& p2, const glm::vec3& p3);
|
|
|
|
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* @brief Calculate the normals of the model.
|
|
|
|
*
|
|
|
|
* @note This **will** overwrite the existing normals.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void calculate_normals();
|
2021-12-07 19:51:12 +00:00
|
|
|
};
|
|
|
|
}
|