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 
22  static std::shared_ptr<Fling::Model> Quad();
23 
28  Model(Guid t_ID);
29 
33  Model(Guid t_ID, std::vector<Vertex>& t_Verts, std::vector<UINT32> t_Indecies);
34 
35  ~Model();
36 
37  FORCEINLINE Buffer* GetVertexBuffer() const { return m_VertexBuffer; }
38  FORCEINLINE Buffer* GetIndexBuffer() const { return m_IndexBuffer; }
39 
40  FORCEINLINE const std::vector<Vertex>& GetVerts() const { return m_Verts; }
41  FORCEINLINE const std::vector<UINT32>& GetIndices() const { return m_Indices; }
42 
43  FORCEINLINE UINT32 GetIndexCount() const { return static_cast<UINT32>(m_Indices.size()); }
44  FORCEINLINE UINT32 GetVertexCount() const { return static_cast<UINT32>(m_Verts.size()); }
45 
46  constexpr static VkIndexType GetIndexType() { return VK_INDEX_TYPE_UINT32; }
47 
48  private:
49 
50  void CreateBuffers();
51 
52  static void CalculateVertexTangents(Vertex* verts, UINT32 numVerts, UINT32* indices, UINT32 numIndices);
53 
54  std::vector<Vertex> m_Verts;
55  std::vector<UINT32> m_Indices;
56 
57  Buffer* m_VertexBuffer = nullptr;
58  Buffer* m_IndexBuffer = nullptr;
59 
63  void LoadModel();
64 
65  };
66 } // namespace Fling
std::vector< UINT32 > m_Indices
Definition: Model.h:55
~Model()
Definition: Model.cpp:92
Buffer * m_IndexBuffer
Definition: Model.h:58
Base class that represents a loaded resource in the engine.
Definition: Resource.h:11
std::vector< Vertex > m_Verts
Definition: Model.h:54
void LoadModel()
Load this model from Tiny Obj loader.
Definition: Model.cpp:99
FORCEINLINE Buffer * GetVertexBuffer() const
Definition: Model.h:37
Basic Vertex outline for use with our vertex buffers.
Definition: Vertex.h:10
Model(Guid t_ID)
Construct a new model object.
Definition: Model.cpp:76
static void CalculateVertexTangents(Vertex *verts, UINT32 numVerts, UINT32 *indices, UINT32 numIndices)
Definition: Model.cpp:171
A model represents a 3D model (.obj files for now) with vertices and indecies.
Definition: Model.h:15
void CreateBuffers()
Definition: Model.cpp:155
FORCEINLINE const std::vector< Vertex > & GetVerts() const
Definition: Model.h:40
entt::hashed_string Guid
Definition: FlingTypes.h:26
FORCEINLINE Buffer * GetIndexBuffer() const
Definition: Model.h:38
FORCEINLINE const std::vector< UINT32 > & GetIndices() const
Definition: Model.h:41
FORCEINLINE UINT32 GetVertexCount() const
Definition: Model.h:44
FORCEINLINE UINT32 GetIndexCount() const
Definition: Model.h:43
static std::shared_ptr< Fling::Model > Quad()
Creates a quad primitive model.
Definition: Model.cpp:15
A Buffer represents a Vulkan buffer with a size, buffer pointer, and buffer memory.
Definition: Buffer.h:11
uint32_t UINT32
Definition: FlingTypes.h:13
Definition: Engine.h:29
Buffer * m_VertexBuffer
Definition: Model.h:57
static constexpr VkIndexType GetIndexType()
Definition: Model.h:46
static std::shared_ptr< Fling::Model > Create(Guid t_ID)
Definition: Model.cpp:10