diff --git a/BarinkEngine/Include/Scene/Node.h b/BarinkEngine/Include/Scene/Node.h index 18bb6a0..30fb55a 100644 --- a/BarinkEngine/Include/Scene/Node.h +++ b/BarinkEngine/Include/Scene/Node.h @@ -6,7 +6,7 @@ class Node { public: Node(const std::string& name); - const std::string& name; + std::string name; Node* parent; std::vector children; diff --git a/SandboxApplication/GUI.cpp b/SandboxApplication/GUI.cpp index 67a3597..733fb66 100644 --- a/SandboxApplication/GUI.cpp +++ b/SandboxApplication/GUI.cpp @@ -1,5 +1,32 @@ #include "GUI.h" +void SceneExplorer(Scene& scene, std::string PanelName) { + ImGui::Begin(PanelName.c_str()); + + ImGui::ListBoxHeader("##ObjectList"); + + Node& current = scene.GetRoot(); + + Node* next = ¤t; + + // Show first node + ImGui::Selectable(next->name.c_str(), true); + + ImGui::Indent(); + + if (next->children.size() != 0) { + for (auto child : next->children) + { + std::string& name = child->name; + ImGui::Selectable(name.c_str(), false); + } + } + + ImGui::ListBoxFooter(); + + ImGui::End(); +} + void CameraTool(Camera* cam) { ImGui::Begin("Camera"); diff --git a/SandboxApplication/GUI.h b/SandboxApplication/GUI.h index 0c50348..ec1f835 100644 --- a/SandboxApplication/GUI.h +++ b/SandboxApplication/GUI.h @@ -5,4 +5,5 @@ void CameraTool(Camera* camera); void ScriptingTool(char* code); void transformWindow(Transform& transform, std::string PanelName); -void materialWindow(Material& material, std::string PanelName); \ No newline at end of file +void materialWindow(Material& material, std::string PanelName); +void SceneExplorer(Scene& scene, std::string PanelName); diff --git a/SandboxApplication/Sandbox.cpp b/SandboxApplication/Sandbox.cpp index 098d890..a031cdc 100644 --- a/SandboxApplication/Sandbox.cpp +++ b/SandboxApplication/Sandbox.cpp @@ -20,40 +20,41 @@ const std::string fragmentShaderSource = "build/SandboxApplication/Debug/test.fs BarinkEngine::ModelImporter* MI = new BarinkEngine::ModelImporter(); +Scene* Level1; + /* * Runs once at startup * - USe to initialize the game/sandbox/demo */ void Start() { + // Build a basic test scene + // NOTE: This will later be done through an editor // Create a level and load it as the current level - std::string levelName("TestLevel"); - auto Level1 = SceneManager::CreateScene(levelName); + std::string levelName("Test Level"); + Level1 = SceneManager::CreateScene(levelName); SceneManager::LoadScene(*Level1); - // Create a cube node // Load a model // *(MI->Import("build/SandboxApplication/Debug/Models/Cube.obj")) - // + std::string groupName("Nested-Group"); auto testGroup = new Group(groupName); Level1->GetRoot().addChild( *testGroup); - // Build a basic test scene - // NOTE: This will later be done through an editor + std::string group2Name("Nested-Group2"); + auto testGroup2 = new Group(group2Name); + Level1->GetRoot().addChild(*testGroup2); // Walk scene graph PrintSceneTree(Level1->GetRoot(),0); shader = new Shader(vertexShaderSource, fragmentShaderSource); - - cam = new Camera(glm::vec3(0.0f, 1.5f, 0.0f), glm::vec3(0.0f, 0.0f, 0.0f), 90.0f); memset(code, '\0', 254); - } @@ -68,24 +69,14 @@ void ImmediateGraphicsDraw() { // at possible GUI elements to use ImGui::ShowDemoWindow(); - // Show internal BarinkEngine stats ShowStats(); - // Show different tooling for this specific sandbox CameraTool(cam); ScriptingTool(code); - //transformWindow(Cube->transform, "Transform (Cube)"); - - //transformWindow(Cube2->transform, "Transform (Cube2)"); - - //materialWindow(*matCube, "Material Cube"); - //materialWindow(*matCube2, "Material Cube2"); - - - + SceneExplorer(*Level1, "Scene Explorer"); } /*