More config and testing adding models

Seperated Sanbox premake config from the main premake file.
pull/13/head
Nigel Barink 2022-08-15 21:35:22 +02:00
parent db6def3bc9
commit 3974889f7e
12 changed files with 8865 additions and 8862 deletions

View File

@ -59,6 +59,9 @@ Shader::Shader(const std::string vertexShaderPath, const std::string fragmentSha
} }
char* Shader::readFile (const char* filePath){ char* Shader::readFile (const char* filePath){
spdlog::info("Opening {} ", filePath);
std::ifstream file ; std::ifstream file ;
file.open(filePath); file.open(filePath);

View File

@ -1,9 +1,9 @@
#pragma once #pragma once
#include "imgui.h" #include "imgui.h"
#include <BarinkEngine.h> #include <BarinkEngine.h>
void CameraTool(Camera* camera); void CameraTool(Camera* camera);
void ScriptingTool(char* code); void ScriptingTool(char* code);
void transformWindow(Transform& transform, std::string PanelName); 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); void SceneExplorer(Scene& scene, std::string PanelName);

View File

@ -1,12 +1,12 @@
# Blender 3.1.2 MTL File: 'None' # Blender 3.1.2 MTL File: 'None'
# www.blender.org # www.blender.org
newmtl Material newmtl Material
Ns 360.000000 Ns 360.000000
Ka 1.000000 1.000000 1.000000 Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.800000 0.800000 Kd 0.800000 0.800000 0.800000
Ks 0.500000 0.500000 0.500000 Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000 Ke 0.000000 0.000000 0.000000
Ni 1.450000 Ni 1.450000
d 1.000000 d 1.000000
illum 2 illum 2

View File

@ -1,40 +1,40 @@
# Blender 3.1.2 # Blender 3.1.2
# www.blender.org # www.blender.org
mtllib Cube.mtl mtllib Cube.mtl
o Cube 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
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 1.0000 -0.0000
vn -0.0000 -0.0000 1.0000 vn -0.0000 -0.0000 1.0000
vn -1.0000 -0.0000 -0.0000 vn -1.0000 -0.0000 -0.0000
vn -0.0000 -1.0000 -0.0000 vn -0.0000 -1.0000 -0.0000
vn 1.0000 -0.0000 -0.0000 vn 1.0000 -0.0000 -0.0000
vn -0.0000 -0.0000 -1.0000 vn -0.0000 -0.0000 -1.0000
vt 0.625000 0.500000 vt 0.625000 0.500000
vt 0.375000 0.500000 vt 0.375000 0.500000
vt 0.625000 0.750000 vt 0.625000 0.750000
vt 0.375000 0.750000 vt 0.375000 0.750000
vt 0.875000 0.500000 vt 0.875000 0.500000
vt 0.625000 0.250000 vt 0.625000 0.250000
vt 0.125000 0.500000 vt 0.125000 0.500000
vt 0.375000 0.250000 vt 0.375000 0.250000
vt 0.875000 0.750000 vt 0.875000 0.750000
vt 0.625000 1.000000 vt 0.625000 1.000000
vt 0.625000 0.000000 vt 0.625000 0.000000
vt 0.375000 1.000000 vt 0.375000 1.000000
vt 0.375000 0.000000 vt 0.375000 0.000000
vt 0.125000 0.750000 vt 0.125000 0.750000
s 0 s 0
usemtl Material usemtl Material
f 1/1/1 5/5/1 7/9/1 3/3/1 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 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 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 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 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 f 6/8/6 5/6/6 1/1/6 2/2/6

View 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"
}

View File

@ -1,71 +1,71 @@
#include "GUI.h" #include "GUI.h"
void SceneExplorer(Scene& scene, std::string PanelName) { void SceneExplorer(Scene& scene, std::string PanelName) {
if (ImGui::Begin(PanelName.c_str())) { if (ImGui::Begin(PanelName.c_str())) {
ImGui::ListBoxHeader("##ObjectList"); ImGui::ListBoxHeader("##ObjectList");
Node& current = scene.GetRoot(); Node& current = scene.GetRoot();
Node* next = &current; Node* next = &current;
// Show first node // Show first node
ImGui::Selectable(next->name.c_str(), true); ImGui::Selectable(next->name.c_str(), true);
ImGui::Indent(); ImGui::Indent();
if (next->children.size() != 0) { if (next->children.size() != 0) {
for (auto child : next->children) for (auto child : next->children)
{ {
std::string& name = child->name; std::string& name = child->name;
ImGui::Selectable(name.c_str(), false); ImGui::Selectable(name.c_str(), false);
} }
} }
ImGui::ListBoxFooter(); ImGui::ListBoxFooter();
} }
ImGui::End(); ImGui::End();
} }
void CameraTool(Camera* cam) { void CameraTool(Camera* cam) {
ImGui::Begin("Camera"); ImGui::Begin("Camera");
ImGui::SliderFloat("Zoom:", &cam->Zoom, 10, 190); ImGui::SliderFloat("Zoom:", &cam->Zoom, 10, 190);
ImGui::InputFloat3("Position:", &cam->Position[0]); ImGui::InputFloat3("Position:", &cam->Position[0]);
ImGui::InputFloat3("Rotation:", &cam->Rotation[0]); ImGui::InputFloat3("Rotation:", &cam->Rotation[0]);
ImGui::End(); ImGui::End();
} }
void ScriptingTool(char* code) { void ScriptingTool(char* code) {
ImGui::Begin("Scripting"); ImGui::Begin("Scripting");
ImGui::InputTextMultiline("Lua Script", code, 255); ImGui::InputTextMultiline("Lua Script", code, 255);
bool runCode = ImGui::Button("Run"); bool runCode = ImGui::Button("Run");
ImGui::End(); ImGui::End();
} }
void transformWindow(Transform& transform, std::string PanelName) { void transformWindow(Transform& transform, std::string PanelName) {
ImGui::Begin(PanelName.c_str()); ImGui::Begin(PanelName.c_str());
ImGui::InputFloat3("Position:", (float*)&transform.Position[0]); ImGui::InputFloat3("Position:", (float*)&transform.Position[0]);
ImGui::InputFloat3("Rotation:", (float*)&transform.Rotation[0]); ImGui::InputFloat3("Rotation:", (float*)&transform.Rotation[0]);
ImGui::InputFloat3("Scale:", (float*)&transform.Scale[0]); ImGui::InputFloat3("Scale:", (float*)&transform.Scale[0]);
ImGui::End(); ImGui::End();
} }
void materialWindow(Material& material, std::string PanelName) { void materialWindow(Material& material, std::string PanelName) {
ImGui::Begin(PanelName.c_str()); ImGui::Begin(PanelName.c_str());
ImGui::ColorPicker3("Color:", &material.Color[0]); ImGui::ColorPicker3("Color:", &material.Color[0]);
ImGui::End(); ImGui::End();
} }

View File

@ -1,119 +1,119 @@
#include "BarinkEngine.h" #include "BarinkEngine.h"
#include "Scene\SceneManager.h" #include "Scene\SceneManager.h"
#include "Scene\SceneNodeTypes.h" #include "Scene\SceneNodeTypes.h"
#include "AssetManager/ModelImporter.h" #include "AssetManager/ModelImporter.h"
#include "imgui.h" #include "imgui.h"
#include "GUI.h" #include "GUI.h"
#include "Util.h" #include "Util.h"
/* /*
* Define globals * Define globals
*/ */
Camera* cam; Camera* cam;
Shader* shader; Shader* shader;
char* code = new char[254]; char* code = new char[254];
const std::string vertexShaderSource = "build/SandboxApplication/Debug/test.vs"; const std::string vertexShaderSource = "../build/SandboxApplication/Debug/test.vs";
const std::string fragmentShaderSource = "build/SandboxApplication/Debug/test.fs"; const std::string fragmentShaderSource = "../build/SandboxApplication/Debug/test.fs";
BarinkEngine::ModelImporter* MI = new BarinkEngine::ModelImporter(); BarinkEngine::ModelImporter* MI = new BarinkEngine::ModelImporter();
Scene* Level1; Scene* Level1;
// BarinkEngine::SceneObject* cube; // BarinkEngine::SceneObject* cube;
/* /*
* Runs once at startup * Runs once at startup
* - USe to initialize the game/sandbox/demo * - USe to initialize the game/sandbox/demo
*/ */
void Start() { void Start() {
// Build a basic test scene // Build a basic test scene
// NOTE: This will later be done through an editor // NOTE: This will later be done through an editor
// Create a level and load it as the current level // Create a level and load it as the current level
std::string levelName("Test Level"); std::string levelName("Test Level");
Level1 = SceneManager::CreateScene(levelName); Level1 = SceneManager::CreateScene(levelName);
SceneManager::LoadScene(*Level1); SceneManager::LoadScene(*Level1);
// Create a cube node // Create a cube node
// Load a model // Load a model
//cube = MI->Import("build/SandboxApplication/Debug/Models/Cube.obj"); auto cube = MI->Import("../build/SandboxApplication/Debug/Models/Cube.obj");
Level1->GetRoot().addChild(*cube);
//Level1->GetRoot().addChild(*cube);
std::string groupName("Nested-Group");
std::string groupName("Nested-Group"); auto testGroup = new Group(groupName);
auto testGroup = new Group(groupName); Level1->GetRoot().addChild( *testGroup);
Level1->GetRoot().addChild( *testGroup);
std::string group2Name("Nested-Group2");
std::string group2Name("Nested-Group2"); auto testGroup2 = new Group(group2Name);
auto testGroup2 = new Group(group2Name); Level1->GetRoot().addChild(*testGroup2);
Level1->GetRoot().addChild(*testGroup2);
// Walk scene graph
// Walk scene graph PrintSceneTree(Level1->GetRoot(),0);
PrintSceneTree(Level1->GetRoot(),0);
shader = new Shader(vertexShaderSource, fragmentShaderSource);
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);
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);
memset(code, '\0', 254); }
}
/*
/* * Runs every frame
* Runs every frame * - Use to draw Immediate mode graphics (Not meant for HUD's )
* - Use to draw Immediate mode graphics (Not meant for HUD's ) */
*/ void ImmediateGraphicsDraw() {
void ImmediateGraphicsDraw() { ImGui::NewFrame();
ImGui::NewFrame();
// Show ImGui demo such that I can easily look
// Show ImGui demo such that I can easily look // at possible GUI elements to use
// at possible GUI elements to use ImGui::ShowDemoWindow();
ImGui::ShowDemoWindow();
// Show internal BarinkEngine stats
// Show internal BarinkEngine stats ShowStats();
ShowStats();
// Show different tooling for this specific sandbox
// Show different tooling for this specific sandbox CameraTool(cam);
CameraTool(cam); ScriptingTool(code);
ScriptingTool(code);
SceneExplorer(*Level1, "Scene Explorer");
SceneExplorer(*Level1, "Scene Explorer");
} }
/* /*
* Runs every frame * Runs every frame
* - Meant for game logic ( non-physics related) * - Meant for game logic ( non-physics related)
*/ */
void Update() void Update()
{ {
/* /*
* NOTE: this needs to move to the renderer * NOTE: this needs to move to the renderer
* Render code should not appear in the sandbox file * 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); //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); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
shader->Use(); shader->Use();
//shader->setUniformMat4("P", projection); //shader->setUniformMat4("P", projection);
//shader->setUniformMat4("M", CalculateModelMat(cube->transform)); //shader->setUniformMat4("M", CalculateModelMat(cube->transform));
shader->setUniformMat4("V", cam->GetViewMatrix()); shader->setUniformMat4("V", cam->GetViewMatrix());
//cube->renderable->material->Apply(); //cube->renderable->material->Apply();
//Cube->Draw(); //Cube->Draw();
} }
/* /*
* Runs at the end of the program * Runs at the end of the program
* - Meant for cleanup * - Meant for cleanup
*/ */
void Stop() { void Stop() {
delete MI; delete MI;
delete shader; delete shader;
} }

View File

@ -18,46 +18,6 @@ workspace "BarinkEngine"
defines {"NDEBUG"} defines {"NDEBUG"}
optimize "On" optimize "On"
include("./SandboxApplication")
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",
}
libdirs {
'./build/BarinkEngine/Debug'
}
files {
"./SandboxApplication/*.h",
"./SandboxApplication/*.cpp"
}
include("./BarinkEngine") include("./BarinkEngine")