PixelBullet  0.0.1
A C++ game engine
Loading...
Searching...
No Matches
static_mesh.h
1#pragma once
2
3#include "pixelbullet/filesystem/virtual_path.h"
4
5#include <glm/glm.hpp>
6
7#include <cstdint>
8#include <vector>
9
10namespace pixelbullet
11{
12class Filesystem;
13
15{
16public:
17 struct Vertex
18 {
19 glm::vec3 position = glm::vec3(0.0f);
20 glm::vec3 normal = glm::vec3(0.0f, 0.0f, 1.0f);
21 glm::vec2 uv = glm::vec2(0.0f);
22 };
23
24 struct Bounds
25 {
26 glm::vec3 min = glm::vec3(0.0f);
27 glm::vec3 max = glm::vec3(0.0f);
28 };
29
30 StaticMesh() = default;
31 StaticMesh(const Filesystem& filesystem, const VirtualPath& assetPath)
32 {
33 Load(filesystem, assetPath);
34 }
35
36 bool Load(const Filesystem& filesystem, const VirtualPath& assetPath);
37
38 explicit operator bool() const noexcept
39 {
40 return !vertices_.empty() && !indices_.empty();
41 }
42
43 const VirtualPath& GetFilename() const
44 {
45 return filename_;
46 }
47 const std::vector<Vertex>& GetVertices() const
48 {
49 return vertices_;
50 }
51 const std::vector<uint32_t>& GetIndices() const
52 {
53 return indices_;
54 }
55 const Bounds& GetBounds() const
56 {
57 return bounds_;
58 }
59
60private:
61 void Clear();
62
63private:
64 VirtualPath filename_;
65 std::vector<Vertex> vertices_;
66 std::vector<uint32_t> indices_;
67 Bounds bounds_;
68};
69} // namespace pixelbullet
Definition filesystem.h:16
Definition static_mesh.h:15
Definition virtual_path.h:10
Definition static_mesh.h:25
Definition static_mesh.h:18