| 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
Fling::Model::m_Indices
std::vector< UINT32 > m_Indices
Definition: Model.h:55
Fling::Model::~Model
~Model()
Definition: Model.cpp:92
Fling::Model::m_IndexBuffer
Buffer * m_IndexBuffer
Definition: Model.h:58
Fling::Resource
Base class that represents a loaded resource in the engine.
Definition: Resource.h:11
Fling::Model::m_Verts
std::vector< Vertex > m_Verts
Definition: Model.h:54
Fling::Model::LoadModel
void LoadModel()
Load this model from Tiny Obj loader.
Definition: Model.cpp:99
Fling::Model::GetVertexBuffer
FORCEINLINE Buffer * GetVertexBuffer() const
Definition: Model.h:37
Fling::Vertex
Basic Vertex outline for use with our vertex buffers.
Definition: Vertex.h:10
Fling::Model::Model
Model(Guid t_ID)
Construct a new model object.
Definition: Model.cpp:76
Resource.h
Fling::Model::CalculateVertexTangents
static void CalculateVertexTangents(Vertex *verts, UINT32 numVerts, UINT32 *indices, UINT32 numIndices)
Definition: Model.cpp:171
Fling::Model
A model represents a 3D model (.obj files for now) with vertices and indecies.
Definition: Model.h:15
Fling::Model::CreateBuffers
void CreateBuffers()
Definition: Model.cpp:155
Vertex.h
Fling::Model::GetVerts
FORCEINLINE const std::vector< Vertex > & GetVerts() const
Definition: Model.h:40
Fling::Guid
entt::hashed_string Guid
Definition: FlingTypes.h:26
Fling::Model::GetIndexBuffer
FORCEINLINE Buffer * GetIndexBuffer() const
Definition: Model.h:38
Fling::Model::GetIndices
FORCEINLINE const std::vector< UINT32 > & GetIndices() const
Definition: Model.h:41
Fling::Model::GetVertexCount
FORCEINLINE UINT32 GetVertexCount() const
Definition: Model.h:44
Fling::Model::GetIndexCount
FORCEINLINE UINT32 GetIndexCount() const
Definition: Model.h:43
Fling::Model::Quad
static std::shared_ptr< Fling::Model > Quad()
Creates a quad primitive model.
Definition: Model.cpp:15
Fling::Buffer
A Buffer represents a Vulkan buffer with a size, buffer pointer, and buffer memory.
Definition: Buffer.h:11
UINT32
uint32_t UINT32
Definition: FlingTypes.h:13
Buffer.h
Fling
Definition: Engine.h:29
Fling::Model::m_VertexBuffer
Buffer * m_VertexBuffer
Definition: Model.h:57
Fling::Model::GetIndexType
static constexpr VkIndexType GetIndexType()
Definition: Model.h:46
Fling::Model::Create
static std::shared_ptr< Fling::Model > Create(Guid t_ID)
Definition: Model.cpp:10