2025-04-01 20:03:18 +00:00
|
|
|
#ifndef MODEL_COMPONENT_H
|
|
|
|
#define MODEL_COMPONENT_H
|
|
|
|
|
|
|
|
#include <glm/glm.hpp>
|
2025-04-01 20:19:00 +00:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
#include <GL/glew.h>
|
|
|
|
|
|
|
|
// Structure representing a single vertex.
|
|
|
|
struct Vertex {
|
|
|
|
glm::vec3 Position;
|
|
|
|
glm::vec3 Normal;
|
|
|
|
glm::vec2 TexCoords;
|
|
|
|
glm::vec3 Tangent;
|
|
|
|
};
|
2025-04-01 20:03:18 +00:00
|
|
|
|
|
|
|
class ModelComponent {
|
|
|
|
public:
|
|
|
|
ModelComponent();
|
|
|
|
~ModelComponent();
|
|
|
|
|
|
|
|
// Material properties.
|
|
|
|
glm::vec3 diffuseColor;
|
|
|
|
glm::vec3 specularColor;
|
|
|
|
float shininess;
|
2025-04-01 20:19:00 +00:00
|
|
|
|
|
|
|
// Mesh data.
|
|
|
|
std::vector<Vertex> vertices;
|
|
|
|
std::vector<GLuint> indices;
|
|
|
|
|
|
|
|
// OpenGL buffers.
|
|
|
|
GLuint VAO, VBO, EBO;
|
|
|
|
|
|
|
|
// Texture handles.
|
|
|
|
GLuint diffuseTexture;
|
|
|
|
GLuint normalTexture;
|
|
|
|
|
|
|
|
// Set up the mesh by creating VAO, VBO, and EBO.
|
|
|
|
void SetupMesh();
|
|
|
|
|
|
|
|
// Load textures from file.
|
|
|
|
bool LoadDiffuseTexture(const std::string &filepath);
|
|
|
|
bool LoadNormalTexture(const std::string &filepath);
|
|
|
|
|
|
|
|
// Draw the mesh.
|
|
|
|
void Draw();
|
2025-04-01 20:03:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // MODEL_COMPONENT_H
|