PortalGame/src/assets/mesh.hpp
2025-08-06 20:21:16 +02:00

45 lines
744 B
C++

#pragma once
#include <memory>
#include <string>
#include <span>
#include <glm/glm.hpp>
#include "gfx/vertex_array.hpp"
#include "gfx/texture.hpp"
namespace assets
{
struct MeshVertex
{
glm::vec3 pos;
glm::vec3 normal;
glm::vec2 uv;
glm::vec2 lightmap_uv;
};
struct MeshTriangle
{
uint32_t vert[3];
};
struct MeshMaterialSlot
{
std::string name;
std::shared_ptr<gfx::Texture> texture;
size_t first_tri = 0;
size_t num_tris = 0;
};
class Mesh
{
gfx::VertexArray va_;
std::vector<MeshMaterialSlot> materials_;
public:
Mesh(std::span<MeshVertex> verts, std::span<MeshTriangle> tris, std::span<MeshMaterialSlot> materials);
static std::shared_ptr<Mesh> LoadFromFile(const std::string& filename);
};
}