3 #include <glm/glm.force.hpp>
4 #include <alicorn/boost/filesystem.forward.hpp>
5 #include <Covellite/Api/Vertex.hpp>
6 #include "IGameObject.hpp"
36 using String_t = ::alicorn::extension::std::String;
38 using IGameObjectPtr_t = ::std::shared_ptr<IGameObject>;
39 using Material_t = ::std::map<String_t, ::std::vector<Index_t>>;
42 using Path_t = ::boost::filesystem::path;
47 size_t GetType(
void)
const final;
54 static IGameObjectPtr_t
Create(
const Support::Value);
55 static IGameObjectPtr_t
Create(
const Extra::Value);
57 static IGameObjectPtr_t
Create(
const Another::Value,
const GameScenePtr_t &);
66 using Hash_t = uint64_t;
69 Hash_t Hash =
static_cast<Hash_t
>(-1);
70 Vertex_t m_Vertex = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f };
73 class Triangle_t final
77 String_t MaterialName = uT(
"Unknown");
81 virtual Object_t
GetObject(
const Any_t & = Any_t{})
const;
84 using cbVertex_t = ::std::function<void(
const Vertex &, const ::std::size_t)>;
85 void Add(
const Triangle_t &,
const cbVertex_t & =
nullptr);
86 ::std::size_t GetAllVertexCount(
void)
const {
return m_Vertexes.size(); }
87 void BuildBasementObject(
const float);
88 static Point GetPoint(
const float,
const float = 0.5f);
91 ::std::map<Vertex::Hash_t, Index_t> m_iVertexes;
94 const String_t m_MeshId;
95 ::std::vector<Vertex_t> m_Vertexes;
96 mutable Material_t m_MaterialIndices;
99 explicit Mesh(const ::std::vector<Triangle_t> & = {});
100 virtual ~Mesh(
void) =
default;
106 Object_t
GetObject(
void)
const {
return { m_pTexture }; }
107 float GetRatioXY(
void)
const {
return m_RatioXY; }
110 Component_t::ComponentPtr_t m_pTexture;
114 explicit Texture(
const Path_t &);
118 static Object_t GetShaderObject(
const bool =
false);
119 size_t AddTexture(
const Path_t &);
120 const Texture & GetTexture(
const size_t)
const;
121 template<
class TMesh,
class TData>
122 size_t AddMesh(
const TData &)
const;
123 template<
class TMesh,
class TData>
124 size_t AddMesh(
const TData &,
const float,
const Rect &)
const;
125 Mesh & GetMesh(
const size_t)
const;
129 mutable ::std::vector<::std::unique_ptr<Texture>> m_Textures;
130 mutable ::std::vector<::std::unique_ptr<Mesh>> m_Meshes;
136 template<
class TMesh,
class TData>
137 inline size_t GameObject::AddMesh(
const TData & _Data)
const
139 m_Meshes.push_back(::std::make_unique<TMesh>(_Data));
140 return m_Meshes.size() - 1;
143 template<
class TMesh,
class TData>
144 inline size_t GameObject::AddMesh(
146 const float _TextureRatioXY,
147 const Rect & _TextureCoord)
const
150 ::std::make_unique<TMesh>(_Data, _TextureRatioXY, _TextureCoord));
151 return m_Meshes.size() - 1;