Added sprite mesh
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
#include "SpriteComponent.h"
|
||||
|
||||
#include "src/Core/FileSystem.h"
|
||||
#include "src/Rendering/Textures/TextureManager.h"
|
||||
#include "src/Rendering/Textures/MaterialManager.h"
|
||||
#include "src/Rendering/Vertex.h"
|
||||
|
||||
namespace Nuake
|
||||
{
|
||||
@@ -14,8 +17,22 @@ namespace Nuake
|
||||
|
||||
bool SpriteComponent::LoadSprite()
|
||||
{
|
||||
const auto texture = TextureManager::Get()->GetTexture(SpritePath);
|
||||
Sprite = texture;
|
||||
std::vector<Vertex> quadVertices =
|
||||
{
|
||||
{ Vector3(-1.0f, -1.0f, 0.0f), Vector2(0, 0), Vector3(0, 0, -1) },
|
||||
{ Vector3(1.0f, 1.0f, 0.0f), Vector2(1.0f, 1.0f), Vector3(0, 0, -1) },
|
||||
{ Vector3(-1.0f, 1.0f, 0.0f), Vector2(0.0f, 1.0f), Vector3(0, 0, -1) },
|
||||
{ Vector3(1.0f, -1.0f, 0.0f), Vector2(1.0f, 0.0f), Vector3(0, 0, -1) },
|
||||
{ Vector3(-1.0f, -1.0f, 0.0f), Vector2(0.0f, 0.0f), Vector3(0, 0, -1) },
|
||||
{ Vector3(1.0f, 1.0f, 0.0f), Vector2(1.0f, 1.0f), Vector3(0, 0, -1) }
|
||||
};
|
||||
|
||||
SpriteMesh = CreateRef<Mesh>();
|
||||
SpriteMesh->AddSurface(quadVertices, { 0, 1, 2, 3, 4, 5 });
|
||||
|
||||
auto& material = MaterialManager::Get()->GetMaterial(FileSystem::Root + SpritePath);
|
||||
SpriteMesh->SetMaterial(material);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user