BRE12
ModelManager.h
1 #pragma once
2 
3 #include <d3d12.h>
4 #include <mutex>
5 #include <tbb\concurrent_unordered_set.h>
6 
7 #include <ModelManager/Model.h>
8 
9 namespace BRE {
10 // To create/get models or built-in geometry.
11 class ModelManager {
12 public:
13  ModelManager() = delete;
14  ~ModelManager() = delete;
15  ModelManager(const ModelManager&) = delete;
16  const ModelManager& operator=(const ModelManager&) = delete;
17  ModelManager(ModelManager&&) = delete;
18  ModelManager& operator=(ModelManager&&) = delete;
19 
20  static void EraseAll() noexcept;
21 
22  static Model& LoadModel(const char* modelFilename,
23  ID3D12GraphicsCommandList& commandList,
24  Microsoft::WRL::ComPtr<ID3D12Resource>& uploadVertexBuffer,
25  Microsoft::WRL::ComPtr<ID3D12Resource>& uploadIndexBuffer) noexcept;
26 
27  // Geometry is centered at the origin.
28  static Model& CreateBox(const float width,
29  const float height,
30  const float depth,
31  const std::uint32_t numSubdivisions,
32  ID3D12GraphicsCommandList& commandList,
33  Microsoft::WRL::ComPtr<ID3D12Resource>& uploadVertexBuffer,
34  Microsoft::WRL::ComPtr<ID3D12Resource>& uploadIndexBuffer) noexcept;
35 
36  // Geometry is centered at the origin.
37  static Model& CreateSphere(const float radius,
38  const std::uint32_t sliceCount,
39  const std::uint32_t stackCount,
40  ID3D12GraphicsCommandList& commandList,
41  Microsoft::WRL::ComPtr<ID3D12Resource>& uploadVertexBuffer,
42  Microsoft::WRL::ComPtr<ID3D12Resource>& uploadIndexBuffer) noexcept;
43 
44  // Geometry is centered at the origin.
45  static Model& CreateGeosphere(const float radius,
46  const std::uint32_t numSubdivisions,
47  ID3D12GraphicsCommandList& commandList,
48  Microsoft::WRL::ComPtr<ID3D12Resource>& uploadVertexBuffer,
49  Microsoft::WRL::ComPtr<ID3D12Resource>& uploadIndexBuffer) noexcept;
50 
51  // Creates a cylinder parallel to the y-axis, and centered about the origin.
52  static Model& CreateCylinder(const float bottomRadius,
53  const float topRadius,
54  const float height,
55  const std::uint32_t sliceCount,
56  const std::uint32_t stackCount,
57  ID3D12GraphicsCommandList& commandList,
58  Microsoft::WRL::ComPtr<ID3D12Resource>& uploadVertexBuffer,
59  Microsoft::WRL::ComPtr<ID3D12Resource>& uploadIndexBuffer) noexcept;
60 
61  // Creates a rows x columns grid in the xz-plane centered
62  // at the origin.
63  static Model& CreateGrid(const float width,
64  const float depth,
65  const std::uint32_t rows,
66  const std::uint32_t columns,
67  ID3D12GraphicsCommandList& commandList,
68  Microsoft::WRL::ComPtr<ID3D12Resource>& uploadVertexBuffer,
69  Microsoft::WRL::ComPtr<ID3D12Resource>& uploadIndexBuffer) noexcept;
70 
71 private:
73  static Models mModels;
74 
75  static std::mutex mMutex;
76 };
77 
78 }
79 
Definition: Camera.cpp:8
Definition: ModelManager.h:11
Definition: concurrent_unordered_set.h:58
Definition: Model.h:15