Engine clean

Added namespaces to the core engine, improved premake setup, added a buildsolution batch script, removed tinygltf submodule
This commit is contained in:
2022-11-04 14:14:53 +01:00
parent 644b6db100
commit b44c88d05c
111 changed files with 1700 additions and 1567 deletions

View File

@ -4,7 +4,7 @@ kind "ConsoleApp"
buildmessage "Building editor ..."
links{
"BarinkEngine",
"YoggieEngine",
"ImGuizmo"
}
@ -13,32 +13,27 @@ includedirs{
-- 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",
incfolder["lua"],
incfolder["spdlog"],
incfolder["glm"],
incfolder["assimp"],
incfolder["glad"],
incfolder["glfw"],
"./../libs/assimp/include",
"./../libs/glad/include",
"./../libs/glfw/include",
"./../libs/tinygltf",
"./../libs/glew/include",
"./../libs/glm",
"./../libs/ImGui",
"./../libs/guizmo",
"./../libs/entt/src",
incfolder["imgui"],
incfolder["imguizmo"],
incfolder["entt"],
"./include"
}
libdirs {
'./../build/BarinkEngine/Debug'
staticlib["yoggie"]
}
files {
"./include/*.h",
"./src/*.h",
"./src/*.cpp"
}

View File

@ -1,25 +1,23 @@
#include <glm/gtc/type_ptr.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <imgui.h>
#include "stb_image.h"
#include "../../libs/guizmo/ImGuizmo.h"
#include "../../BarinkEngine/src/BarinkEngine.h"
#include "../../BarinkEngine/src/AssetManager/ModelImporter.h"
#include "../../BarinkEngine/src/Graphics/Memory/Framebuffer.h"
#include "../../BarinkEngine/src/PerfCounter.cpp"
#include "../../BarinkEngine/src/Scene/Entity.h"
#include "../../YoggieEngine/src/BarinkEngine.h"
#include "../../YoggieEngine/src/AssetManager/ModelImporter.h"
#include "../../YoggieEngine/src/Graphics/Memory/Framebuffer.h"
#include "../../YoggieEngine/src/PerfCounter.cpp"
#include "../../YoggieEngine/src/Scene/Entity.h"
#include "Widgets.h"
using namespace YoggieEngine;
/*
* Define globals
*/
Framebuffer* framebuffer;
Scene Level1;
BarinkEngine::SceneObject* Model;
SceneObject* Model;
Entity cube;
entt::entity Selected;
@ -35,25 +33,25 @@ void Start() {
// Create a level and load it as the current level
auto importer = BarinkEngine::ModelImporter();
auto importer = ModelImporter();
// Create a cube
Model = importer.Import("build/Debug/Models/Cube.obj");
cube = Level1.AddEntity("cube");
auto& render3DComponent = cube.AddComponent<BarinkEngine::Render3DComponent>();
auto& render3DComponent = cube.AddComponent<Render3DComponent>();
render3DComponent.mesh = *(Model->renderable->mesh);
cube.GetComponent<BarinkEngine::TransformComponent>().Position = glm::vec3(1.0f, 0.0f, 5.0f);
cube.GetComponent<TransformComponent>().Position = glm::vec3(1.0f, 0.0f, 5.0f);
auto cube2 = Level1.AddEntity("Cube1");
auto& rendercube2 = cube2.AddComponent<BarinkEngine::Render3DComponent>();
auto& rendercube2 = cube2.AddComponent<Render3DComponent>();
rendercube2.mesh = *(Model->renderable->mesh);
// create an ambient light source
auto AmbientLight = Level1.AddEntity("AmbientLight");
auto light = AmbientLight.AddComponent<BarinkEngine::LightComponent>();
auto light = AmbientLight.AddComponent<LightComponent>();
light.Color = glm::vec3(1.0f);
light.Strength = 1.0f;

View File

@ -1,7 +1,8 @@
#include "widgets.h"
//#include "EditorConsole.h"
#include <iostream>
#include "../../BarinkEngine/src/Scene/Components.h"
#include "../../BarinkEngine/src/Scene/Entity.h"
#include "../../YoggieEngine/src/Scene/Components.h"
#include "../../YoggieEngine/src/Scene/Entity.h"
class Editor;
void ComponentView(const std::string& componentName, voidFunction func)
@ -18,33 +19,61 @@ void ComponentView(const std::string& componentName, voidFunction func)
void Inspector(entt::entity ent , Scene& scene) {
ImGui::Begin("Inspector");
static char* names[] = { "Script Component", "Camera Component" };
static float Zoom = 90;
static glm::vec3 Position = glm::vec3(0.0f, 0.0f, 0.0f);
static glm::vec3 Rotation = glm::vec3(0.0f, 0.0f, 0.0f);
if (scene.getReg().valid(ent)) {
Entity entity = Entity(ent, &scene);
auto component = entity.GetComponent<IdentifierComponent>();
ImGui::LabelText("## Name:", component.name.c_str());
if (ImGui::Button("Add Component"))
ImGui::OpenPopup("Component picker");
auto component = entity.GetComponent<BarinkEngine::IdentifierComponent>();
ImGui::LabelText("## Name:", component.name.c_str() );
ImGui::SameLine();
if (ImGui::BeginPopup("Component picker")) {
for (int i = 0; i < IM_ARRAYSIZE(names); i++)
if (ImGui::MenuItem(names[i])) {
std::cout << "Add a " << names[i] << " to "
<< entity.GetComponent<IdentifierComponent>().name << std::endl;
}
ImGui::EndPopup();
}
ImGui::NewLine();
if (entity.HasComponent<BarinkEngine::TransformComponent>()) {
auto& transform = entity.GetComponent<BarinkEngine::TransformComponent>();
ImGui::DragFloat3("Position", glm::value_ptr(transform.Position) , 0.01);
if (entity.HasComponent<TransformComponent>()) {
auto& transform = entity.GetComponent<TransformComponent>();
if (ImGui::CollapsingHeader("Transform", ImGuiTreeNodeFlags_None )) {
ImGui::DragFloat3("Position", glm::value_ptr(transform.Position), 0.01);
ImGui::DragFloat3("Rotation", glm::value_ptr(transform.Rotation), 0.01);
ImGui::DragFloat3("Scale", glm::value_ptr(transform.Scale), 0.01, 0);
}
}
if (entity.HasComponent<BarinkEngine::LightComponent>()) {
auto& light = entity.GetComponent<BarinkEngine::LightComponent>();
if (entity.HasComponent<LightComponent>()) {
auto& light = entity.GetComponent<LightComponent>();
ImGui::DragFloat("Strength", &light.Strength, 0.001f);
ImGui::ColorEdit3("Colour", glm::value_ptr(light.Color));
}
if (entity.HasComponent <BarinkEngine::CameraComponent>()) {
auto& camera = entity.GetComponent<BarinkEngine::CameraComponent>();
if (entity.HasComponent <CameraComponent>()) {
auto& camera = entity.GetComponent<CameraComponent>();
ComponentView("Camera", [] {
ImGui::SliderFloat("Zoom", &Zoom, 10, 190);
ImGui::InputFloat3("Position:", &Position[0]);
@ -52,7 +81,7 @@ void Inspector(entt::entity ent , Scene& scene) {
});
}
if (entity.HasComponent<BarinkEngine::ScriptComponent>()) {
if (entity.HasComponent<ScriptComponent>()) {
ComponentView("Scripting", [] {
ImGui::LabelText("##--", "Hello scripting");
});
@ -71,7 +100,7 @@ void SceneExplorer(entt::entity& selected, Scene& scene )
scene.getReg().each([&](entt::entity enttNumber) {
Entity entity = Entity(enttNumber, &scene);
auto id = entity.GetComponent<BarinkEngine::IdentifierComponent>();
auto id = entity.GetComponent<IdentifierComponent>();
if (ImGui::Selectable(id.name.c_str(), enttNumber == selected )) {
selected = enttNumber;
@ -122,9 +151,11 @@ void Settings() {
ImGui::End();
}
//auto console = EditorConsole();
void Console() {
ImGui::Begin("Console", false);
ImGui::Dummy(ImVec2{ 128, 128 });
// console.Draw();
ImGui::End();
}

View File

@ -2,11 +2,14 @@
#include <glm/glm.hpp>
#include <imgui.h>
#include <string>
#include "../../libs/guizmo/ImGuizmo.h"
#include "../../BarinkEngine/src/BarinkEngine.h"
#include <entt/entt.hpp>
#include <entt/entity/fwd.hpp>
#include "../../libs/guizmo/ImGuizmo.h"
#include "../../YoggieEngine/src/BarinkEngine.h"
typedef void ( *voidFunction ) (void);
using namespace YoggieEngine;
void ComponentView(const std::string& componentName, voidFunction func);