Move classes Mesh and StaticMesh to UwURenderEngine project. Because they depended from UwURenderEngine
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
#include "Mesh.hpp"
|
||||
|
||||
#include "Game/SaveMap/SaveMap.hpp"
|
||||
|
||||
Mesh::Mesh()
|
||||
{
|
||||
SetType(Classes::Mesh);
|
||||
}
|
||||
|
||||
std::shared_ptr<SaveMap> Mesh::save()
|
||||
{
|
||||
return std::make_shared<SaveMap>("Mesh")
|
||||
->SaveString("model_name_", model_name_)
|
||||
->connect_to(Actor::save());
|
||||
}
|
||||
|
||||
void Mesh::load(std::shared_ptr<SaveMap> save)
|
||||
{
|
||||
Actor::load(save->getParent());
|
||||
model_name_ = save->GetString("model_name_");
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "Game/Actors/Actor.hpp"
|
||||
|
||||
GENERATE_META(Mesh)
|
||||
class Mesh : public Actor
|
||||
{
|
||||
std::string model_name_;
|
||||
protected:
|
||||
void SetModelName(const std::string& new_model_name) { model_name_ = new_model_name; }
|
||||
|
||||
public:
|
||||
Mesh();
|
||||
|
||||
#pragma region ISave
|
||||
virtual std::shared_ptr<SaveMap> save() override;
|
||||
virtual void load(std::shared_ptr<SaveMap> save) override;
|
||||
#pragma endregion
|
||||
|
||||
virtual void load_model(const std::string& model_name) = 0;
|
||||
const std::string& GetModelName() const { return model_name_; }
|
||||
};
|
||||
@@ -0,0 +1,34 @@
|
||||
#include "StaticMesh.hpp"
|
||||
|
||||
#include "Core/CoreInstance.hpp"
|
||||
#include "Game/GameInstance.hpp"
|
||||
#include "Game/SaveMap/SaveMap.hpp"
|
||||
#include "Game/World/World.hpp"
|
||||
|
||||
StaticMesh::StaticMesh()
|
||||
{
|
||||
SetType(Classes::StaticMesh);
|
||||
}
|
||||
|
||||
std::shared_ptr<SaveMap> StaticMesh::save()
|
||||
{
|
||||
return std::make_shared<SaveMap>("StaticMesh")->connect_to(Mesh::save());
|
||||
}
|
||||
|
||||
void StaticMesh::load(std::shared_ptr<SaveMap> save)
|
||||
{
|
||||
Mesh::load(save->getParent());
|
||||
}
|
||||
|
||||
void StaticMesh::load_model(const std::string& model_name)
|
||||
{
|
||||
model_name_ = model_name;
|
||||
SetModelName(model_name);
|
||||
model_ = GetWorld()->GetGameInstance().GetCurrentModelManager()->LoadModel(model_name);
|
||||
}
|
||||
|
||||
void StaticMesh::OnDestroy()
|
||||
{
|
||||
Mesh::OnDestroy();
|
||||
GetWorld()->GetGameInstance().GetCurrentModelManager()->FreeModel(model_name_);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include "Mesh.hpp"
|
||||
#include "Game/ModelManager.hpp"
|
||||
|
||||
GENERATE_META(StaticMesh)
|
||||
|
||||
class StaticMesh : public Mesh
|
||||
{
|
||||
std::string model_name_;
|
||||
ModelManager::StaticModel* model_ = nullptr;
|
||||
public:
|
||||
StaticMesh();
|
||||
|
||||
#pragma region ISave
|
||||
virtual std::shared_ptr<SaveMap> save() override;
|
||||
virtual void load(std::shared_ptr<SaveMap> save) override;
|
||||
#pragma endregion
|
||||
|
||||
void load_model(const std::string& model_name) override;
|
||||
void OnDestroy() override;
|
||||
};
|
||||
+1
-3
@@ -12,9 +12,7 @@
|
||||
|
||||
#include "Game/GameInstance.hpp"
|
||||
#include "Game/World/World.hpp"
|
||||
#include "Game/Actors/Mesh/Mesh.hpp"
|
||||
|
||||
#include "GLFW/glfw3.h"
|
||||
#include "../Game/Actors/Mesh/Mesh.hpp"
|
||||
|
||||
const std::vector<const char*> UwURenderEngine::deviceExtensions = {
|
||||
VK_KHR_SWAPCHAIN_EXTENSION_NAME
|
||||
Reference in New Issue
Block a user