Fling Engine  0.00.1
Fling Engine is a game engine written in Vulkan
Model.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "Resource.h"
4 
5 #include "Buffer.h"
6 #include "Vertex.h"
7 
8 namespace Fling
9 {
15  class Model : public Resource
16  {
17  public:
18 
19  static std::shared_ptr<Fling::Model> Create(Guid t_ID);
20 
25  explicit Model(Guid t_ID);
26 
27  ~Model();
28 
29  FORCEINLINE Buffer* GetVertexBuffer() const { return m_VertexBuffer; }
30  FORCEINLINE Buffer* GetIndexBuffer() const { return m_IndexBuffer; }
31 
32  FORCEINLINE const std::vector<Vertex>& GetVerts() const { return m_Verts; }
33  FORCEINLINE const std::vector<UINT32>& GetIndices() const { return m_Indices; }
34 
35  FORCEINLINE UINT32 GetIndexCount() const { return static_cast<UINT32>(m_Indices.size()); }
36  FORCEINLINE UINT32 GetVertexCount() const { return static_cast<UINT32>(m_Verts.size()); }
37 
38  static VkIndexType GetIndexType() { return VK_INDEX_TYPE_UINT32; }
39 
40  // Cadds bind commands to vertex and index buffers
41  bool CmdRender(const VkCommandBuffer& t_CmdBuf) const;
42 
43  private:
44 
45  std::vector<Vertex> m_Verts;
46  std::vector<UINT32> m_Indices;
47 
48  Buffer* m_VertexBuffer = nullptr;
49  Buffer* m_IndexBuffer = nullptr;
50 
54  void LoadModel();
55 
56  };
57 } // namespace Fling
std::vector< UINT32 > m_Indices
Definition: Model.h:46
~Model()
Definition: Model.cpp:21
Buffer * m_IndexBuffer
Definition: Model.h:49
Base class that represents a loaded resource in the engine.
Definition: Resource.h:11
std::vector< Vertex > m_Verts
Definition: Model.h:45
void LoadModel()
Load this model from Tiny Obj loader.
Definition: Model.cpp:28
FORCEINLINE Buffer * GetVertexBuffer() const
Definition: Model.h:29
Model(Guid t_ID)
Construct a new model object.
Definition: Model.cpp:15
static VkIndexType GetIndexType()
Definition: Model.h:38
A model represents a 3D model (.obj files for now) with vertices and indecies.
Definition: Model.h:15
FORCEINLINE const std::vector< Vertex > & GetVerts() const
Definition: Model.h:32
entt::hashed_string Guid
Definition: FlingTypes.h:21
FORCEINLINE Buffer * GetIndexBuffer() const
Definition: Model.h:30
FORCEINLINE const std::vector< UINT32 > & GetIndices() const
Definition: Model.h:33
bool CmdRender(const VkCommandBuffer &t_CmdBuf) const
Definition: Model.cpp:92
FORCEINLINE UINT32 GetVertexCount() const
Definition: Model.h:36
FORCEINLINE UINT32 GetIndexCount() const
Definition: Model.h:35
A Buffer represents a Vulkan buffer with a size, buffer pointer, and buffer memory.
Definition: Buffer.h:11
uint32_t UINT32
Definition: FlingTypes.h:10
Definition: Engine.h:13
Buffer * m_VertexBuffer
Definition: Model.h:48
static std::shared_ptr< Fling::Model > Create(Guid t_ID)
Definition: Model.cpp:10