Implement Mesh partitioning
This commit is contained in:
17
src/mesh.hpp
17
src/mesh.hpp
@@ -5,6 +5,7 @@
|
||||
#include <glad/gl.h>
|
||||
|
||||
#include "vertex.hpp"
|
||||
#include "material.hpp"
|
||||
#include "utils.hpp"
|
||||
|
||||
namespace Fan
|
||||
@@ -13,14 +14,24 @@ namespace Fan
|
||||
class Mesh
|
||||
{
|
||||
public:
|
||||
struct SubMesh
|
||||
{
|
||||
GLuint index_offset{};
|
||||
GLuint index_count{};
|
||||
Rc<Material> material{};
|
||||
};
|
||||
|
||||
static Rc<Mesh> create(const std::vector<Vertex>& vertices,
|
||||
const std::vector<GLuint>& indices = {});
|
||||
const std::vector<GLuint>& indices = {},
|
||||
const std::vector<SubMesh>& submeshes = {});
|
||||
Mesh(const std::vector<Vertex>& vertices,
|
||||
const std::vector<GLuint>& indices,
|
||||
const std::vector<SubMesh>& submeshes,
|
||||
bool has_indices,
|
||||
GLuint VBO, GLuint VAO, GLuint EBO)
|
||||
: m_vertices(vertices)
|
||||
, m_indices(indices)
|
||||
, m_submeshes(submeshes)
|
||||
, m_has_indices(has_indices)
|
||||
, m_VBO(VBO)
|
||||
, m_VAO(VAO)
|
||||
@@ -32,11 +43,15 @@ public:
|
||||
Mesh(Mesh&& other) noexcept;
|
||||
Mesh& operator=(Mesh&& other) noexcept;
|
||||
|
||||
const std::vector<SubMesh>& get_submeshes() const;
|
||||
|
||||
void draw() const;
|
||||
void draw_submesh(GLuint index_offset, GLuint index_count) const;
|
||||
|
||||
private:
|
||||
std::vector<Vertex> m_vertices{};
|
||||
std::vector<GLuint> m_indices{};
|
||||
std::vector<SubMesh> m_submeshes{};
|
||||
bool m_has_indices{};
|
||||
|
||||
GLuint m_VBO{};
|
||||
|
||||
Reference in New Issue
Block a user