Made Scene Manager actual load and save scene
One bug is the Load does not load the VAO because im going to make it call the Asset manager to load the model from disk
This commit is contained in:
parent
d204e68cf3
commit
c7f163245a
56
Default.scene
Normal file
56
Default.scene
Normal file
@ -0,0 +1,56 @@
|
||||
Entities:
|
||||
- ID: 0
|
||||
Name: Default
|
||||
Components:
|
||||
Mesh:
|
||||
vao: 1
|
||||
indexCount: 36
|
||||
textureID: 1
|
||||
Transform:
|
||||
Position: [0, 2.79999995, -12.6000004]
|
||||
Rotation: [0, 0.5, -20.6000004]
|
||||
Scale: [1, 1, 1]
|
||||
- ID: 1
|
||||
Name: New GameObject 1
|
||||
Components:
|
||||
Mesh:
|
||||
vao: 3
|
||||
indexCount: 36
|
||||
textureID: 2
|
||||
Transform:
|
||||
Position: [-11.8999996, -2, -21.7999992]
|
||||
Rotation: [-9, -18.6000004, -28.1000004]
|
||||
Scale: [1, 1, 1]
|
||||
- ID: 2
|
||||
Name: New GameObject 2
|
||||
Components:
|
||||
Mesh:
|
||||
vao: 4
|
||||
indexCount: 36
|
||||
textureID: 3
|
||||
Transform:
|
||||
Position: [7.80000019, -8.10000038, -20.6000004]
|
||||
Rotation: [-86.3000031, 0, -66]
|
||||
Scale: [1, 1, 1]
|
||||
- ID: 3
|
||||
Name: New GameObject 3
|
||||
Components:
|
||||
Mesh:
|
||||
vao: 5
|
||||
indexCount: 36
|
||||
textureID: 4
|
||||
Transform:
|
||||
Position: [-1.20000005, -3.4000001, -17.7000008]
|
||||
Rotation: [-23.5, 15.8999996, -59.9000015]
|
||||
Scale: [1, 1, 1]
|
||||
- ID: 4
|
||||
Name: New GameObject 4
|
||||
Components:
|
||||
Mesh:
|
||||
vao: 6
|
||||
indexCount: 36
|
||||
textureID: 5
|
||||
Transform:
|
||||
Position: [6.80000019, 0.800000012, -12]
|
||||
Rotation: [-17.2999992, -16.1000004, -19.2999992]
|
||||
Scale: [1, 1, 1]
|
20
imgui.ini
20
imgui.ini
@ -1,6 +1,6 @@
|
||||
[Window][DockSpace]
|
||||
Pos=0,0
|
||||
Size=1280,720
|
||||
Size=1920,1177
|
||||
Collapsed=0
|
||||
|
||||
[Window][Debug##Default]
|
||||
@ -9,26 +9,26 @@ Size=400,400
|
||||
Collapsed=0
|
||||
|
||||
[Window][Inspector]
|
||||
Pos=948,27
|
||||
Size=324,352
|
||||
Pos=1588,27
|
||||
Size=324,587
|
||||
Collapsed=0
|
||||
DockId=0x00000005,0
|
||||
|
||||
[Window][OpenGL Output]
|
||||
Pos=374,27
|
||||
Size=572,313
|
||||
Size=1212,770
|
||||
Collapsed=0
|
||||
DockId=0x00000003,0
|
||||
|
||||
[Window][Performance]
|
||||
Pos=948,381
|
||||
Size=324,331
|
||||
Pos=1588,616
|
||||
Size=324,553
|
||||
Collapsed=0
|
||||
DockId=0x00000006,0
|
||||
|
||||
[Window][Logger]
|
||||
Pos=374,342
|
||||
Size=572,370
|
||||
Pos=374,799
|
||||
Size=1212,370
|
||||
Collapsed=0
|
||||
DockId=0x00000004,0
|
||||
|
||||
@ -40,12 +40,12 @@ DockId=0x00000007,0
|
||||
|
||||
[Window][Scene Window]
|
||||
Pos=8,27
|
||||
Size=364,685
|
||||
Size=364,1142
|
||||
Collapsed=0
|
||||
DockId=0x00000009,0
|
||||
|
||||
[Docking][Data]
|
||||
DockSpace ID=0x14621557 Window=0x3DA2F1DE Pos=8,27 Size=1264,685 Split=X Selected=0xF7365A5A
|
||||
DockSpace ID=0x14621557 Window=0x3DA2F1DE Pos=8,27 Size=1904,1142 Split=X Selected=0xF7365A5A
|
||||
DockNode ID=0x00000009 Parent=0x14621557 SizeRef=364,1142 HiddenTabBar=1 Selected=0x3DC5AC3F
|
||||
DockNode ID=0x0000000A Parent=0x14621557 SizeRef=1538,1142 Split=X
|
||||
DockNode ID=0x00000007 Parent=0x0000000A SizeRef=357,1142 Selected=0x7737E8B2
|
||||
|
@ -3,6 +3,13 @@
|
||||
#include "Transform.h"
|
||||
#include <iostream>
|
||||
|
||||
#include "../Windows/LoggerWindow.h"
|
||||
|
||||
|
||||
|
||||
extern LoggerWindow *g_LoggerWindow;
|
||||
|
||||
|
||||
GameObject::GameObject(int id, const std::string &name)
|
||||
: id(id), name(name)
|
||||
{
|
||||
@ -50,6 +57,8 @@ YAML::Node GameObject::Serialize()
|
||||
|
||||
void GameObject::Deserialize(const YAML::Node &node)
|
||||
{
|
||||
|
||||
|
||||
if (node["ID"])
|
||||
{
|
||||
id = node["ID"].as<int>();
|
||||
@ -61,8 +70,10 @@ void GameObject::Deserialize(const YAML::Node &node)
|
||||
if (node["Components"])
|
||||
{
|
||||
YAML::Node componentsNode = node["Components"];
|
||||
|
||||
for (auto it = componentsNode.begin(); it != componentsNode.end(); ++it)
|
||||
{
|
||||
|
||||
std::string compName = it->first.as<std::string>();
|
||||
YAML::Node compNode = it->second;
|
||||
|
||||
@ -72,9 +83,16 @@ void GameObject::Deserialize(const YAML::Node &node)
|
||||
transform->Deserialize(compNode);
|
||||
AddComponent(transform);
|
||||
}
|
||||
if (compName == MeshComponent::GetStaticName())
|
||||
{
|
||||
auto mesh = std::make_shared<MeshComponent>();
|
||||
mesh->Deserialize(compNode);
|
||||
AddComponent(mesh);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "[Poly] [De/Serialize] [ERROR] Invalid Component Type '" << compName << "' Skipping" << std::endl;
|
||||
g_LoggerWindow->AddLog("[SceneManager] Failed to load Component: %s", compName.c_str());
|
||||
|
||||
}
|
||||
// Add deserialization for other components as needed
|
||||
}
|
||||
|
@ -37,6 +37,8 @@ AssetManager g_AssetManager;
|
||||
|
||||
LoggerWindow *g_LoggerWindow;
|
||||
|
||||
SceneManager g_SceneManager;
|
||||
|
||||
std::vector<std::shared_ptr<GameObject>> g_GameObjects;
|
||||
|
||||
int g_GPU_Triangles_drawn_to_screen = 0;
|
||||
@ -322,11 +324,14 @@ void MyEngine::ShowDockSpace()
|
||||
if (ImGui::MenuItem("Save"))
|
||||
{
|
||||
m_LoggerWindow->AddLog("Saveing Scene");
|
||||
g_SceneManager.SaveScene(g_GameObjects, "./Default.scene");
|
||||
|
||||
}
|
||||
if (ImGui::MenuItem("Load"))
|
||||
{
|
||||
m_LoggerWindow->AddLog("Loading Scene");
|
||||
g_SceneManager.LoadScene(g_GameObjects, "./Default.scene");
|
||||
|
||||
|
||||
}
|
||||
ImGui::EndMenu();
|
||||
|
@ -45,7 +45,7 @@ void* AssetManager::loadAsset(AssetType type, const std::string& path)
|
||||
|
||||
LoaddedAssets += 1;
|
||||
|
||||
g_LoggerWindow->AddLog("Loadded Asset: %s", path.c_str());
|
||||
g_LoggerWindow->AddLog("[AsseetManager] Loadded Asset: %s", path.c_str());
|
||||
|
||||
// 5) Return pointer
|
||||
return assetData;
|
||||
|
@ -1,9 +1,9 @@
|
||||
#include "SceneManager.h"
|
||||
|
||||
#include "Component.h"
|
||||
#include "Transform.h"
|
||||
#include "Mesh.h"
|
||||
#include "GameObject.h"
|
||||
#include "./Componenets/Component.h"
|
||||
#include "./Componenets/Transform.h"
|
||||
#include "./Componenets/Mesh.h"
|
||||
#include "./Componenets/GameObject.h"
|
||||
|
||||
|
||||
#include <yaml-cpp/yaml.h>
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "GameObject.h"
|
||||
|
||||
#include "./Componenets/GameObject.h"
|
||||
|
||||
|
||||
|
||||
|
@ -284,7 +284,7 @@ void SetupImGuiStyle_Windark()
|
||||
|
||||
void ThemeManager_ChangeTheme(int ThemeID)
|
||||
{
|
||||
g_LoggerWindow->AddLog("Changed Global Theme To: %d", ThemeID);
|
||||
g_LoggerWindow->AddLog("[ThemeManager] Changed Global Theme To: %d", ThemeID);
|
||||
|
||||
switch (ThemeID) {
|
||||
case 0:
|
||||
|
Loading…
Reference in New Issue
Block a user