PixelBullet  0.0.1
A C++ game engine
Loading...
Searching...
No Matches
skinned_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
14class SkinnedMesh
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 uv0 = glm::vec2(0.0f);
22 glm::vec2 uv1 = glm::vec2(0.0f);
23 glm::vec4 tangent = glm::vec4(1.0f, 0.0f, 0.0f, 1.0f);
24 glm::uvec4 joints = glm::uvec4(0u);
25 glm::vec4 weights = glm::vec4(1.0f, 0.0f, 0.0f, 0.0f);
26 glm::uvec4 joints1 = glm::uvec4(0u);
27 glm::vec4 weights1 = glm::vec4(0.0f);
28 };
29
30 struct Bounds
31 {
32 glm::vec3 min = glm::vec3(0.0f);
33 glm::vec3 max = glm::vec3(0.0f);
34 };
35
36 SkinnedMesh() = default;
37 SkinnedMesh(const Filesystem& filesystem, const VirtualPath& asset_path)
38 {
39 Load(filesystem, asset_path);
40 }
41
42 bool Load(const Filesystem& filesystem, const VirtualPath& asset_path);
43
44 explicit operator bool() const noexcept
45 {
46 return !vertices_.empty() && !indices_.empty() && !inverse_bind_matrices_.empty();
47 }
48
49 const VirtualPath& GetFilename() const
50 {
51 return filename_;
52 }
53 const std::vector<Vertex>& GetVertices() const
54 {
55 return vertices_;
56 }
57 const std::vector<uint32_t>& GetIndices() const
58 {
59 return indices_;
60 }
61 const std::vector<glm::mat4>& GetInverseBindMatrices() const
62 {
63 return inverse_bind_matrices_;
64 }
65 const Bounds& GetBounds() const
66 {
67 return bounds_;
68 }
69
70private:
71 void Clear();
72
73private:
74 VirtualPath filename_;
75 std::vector<Vertex> vertices_;
76 std::vector<uint32_t> indices_;
77 std::vector<glm::mat4> inverse_bind_matrices_;
78 Bounds bounds_;
79};
80} // namespace pixelbullet
Definition filesystem.h:16
Definition virtual_path.h:10
Definition skinned_mesh.h:31
Definition skinned_mesh.h:18