Graphics v0.0.0
A simple abstraction layer for the modern graphics APIs.
载入中...
搜索中...
未找到
Mesh.h
1// Copyright 2022 ShenMian
2// License(Apache-2.0)
3
4#pragma once
5
6#include <math/math.hpp>
7#include <memory>
8#include <string>
9#include <vector>
10
11class IndexBuffer;
12class VertexBuffer;
13struct Material;
14
22class Mesh
23{
24public:
25 struct Vertex
26 {
27 Vector3 position;
28 Vector3 normal;
29 Vector2 uv;
30 Vector3 tangent;
31 Vector3 bitangent;
32 };
33
34 Mesh(std::string_view name, const std::vector<Vertex>& vertices, const std::vector<unsigned int>& indices,
35 Material* mat = nullptr);
36
37 std::string name;
38 std::vector<Vertex> vertices;
39 std::vector<unsigned int> indices;
40 Material* material = nullptr;
41
42 uint32_t vertexCount = 0;
43 uint32_t indexCount = 0;
44
45 std::shared_ptr<VertexBuffer> vertexBuffer;
46 std::shared_ptr<IndexBuffer> indexBuffer;
47
55 float compress();
56
60 void decompress();
61
65 bool is_compressed() const noexcept;
66
67private:
68 void optimize();
69 void create_buffers();
70
71 std::vector<unsigned char> vbuf_;
72 std::vector<unsigned char> ibuf_;
73};
74
索引缓冲区.
Definition: IndexBuffer.h:16
网格.
Definition: Mesh.h:23
bool is_compressed() const noexcept
Definition: Mesh.cpp:58
float compress()
压缩.
Definition: Mesh.cpp:18
void decompress()
解压.
Definition: Mesh.cpp:43
顶点缓冲区.
Definition: VertexBuffer.h:16
材质.
Definition: Material.h:17
Definition: Mesh.h:26