SpiecsEngine
 
Loading...
Searching...
No Matches
SpriteComponent.cpp
Go to the documentation of this file.
1/**
2* @file SpriteComponent.cpp.
3* @brief The SpriteComponent Class Implementation.
4* @author Spices.
5*/
6
7#include "Pchheader.h"
9#include "Render/FrameInfo.h"
10#include "World/Entity.h"
11
12namespace Spices {
13
15 {
17
18 std::shared_ptr<PlanePack> pack = std::make_shared<PlanePack>(2, 2);
19 //pack->SetMaterial(path);
20
21 // spritecomponent only take one meshpack
22 m_Mesh = Mesh::Builder().AddPack(pack).Build();
23 }
24
25 void SpriteComponent::SetMaterial(const std::string& materialPath)
26 {
28
29 auto& e = FrameInfo::Get().m_World->QueryEntitybyID((uint32_t)m_Owner);
30
31 m_Mesh->GetPacks().for_each([&](auto& k, auto& v) {
32 v->SetMaterial(materialPath);
33 v->GetMeshDesc().UpdatemodelAddress(e.GetComponent<TransformComponent>().GetModelBufferAddress());
34 v->GetMeshDesc().UpdateentityID((uint32_t)m_Owner);
35 return false;
36 });
37 }
38}
#define SPICES_PROFILE_ZONE
PlanePack Class. This class defines plane type mesh pack.
Definition MeshPack.h:397
SpriteComponent()
Constructor Function.
void SetMaterial(const std::string &materialPath)
Set Sprite Material.
SpriteComponent Class. This class defines the specific behaves of SpriteComponent.