Added the basics for a scene explorer in ImGui
This commit is contained in:
parent
6a2e8d3b2f
commit
e31fd036ea
@ -6,7 +6,7 @@
|
||||
class Node {
|
||||
public:
|
||||
Node(const std::string& name);
|
||||
const std::string& name;
|
||||
std::string name;
|
||||
Node* parent;
|
||||
std::vector<Node*> children;
|
||||
|
||||
|
@ -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");
|
||||
|
@ -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);
|
||||
void materialWindow(Material& material, std::string PanelName);
|
||||
void SceneExplorer(Scene& scene, std::string PanelName);
|
||||
|
@ -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");
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user