BRE12
Mesh.h
1 #pragma once
2 
3 #include <cstdint>
4 
5 #include <GeometryGenerator/GeometryGenerator.h>
6 #include <ResourceManager\VertexAndIndexBufferCreator.h>
7 #include <Utils/DebugUtils.h>
8 
9 struct aiMesh;
10 struct ID3D12GraphicsCommandList;
11 
12 namespace BRE {
13 class Model;
14 
15 // Stores model's mesh vertex and buffer data.
16 class Mesh {
17  friend class Model;
18 
19 public:
20  ~Mesh() = default;
21  Mesh(const Mesh&) = delete;
22  const Mesh& operator=(const Mesh&) = delete;
23  Mesh(Mesh&&) = default;
24  Mesh& operator=(Mesh&&) = delete;
25 
26  // Preconditions:
27  // - data must be valid
28  __forceinline const VertexAndIndexBufferCreator::VertexBufferData& GetVertexBufferData() const noexcept
29  {
30  BRE_ASSERT(mVertexBufferData.IsDataValid());
31  return mVertexBufferData;
32  }
33 
34  // Preconditions:
35  // - data must be valid
36  __forceinline const VertexAndIndexBufferCreator::IndexBufferData& GetIndexBufferData() const noexcept
37  {
38  BRE_ASSERT(mIndexBufferData.IsDataValid());
39  return mIndexBufferData;
40  }
41 
42 private:
43  // Command lists are used to store buffers creation (vertex and index per mesh)
44  // "commandList" must be executed after calling these methods, to create the commited resource.
45  // Preconditions:
46  // - "commandList" must be in recorded state before calling these method.
47  explicit Mesh(const aiMesh& mesh,
48  ID3D12GraphicsCommandList& commandList,
49  Microsoft::WRL::ComPtr<ID3D12Resource>& uploadVertexBuffer,
50  Microsoft::WRL::ComPtr<ID3D12Resource>& uploadIndexBuffer);
51 
52  explicit Mesh(const GeometryGenerator::MeshData& meshData,
53  ID3D12GraphicsCommandList& commandList,
54  Microsoft::WRL::ComPtr<ID3D12Resource>& uploadVertexBuffer,
55  Microsoft::WRL::ComPtr<ID3D12Resource>& uploadIndexBuffer);
56 
59 };
60 }
61 
Definition: Camera.cpp:8
A mesh represents a geometry or model with a single material.
Definition: mesh.h:467
Definition: VertexAndIndexBufferCreator.h:53
Definition: GeometryGenerator.h:30
Definition: Mesh.h:16
Definition: VertexAndIndexBufferCreator.h:36
Definition: Model.h:15