Fixed sprites not working

This commit is contained in:
antopilo
2024-10-15 19:00:56 -04:00
parent 28bbb255c5
commit 534c35c76f
9 changed files with 1683 additions and 655 deletions

View File

@@ -15,8 +15,15 @@ namespace Nuake
{
}
bool SpriteComponent::LoadSprite()
void SpriteComponent::SetSprite(ResourceFile path)
{
if (!FileSystem::FileExists(path.GetRelativePath()))
{
return;
}
SpritePath = FileSystem::GetFile(path.GetRelativePath());
std::vector<Vertex> quadVertices =
{
{ Vector3(-1.0f, 1.0f, 0.0f), Vector2(0.0f, 1.0f), Vector3(0, 0, 1), Vector3(1, 0, 0), Vector3(0, 1, 0) },
@@ -40,6 +47,10 @@ namespace Nuake
Ref<Material> material = MaterialManager::Get()->GetMaterial(absPath);
bool hasNormal = material->HasNormal();
SpriteMesh->SetMaterial(material);
}
bool SpriteComponent::LoadSprite()
{
return true;
}
@@ -67,6 +78,7 @@ namespace Nuake
}
DESERIALIZE_RES_FILE(SpritePath);
SetSprite(SpritePath);
if (j.contains("PositionFacing"))
{

View File

@@ -19,7 +19,9 @@ namespace Nuake
BindComponentField<&SpriteComponent::Billboard>("Billboard", "Billboard");
BindComponentField<&SpriteComponent::LockYRotation>("LockYRotation", "Lock Y Rotation");
BindComponentField<&SpriteComponent::PositionFacing>("PositionFacing", "Position Facing");
BindComponentField<&SpriteComponent::SpritePath>("SpritePath", "Sprite Path");
//BindComponentField<&SpriteComponent::SpritePath>("SpritePath", "Sprite Path");
BindComponentProperty<&SpriteComponent::SetSprite, &SpriteComponent::GetSprite>("SpritePath", "Sprite Path");
ResourceFileRestriction("_Image");
}
public:
@@ -33,6 +35,12 @@ namespace Nuake
SpriteComponent();
public:
void SetSprite(ResourceFile file);
ResourceFile GetSprite()
{
return SpritePath;
}
bool LoadSprite();
json Serialize();