2022-08-30 23:39:24 +00:00
|
|
|
#pragma once
|
|
|
|
|
2022-09-22 02:52:06 +00:00
|
|
|
#include "../../gfx/mesh.h"
|
2022-08-30 23:39:24 +00:00
|
|
|
#include "../../gfx/material.h"
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace simpleengine {
|
|
|
|
/**
|
2022-09-23 04:44:07 +00:00
|
|
|
* @brief A component that contains a Mesh that will be rendered.
|
2022-08-30 23:39:24 +00:00
|
|
|
*
|
|
|
|
*/
|
2022-09-23 04:44:07 +00:00
|
|
|
class MeshComponent {
|
2022-08-30 23:39:24 +00:00
|
|
|
public:
|
2022-09-23 04:44:07 +00:00
|
|
|
gfx::Mesh mesh;
|
2022-08-30 23:39:24 +00:00
|
|
|
|
2022-09-23 04:44:07 +00:00
|
|
|
MeshComponent(gfx::Mesh mesh) : mesh(mesh) {
|
2022-08-30 23:39:24 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-09-22 02:52:06 +00:00
|
|
|
MeshComponent(std::vector<LitVertex> vertices, std::vector<GLuint> indicies, gfx::Material material,
|
2022-09-23 04:44:07 +00:00
|
|
|
bool calculate_normals = false): mesh(vertices, indicies, material) {
|
2022-09-16 21:01:52 +00:00
|
|
|
|
|
|
|
if (calculate_normals) {
|
2022-09-23 04:44:07 +00:00
|
|
|
mesh.calculate_normals();
|
2022-09-16 21:01:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-22 02:52:06 +00:00
|
|
|
MeshComponent(std::vector<LitVertex> vertices, std::vector<GLuint> indicies = std::vector<GLuint>(),
|
2022-09-16 21:01:52 +00:00
|
|
|
std::optional<gfx::Material> material = std::nullopt, bool calculate_normals = false) :
|
2022-09-23 04:44:07 +00:00
|
|
|
mesh(vertices, indicies, material) {
|
2022-09-16 21:01:52 +00:00
|
|
|
|
|
|
|
if (calculate_normals) {
|
2022-09-23 04:44:07 +00:00
|
|
|
mesh.calculate_normals();
|
2022-09-16 21:01:52 +00:00
|
|
|
}
|
|
|
|
}
|
2022-08-30 23:39:24 +00:00
|
|
|
};
|
|
|
|
}
|