More config and testing adding models
Seperated Sanbox premake config from the main premake file.
This commit is contained in:
		@ -1,9 +1,9 @@
 | 
			
		||||
#pragma once
 | 
			
		||||
#include "imgui.h"
 | 
			
		||||
#include <BarinkEngine.h>
 | 
			
		||||
 | 
			
		||||
void CameraTool(Camera* camera);
 | 
			
		||||
void ScriptingTool(char* code);
 | 
			
		||||
void transformWindow(Transform& transform, std::string PanelName);
 | 
			
		||||
void materialWindow(Material& material, std::string PanelName);
 | 
			
		||||
void SceneExplorer(Scene& scene, std::string PanelName);
 | 
			
		||||
#pragma once
 | 
			
		||||
#include "imgui.h"
 | 
			
		||||
#include <BarinkEngine.h>
 | 
			
		||||
 | 
			
		||||
void CameraTool(Camera* camera);
 | 
			
		||||
void ScriptingTool(char* code);
 | 
			
		||||
void transformWindow(Transform& transform, std::string PanelName);
 | 
			
		||||
void materialWindow(Material& material, std::string PanelName);
 | 
			
		||||
void SceneExplorer(Scene& scene, std::string PanelName);
 | 
			
		||||
@ -1,12 +1,12 @@
 | 
			
		||||
# Blender 3.1.2 MTL File: 'None'
 | 
			
		||||
# www.blender.org
 | 
			
		||||
 | 
			
		||||
newmtl Material
 | 
			
		||||
Ns 360.000000
 | 
			
		||||
Ka 1.000000 1.000000 1.000000
 | 
			
		||||
Kd 0.800000 0.800000 0.800000
 | 
			
		||||
Ks 0.500000 0.500000 0.500000
 | 
			
		||||
Ke 0.000000 0.000000 0.000000
 | 
			
		||||
Ni 1.450000
 | 
			
		||||
d 1.000000
 | 
			
		||||
illum 2
 | 
			
		||||
# Blender 3.1.2 MTL File: 'None'
 | 
			
		||||
# www.blender.org
 | 
			
		||||
 | 
			
		||||
newmtl Material
 | 
			
		||||
Ns 360.000000
 | 
			
		||||
Ka 1.000000 1.000000 1.000000
 | 
			
		||||
Kd 0.800000 0.800000 0.800000
 | 
			
		||||
Ks 0.500000 0.500000 0.500000
 | 
			
		||||
Ke 0.000000 0.000000 0.000000
 | 
			
		||||
Ni 1.450000
 | 
			
		||||
d 1.000000
 | 
			
		||||
illum 2
 | 
			
		||||
@ -1,40 +1,40 @@
 | 
			
		||||
# Blender 3.1.2
 | 
			
		||||
# www.blender.org
 | 
			
		||||
mtllib Cube.mtl
 | 
			
		||||
o Cube
 | 
			
		||||
v 1.000000 1.000000 -1.000000
 | 
			
		||||
v 1.000000 -1.000000 -1.000000
 | 
			
		||||
v 1.000000 1.000000 1.000000
 | 
			
		||||
v 1.000000 -1.000000 1.000000
 | 
			
		||||
v -1.000000 1.000000 -1.000000
 | 
			
		||||
v -1.000000 -1.000000 -1.000000
 | 
			
		||||
v -1.000000 1.000000 1.000000
 | 
			
		||||
v -1.000000 -1.000000 1.000000
 | 
			
		||||
vn -0.0000 1.0000 -0.0000
 | 
			
		||||
vn -0.0000 -0.0000 1.0000
 | 
			
		||||
vn -1.0000 -0.0000 -0.0000
 | 
			
		||||
vn -0.0000 -1.0000 -0.0000
 | 
			
		||||
vn 1.0000 -0.0000 -0.0000
 | 
			
		||||
vn -0.0000 -0.0000 -1.0000
 | 
			
		||||
vt 0.625000 0.500000
 | 
			
		||||
vt 0.375000 0.500000
 | 
			
		||||
vt 0.625000 0.750000
 | 
			
		||||
vt 0.375000 0.750000
 | 
			
		||||
vt 0.875000 0.500000
 | 
			
		||||
vt 0.625000 0.250000
 | 
			
		||||
vt 0.125000 0.500000
 | 
			
		||||
vt 0.375000 0.250000
 | 
			
		||||
vt 0.875000 0.750000
 | 
			
		||||
vt 0.625000 1.000000
 | 
			
		||||
vt 0.625000 0.000000
 | 
			
		||||
vt 0.375000 1.000000
 | 
			
		||||
vt 0.375000 0.000000
 | 
			
		||||
vt 0.125000 0.750000
 | 
			
		||||
s 0
 | 
			
		||||
usemtl Material
 | 
			
		||||
f 1/1/1 5/5/1 7/9/1 3/3/1
 | 
			
		||||
f 4/4/2 3/3/2 7/10/2 8/12/2
 | 
			
		||||
f 8/13/3 7/11/3 5/6/3 6/8/3
 | 
			
		||||
f 6/7/4 2/2/4 4/4/4 8/14/4
 | 
			
		||||
f 2/2/5 1/1/5 3/3/5 4/4/5
 | 
			
		||||
f 6/8/6 5/6/6 1/1/6 2/2/6
 | 
			
		||||
# Blender 3.1.2
 | 
			
		||||
# www.blender.org
 | 
			
		||||
mtllib Cube.mtl
 | 
			
		||||
o Cube
 | 
			
		||||
v 1.000000 1.000000 -1.000000
 | 
			
		||||
v 1.000000 -1.000000 -1.000000
 | 
			
		||||
v 1.000000 1.000000 1.000000
 | 
			
		||||
v 1.000000 -1.000000 1.000000
 | 
			
		||||
v -1.000000 1.000000 -1.000000
 | 
			
		||||
v -1.000000 -1.000000 -1.000000
 | 
			
		||||
v -1.000000 1.000000 1.000000
 | 
			
		||||
v -1.000000 -1.000000 1.000000
 | 
			
		||||
vn -0.0000 1.0000 -0.0000
 | 
			
		||||
vn -0.0000 -0.0000 1.0000
 | 
			
		||||
vn -1.0000 -0.0000 -0.0000
 | 
			
		||||
vn -0.0000 -1.0000 -0.0000
 | 
			
		||||
vn 1.0000 -0.0000 -0.0000
 | 
			
		||||
vn -0.0000 -0.0000 -1.0000
 | 
			
		||||
vt 0.625000 0.500000
 | 
			
		||||
vt 0.375000 0.500000
 | 
			
		||||
vt 0.625000 0.750000
 | 
			
		||||
vt 0.375000 0.750000
 | 
			
		||||
vt 0.875000 0.500000
 | 
			
		||||
vt 0.625000 0.250000
 | 
			
		||||
vt 0.125000 0.500000
 | 
			
		||||
vt 0.375000 0.250000
 | 
			
		||||
vt 0.875000 0.750000
 | 
			
		||||
vt 0.625000 1.000000
 | 
			
		||||
vt 0.625000 0.000000
 | 
			
		||||
vt 0.375000 1.000000
 | 
			
		||||
vt 0.375000 0.000000
 | 
			
		||||
vt 0.125000 0.750000
 | 
			
		||||
s 0
 | 
			
		||||
usemtl Material
 | 
			
		||||
f 1/1/1 5/5/1 7/9/1 3/3/1
 | 
			
		||||
f 4/4/2 3/3/2 7/10/2 8/12/2
 | 
			
		||||
f 8/13/3 7/11/3 5/6/3 6/8/3
 | 
			
		||||
f 6/7/4 2/2/4 4/4/4 8/14/4
 | 
			
		||||
f 2/2/5 1/1/5 3/3/5 4/4/5
 | 
			
		||||
f 6/8/6 5/6/6 1/1/6 2/2/6
 | 
			
		||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										40
									
								
								SandboxApplication/premake5.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								SandboxApplication/premake5.lua
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,40 @@
 | 
			
		||||
project "SandboxApplication"
 | 
			
		||||
kind "ConsoleApp"
 | 
			
		||||
 | 
			
		||||
buildmessage "Building Sandbox ..."
 | 
			
		||||
 | 
			
		||||
links{
 | 
			
		||||
  "BarinkEngine"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
includedirs{
 | 
			
		||||
  "./../BarinkEngine/Include",
 | 
			
		||||
 | 
			
		||||
  -- I'd prefer if didn't need these..
 | 
			
		||||
  -- We'll figure that out some time later
 | 
			
		||||
  "./../libs/lua/include",
 | 
			
		||||
  "./../libs/spdlog/include",
 | 
			
		||||
  "./../libs/glm",
 | 
			
		||||
  "./../libs/GorillaAudio/include",
 | 
			
		||||
 | 
			
		||||
  "./../libs/assimp/include",
 | 
			
		||||
  "./../libs/glad/include",
 | 
			
		||||
  "./../libs/glfw/include",
 | 
			
		||||
  "./../libs/tinygltf",
 | 
			
		||||
  "./../libs/glew/include",
 | 
			
		||||
  "./../libs/glm",
 | 
			
		||||
  "./../libs/ImGui",
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  "./include"
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
libdirs {
 | 
			
		||||
  './../build/BarinkEngine/Debug'
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
files { 
 | 
			
		||||
  "./include/*.h",
 | 
			
		||||
  "./src/*.cpp"
 | 
			
		||||
}
 | 
			
		||||
@ -1,71 +1,71 @@
 | 
			
		||||
#include "GUI.h"
 | 
			
		||||
 | 
			
		||||
void SceneExplorer(Scene& scene, std::string PanelName) {
 | 
			
		||||
    if (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");
 | 
			
		||||
 | 
			
		||||
    ImGui::SliderFloat("Zoom:", &cam->Zoom, 10, 190);
 | 
			
		||||
 | 
			
		||||
    ImGui::InputFloat3("Position:", &cam->Position[0]);
 | 
			
		||||
 | 
			
		||||
    ImGui::InputFloat3("Rotation:", &cam->Rotation[0]);
 | 
			
		||||
 | 
			
		||||
    ImGui::End();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ScriptingTool(char* code) {
 | 
			
		||||
    ImGui::Begin("Scripting");
 | 
			
		||||
 | 
			
		||||
    ImGui::InputTextMultiline("Lua Script", code, 255);
 | 
			
		||||
    bool runCode = ImGui::Button("Run");
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    ImGui::End();
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void transformWindow(Transform& transform, std::string PanelName) {
 | 
			
		||||
    ImGui::Begin(PanelName.c_str());
 | 
			
		||||
    ImGui::InputFloat3("Position:", (float*)&transform.Position[0]);
 | 
			
		||||
    ImGui::InputFloat3("Rotation:", (float*)&transform.Rotation[0]);
 | 
			
		||||
    ImGui::InputFloat3("Scale:", (float*)&transform.Scale[0]);
 | 
			
		||||
    ImGui::End();
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void materialWindow(Material& material, std::string PanelName) {
 | 
			
		||||
    ImGui::Begin(PanelName.c_str());
 | 
			
		||||
    ImGui::ColorPicker3("Color:", &material.Color[0]);
 | 
			
		||||
    ImGui::End();
 | 
			
		||||
#include "GUI.h"
 | 
			
		||||
 | 
			
		||||
void SceneExplorer(Scene& scene, std::string PanelName) {
 | 
			
		||||
    if (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");
 | 
			
		||||
 | 
			
		||||
    ImGui::SliderFloat("Zoom:", &cam->Zoom, 10, 190);
 | 
			
		||||
 | 
			
		||||
    ImGui::InputFloat3("Position:", &cam->Position[0]);
 | 
			
		||||
 | 
			
		||||
    ImGui::InputFloat3("Rotation:", &cam->Rotation[0]);
 | 
			
		||||
 | 
			
		||||
    ImGui::End();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ScriptingTool(char* code) {
 | 
			
		||||
    ImGui::Begin("Scripting");
 | 
			
		||||
 | 
			
		||||
    ImGui::InputTextMultiline("Lua Script", code, 255);
 | 
			
		||||
    bool runCode = ImGui::Button("Run");
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    ImGui::End();
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void transformWindow(Transform& transform, std::string PanelName) {
 | 
			
		||||
    ImGui::Begin(PanelName.c_str());
 | 
			
		||||
    ImGui::InputFloat3("Position:", (float*)&transform.Position[0]);
 | 
			
		||||
    ImGui::InputFloat3("Rotation:", (float*)&transform.Rotation[0]);
 | 
			
		||||
    ImGui::InputFloat3("Scale:", (float*)&transform.Scale[0]);
 | 
			
		||||
    ImGui::End();
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void materialWindow(Material& material, std::string PanelName) {
 | 
			
		||||
    ImGui::Begin(PanelName.c_str());
 | 
			
		||||
    ImGui::ColorPicker3("Color:", &material.Color[0]);
 | 
			
		||||
    ImGui::End();
 | 
			
		||||
}
 | 
			
		||||
@ -1,119 +1,119 @@
 | 
			
		||||
#include "BarinkEngine.h"
 | 
			
		||||
#include "Scene\SceneManager.h"
 | 
			
		||||
#include "Scene\SceneNodeTypes.h"
 | 
			
		||||
#include "AssetManager/ModelImporter.h"
 | 
			
		||||
 | 
			
		||||
#include "imgui.h"
 | 
			
		||||
#include "GUI.h"
 | 
			
		||||
#include "Util.h"
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
* Define globals
 | 
			
		||||
*/
 | 
			
		||||
Camera* cam;
 | 
			
		||||
Shader* shader;
 | 
			
		||||
 | 
			
		||||
char* code = new char[254];
 | 
			
		||||
 | 
			
		||||
const std::string vertexShaderSource = "build/SandboxApplication/Debug/test.vs";
 | 
			
		||||
const std::string fragmentShaderSource = "build/SandboxApplication/Debug/test.fs";
 | 
			
		||||
 | 
			
		||||
BarinkEngine::ModelImporter* MI = new BarinkEngine::ModelImporter();
 | 
			
		||||
 | 
			
		||||
Scene* Level1;
 | 
			
		||||
// BarinkEngine::SceneObject* cube;
 | 
			
		||||
/*
 | 
			
		||||
* 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("Test Level");
 | 
			
		||||
    Level1 = SceneManager::CreateScene(levelName);
 | 
			
		||||
    SceneManager::LoadScene(*Level1);
 | 
			
		||||
 | 
			
		||||
    // Create a cube node
 | 
			
		||||
   
 | 
			
		||||
    // Load a model 
 | 
			
		||||
    //cube = MI->Import("build/SandboxApplication/Debug/Models/Cube.obj");
 | 
			
		||||
        
 | 
			
		||||
    //Level1->GetRoot().addChild(*cube);
 | 
			
		||||
 
 | 
			
		||||
    std::string groupName("Nested-Group");
 | 
			
		||||
    auto testGroup = new Group(groupName);
 | 
			
		||||
    Level1->GetRoot().addChild( *testGroup);
 | 
			
		||||
 | 
			
		||||
    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);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
* Runs every frame
 | 
			
		||||
* - Use to draw Immediate mode graphics (Not meant for HUD's )
 | 
			
		||||
*/
 | 
			
		||||
void ImmediateGraphicsDraw() {
 | 
			
		||||
    ImGui::NewFrame();
 | 
			
		||||
 | 
			
		||||
    // Show ImGui demo such that I can easily look
 | 
			
		||||
    // at possible GUI elements to use
 | 
			
		||||
    ImGui::ShowDemoWindow();
 | 
			
		||||
 | 
			
		||||
    // Show internal BarinkEngine stats
 | 
			
		||||
    ShowStats();
 | 
			
		||||
 | 
			
		||||
    // Show different tooling for this specific sandbox
 | 
			
		||||
    CameraTool(cam);
 | 
			
		||||
    ScriptingTool(code);
 | 
			
		||||
 | 
			
		||||
    SceneExplorer(*Level1, "Scene Explorer");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
* Runs every frame
 | 
			
		||||
* - Meant for game logic ( non-physics related) 
 | 
			
		||||
*/
 | 
			
		||||
void Update()
 | 
			
		||||
{
 | 
			
		||||
    /*
 | 
			
		||||
    * NOTE: this needs to move to the renderer
 | 
			
		||||
    * Render code should not appear in the sandbox file
 | 
			
		||||
    */
 | 
			
		||||
    //glm::mat4 projection = glm::perspective(glm::radians(cam->Zoom), (800.0f / 600.0f), 0.001f, 100.0f);
 | 
			
		||||
 | 
			
		||||
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
 | 
			
		||||
 | 
			
		||||
    shader->Use();
 | 
			
		||||
    //shader->setUniformMat4("P", projection);
 | 
			
		||||
    //shader->setUniformMat4("M", CalculateModelMat(cube->transform));
 | 
			
		||||
 | 
			
		||||
    shader->setUniformMat4("V", cam->GetViewMatrix());
 | 
			
		||||
    
 | 
			
		||||
    //cube->renderable->material->Apply();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    //Cube->Draw();
 | 
			
		||||
 | 
			
		||||
  
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
* Runs at the end of the program
 | 
			
		||||
* - Meant for cleanup
 | 
			
		||||
*/
 | 
			
		||||
void Stop() {
 | 
			
		||||
    delete MI;
 | 
			
		||||
    delete shader;
 | 
			
		||||
#include "BarinkEngine.h"
 | 
			
		||||
#include "Scene\SceneManager.h"
 | 
			
		||||
#include "Scene\SceneNodeTypes.h"
 | 
			
		||||
#include "AssetManager/ModelImporter.h"
 | 
			
		||||
 | 
			
		||||
#include "imgui.h"
 | 
			
		||||
#include "GUI.h"
 | 
			
		||||
#include "Util.h"
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
* Define globals
 | 
			
		||||
*/
 | 
			
		||||
Camera* cam;
 | 
			
		||||
Shader* shader;
 | 
			
		||||
 | 
			
		||||
char* code = new char[254];
 | 
			
		||||
 | 
			
		||||
const std::string vertexShaderSource = "../build/SandboxApplication/Debug/test.vs";
 | 
			
		||||
const std::string fragmentShaderSource = "../build/SandboxApplication/Debug/test.fs";
 | 
			
		||||
 | 
			
		||||
BarinkEngine::ModelImporter* MI = new BarinkEngine::ModelImporter();
 | 
			
		||||
 | 
			
		||||
Scene* Level1;
 | 
			
		||||
// BarinkEngine::SceneObject* cube;
 | 
			
		||||
/*
 | 
			
		||||
* 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("Test Level");
 | 
			
		||||
    Level1 = SceneManager::CreateScene(levelName);
 | 
			
		||||
    SceneManager::LoadScene(*Level1);
 | 
			
		||||
 | 
			
		||||
    // Create a cube node
 | 
			
		||||
   
 | 
			
		||||
    // Load a model 
 | 
			
		||||
    auto cube = MI->Import("../build/SandboxApplication/Debug/Models/Cube.obj");
 | 
			
		||||
    Level1->GetRoot().addChild(*cube);
 | 
			
		||||
 
 | 
			
		||||
    std::string groupName("Nested-Group");
 | 
			
		||||
    auto testGroup = new Group(groupName);
 | 
			
		||||
    Level1->GetRoot().addChild( *testGroup);
 | 
			
		||||
 | 
			
		||||
    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);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
* Runs every frame
 | 
			
		||||
* - Use to draw Immediate mode graphics (Not meant for HUD's )
 | 
			
		||||
*/
 | 
			
		||||
void ImmediateGraphicsDraw() {
 | 
			
		||||
    ImGui::NewFrame();
 | 
			
		||||
 | 
			
		||||
    // Show ImGui demo such that I can easily look
 | 
			
		||||
    // at possible GUI elements to use
 | 
			
		||||
    ImGui::ShowDemoWindow();
 | 
			
		||||
 | 
			
		||||
    // Show internal BarinkEngine stats
 | 
			
		||||
    ShowStats();
 | 
			
		||||
 | 
			
		||||
    // Show different tooling for this specific sandbox
 | 
			
		||||
    CameraTool(cam);
 | 
			
		||||
    ScriptingTool(code);
 | 
			
		||||
 | 
			
		||||
    SceneExplorer(*Level1, "Scene Explorer");
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
* Runs every frame
 | 
			
		||||
* - Meant for game logic ( non-physics related) 
 | 
			
		||||
*/
 | 
			
		||||
void Update()
 | 
			
		||||
{
 | 
			
		||||
    /*
 | 
			
		||||
    * NOTE: this needs to move to the renderer
 | 
			
		||||
    * Render code should not appear in the sandbox file
 | 
			
		||||
    */
 | 
			
		||||
    //glm::mat4 projection = glm::perspective(glm::radians(cam->Zoom), (800.0f / 600.0f), 0.001f, 100.0f);
 | 
			
		||||
 | 
			
		||||
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
 | 
			
		||||
 | 
			
		||||
    shader->Use();
 | 
			
		||||
    //shader->setUniformMat4("P", projection);
 | 
			
		||||
    //shader->setUniformMat4("M", CalculateModelMat(cube->transform));
 | 
			
		||||
 | 
			
		||||
    shader->setUniformMat4("V", cam->GetViewMatrix());
 | 
			
		||||
    
 | 
			
		||||
    //cube->renderable->material->Apply();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    //Cube->Draw();
 | 
			
		||||
 | 
			
		||||
  
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
* Runs at the end of the program
 | 
			
		||||
* - Meant for cleanup
 | 
			
		||||
*/
 | 
			
		||||
void Stop() {
 | 
			
		||||
    delete MI;
 | 
			
		||||
    delete shader;
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user