#include #include "GUI.h" #include "Util.h" #include #include "../../YoggieEngine/src/BarinkEngine.h" #include "../../YoggieEngine/src/Scene/Components.h" #include "../../YoggieEngine/src/Scene/Scene.h" #include "../../YoggieEngine/src/Scene/Entity.h" #include "../../YoggieEngine/src/AssetManager/ModelImporter.h" #include "../../YoggieEngine/src/PerfCounter.h" /* * Define globals */ Scene scene; BarinkEngine::Renderable* renderable; BarinkEngine::SceneObject* object; Entity cube; /* * Runs once at startup * - USe to initialize the game/sandbox/demo */ void Start() { auto importer = BarinkEngine::ModelImporter(); // Load in asset(S) object = importer.Import("build/Debug/Models/Cube.obj"); renderable = object->renderable; // Add Entities to the scene cube = scene.AddEntity("cube"); auto& render3DComponent = cube.AddComponent(); render3DComponent.mesh = *renderable->mesh; cube.GetComponent() .transform = glm::rotate(glm::mat4(1.0f), 32.0f, glm::vec3(0.5f,1.0f,0.0f)); // Create a second cube auto cube2 = scene.AddEntity("Cube2"); auto& cube2Render = cube2.AddComponent(); cube2Render.mesh = *renderable->mesh; cube2Render.color = glm::vec3(0.0f, 1.0f, 0.0f); auto& cube2Trans = cube2.GetComponent(); cube2Trans.transform = glm::translate( glm::mat4(1.0f), glm::vec3(1.0f,0.0f, 5.0f)); // Create a light auto AmbientLight = scene.AddEntity("AmbientLight"); AmbientLight.AddComponent(); renderer.Prepare(scene); } /* * Runs every frame * - Use to draw Immediate mode graphics (Not meant for HUD's ) */ void ImmediateGraphicsDraw() { // Show internal BarinkEngine stats EngineInstrumentation::ShowStats(); ImGui::Begin("Scene view"); auto group = scene.getReg().view(); group.each([](auto entity, BarinkEngine::IdentifierComponent& identifier) { ImGui::Text("%s", identifier.name.c_str()); }); ImGui::End(); ImGui::ShowMetricsWindow(); ImGui::Begin("Settings"); auto& a = cube.GetComponent(); auto& b = cube.GetComponent(); ImGui::DragFloat3("Color", &a.color[0], 0.01f, 0.0f, 1.0f); ImGui::DragFloat3("Position", &b.transform[3][0], 0.01f, 0.0f, 16.0f); auto l = scene.getReg().view(); l.each([](auto entity, BarinkEngine::LightComponent& light) { ImGui::Text("Lighting"); ImGui::SliderFloat("Intensity", &light.Strength, 0.0f, 1.0f); ImGui::SliderFloat3("l-Color", &light.Color[0], 0.0f, 1.0f); }); ImGui::End(); } /* * Runs every frame * - Meant for game logic ( non-physics related) */ void Update() { } void Render() { renderer.Render(scene); } /* * Runs at the end of the program * - Meant for cleanup */ void Stop() { }