ThreeLab/Engine/Components/ModelComponent.h
2025-04-01 15:19:00 -05:00

50 lines
985 B
C++

#ifndef MODEL_COMPONENT_H
#define MODEL_COMPONENT_H
#include <glm/glm.hpp>
#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;
};
class ModelComponent {
public:
ModelComponent();
~ModelComponent();
// Material properties.
glm::vec3 diffuseColor;
glm::vec3 specularColor;
float shininess;
// 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();
};
#endif // MODEL_COMPONENT_H