Compare commits

..

No commits in common. "145338d666c4bf2f2454ec0fbe7902d7f30f6788" and "13f67a7cdbdd4c3f7e4fa90b6698e35946937f2b" have entirely different histories.

41 changed files with 1060 additions and 1157 deletions

View File

@ -1,68 +0,0 @@
#pragma once
#include "../../YoggieEngine/src/YoggieEngine.h"
#include "EditorWindow.h"
#include "AssetManagement/AssetManager.h"
class AssetFinder : EditorWindow {
public:
AssetFinder() : EditorWindow("Assets") {}
void Draw() override {
ImGui::DragInt("IconSize", &iconSize, 1, 30, 90);
if (ImGui::BeginTable("##resources", 3))
{
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.f, 0.f, 0.f, 0.f));
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0.f, 0.f, 0.f, 0.f));
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(1.f, 1.f, 1.f, 0.2f));
YoggieEngine::Texture folderIcon = YoggieEngine::Texture("rsc/folderIcon.png");
YoggieEngine::Texture assetIcon = YoggieEngine::Texture("rsc/assetIcon.png");
int row = 0;
int column = 0;
for (auto& asset : AssetManager::assets) {
if (column % 3 == 0) {
ImGui::TableNextRow();
column = 0;
row++;
}
ImGui::TableSetColumnIndex(column);
if (asset.isFolder) {
ImGui::ImageButton(
(ImTextureID)folderIcon.GetID(),
ImVec2{ (float)iconSize,(float)iconSize });
ImGui::Text(asset.GetName(), row);
}
else {
ImGui::ImageButton(
(ImTextureID)assetIcon.GetID(),
ImVec2{ (float)iconSize, (float)iconSize });
ImGui::Text(asset.GetName(), row);
}
column++;
}
ImGui::PopStyleColor(3);
ImGui::EndTable();
const GLuint textures[2]{ assetIcon.GetID(), folderIcon.GetID() };
glDeleteTextures(2, textures);
}
}
private:
int iconSize = 60;
};

View File

@ -1,129 +0,0 @@
#include "SceneSerializer.h"
#include "../../YoggieEngine/src/YoggieEngine.h"
#include <yaml-cpp/yaml.h>
#include <yaml-cpp/node/type.h>
#include <filesystem>
void WriteFile(std::string& emitter, std::filesystem::path path)
{
std::cout << "Writing Scene file to: " << path.u8string() << std::endl;
std::ofstream sceneFile;
sceneFile.open(path.u8string());
sceneFile << emitter.c_str();
sceneFile.close();
}
YAML::Emitter& operator<< (YAML::Emitter& emitter, glm::vec3& vector) {
emitter << YAML::Flow << YAML::BeginSeq << vector.x << vector.y << vector.x << YAML::EndSeq;
return emitter;
}
std::string Serialize(YoggieEngine::Scene& scene) {
YAML::Emitter emitter;
emitter << YAML::BeginMap;
emitter << YAML::Key << "Scene" << YAML::Value << "test-Scene";
emitter << YAML::Key << "Entities" << YAML::Value << YAML::BeginSeq;
scene.getReg().each([&emitter, &scene](entt::entity enttNumber) {
YoggieEngine::Entity entity = YoggieEngine::Entity(enttNumber, &scene);
emitter << YAML::BeginMap;
emitter << YAML::Key << "Entity" << YAML::Value << entity.GetComponent<YoggieEngine::IdentifierComponent>().name;
if (entity.HasComponent<YoggieEngine::IdentifierComponent>()) {
emitter << YAML::Key << "Ident";
emitter << YAML::BeginMap;
emitter << YAML::Value << entity.GetComponent<YoggieEngine::IdentifierComponent>().name;
emitter << YAML::EndMap;
}
if (entity.HasComponent<YoggieEngine::TransformComponent>()) {
emitter << YAML::Key << "Transform" << YAML::Value;
emitter << YAML::BeginMap;
emitter << YAML::Key << "Position";
emitter << YAML::Value << entity.GetComponent<YoggieEngine::TransformComponent>().Position;
emitter << YAML::Key << "Rotation";
emitter << YAML::Value << entity.GetComponent<YoggieEngine::TransformComponent>().Rotation;
emitter << YAML::Key << "Scale";
emitter << YAML::Value << entity.GetComponent<YoggieEngine::TransformComponent>().Scale;
emitter << YAML::EndMap;
}
if (entity.HasComponent<YoggieEngine::LightComponent>()) {
emitter << YAML::Key << "Light";
emitter << YAML::Value;
emitter << YAML::BeginMap;
emitter << YAML::Key << "Color";
emitter << YAML::Value << entity.GetComponent<YoggieEngine::LightComponent>().Color;
emitter << YAML::EndMap;
}
emitter << YAML::EndMap;
});
emitter << YAML::EndSeq;
emitter << YAML::EndMap;
return std::string(emitter.c_str());
}
void SaveScene(std::filesystem::path path, YoggieEngine::Scene& scene) {
std::string YAMLString = Serialize(scene);
WriteFile(YAMLString, path);
}
void LoadScene(std::filesystem::path path, YoggieEngine::Scene& scene)
{
auto sceneYAML = YAML::LoadFile(path.u8string());
if (!sceneYAML["Scene"]) {
spdlog::error("Not a scene file!");
return;
}
scene.getReg().clear();
std::string SceneName = sceneYAML["Scene"].as<std::string>();
auto entities = sceneYAML["Entities"];
for (const auto& entity : entities) {
std::string entityID = entity["Ident"].as<std::string>();
YoggieEngine::Entity SE = scene.AddEntity(entityID);
if (entity["Transform"])
{
YoggieEngine::TransformComponent tc = SE.GetComponent <YoggieEngine::TransformComponent> ();
auto positionNode = entity["Transform"]["Position"];
tc.Position = glm::vec3(positionNode[0].as<float>(), positionNode[1].as<float>(), positionNode[2].as<float>());
auto rotationNode = entity["Transform"]["Rotation"];
tc.Rotation = glm::vec3(rotationNode[0].as<float>(), rotationNode[1].as<float>(), rotationNode[2].as<float>());
auto scaleNode = entity["Transform"]["Scale"];
tc.Scale = glm::vec3(scaleNode[0].as<float>(), scaleNode[1].as<float>(), scaleNode[2].as<float>());
}
if (entity["Light"]) {
YoggieEngine::LightComponent lc = SE.AddComponent<YoggieEngine::LightComponent>();
lc.Color = glm::vec3(entity["Light"]["Color"][0].as<float>(), entity["Light"]["Color"][1].as<float>(), entity["Light"]["Color"][2].as<float>());
}
}
}

View File

@ -1,16 +0,0 @@
#pragma once
#include <entt/entity/fwd.hpp>
#include <glm/glm.hpp>
#include <yaml-cpp/yaml.h>
#include <filesystem>
#include "../../YoggieEngine/src/YoggieEngine.h"
void WriteFile(std::string& emitter, std::filesystem::path path);
YAML::Emitter& operator<< (YAML::Emitter& emitter, glm::vec3& vector);
std::string Serialize(YoggieEngine::Scene& scene);
void SaveScene(std::filesystem::path path, YoggieEngine::Scene& scene);
void LoadScene(std::filesystem::path path, YoggieEngine::Scene& scene);

View File

@ -1,22 +0,0 @@
#pragma once
#include "../../YoggieEngine/src/YoggieEngine.h"
#include "EditorWindow.h"
#include <imgui.h>
class Console : public EditorWindow {
public:
Console();
~Console();
void Draw() override;
void Show();
void AddLog(const char* fmt, ...);
private:
ImVector<char*> Items;
bool AutoScroll;
bool ScrollToBottom;
};

View File

@ -1,26 +0,0 @@
#pragma once
#include <imgui.h>
#include <string>
class EditorWindow {
public:
EditorWindow (const std::string& name, ImGuiWindowFlags_ flags = ImGuiWindowFlags_None ) : name(name) , flags(flags) {}
void Update()
{
ImGui::Begin(name.c_str(), false, flags);
Draw();
ImGui::End();
}
~EditorWindow() = default;
protected:
std::string name;
private:
ImGuiWindowFlags_ flags;
virtual void Draw() = 0;
};

View File

@ -1,188 +0,0 @@
#include "MainMenuBar.h"
#include <nfd.h>
#include "AssetManagement/AssetManager.h"
MainMenuBar::MainMenuBar()
{
ImGui::BeginMainMenuBar();
}
void MainMenuBar::ApplicationMenu(Project& project) {
if (ImGui::BeginMenu("Application")) {
if (ImGui::MenuItem("Load Project"))
{
nfdresult_t result = NFD_OpenDialog({ "yproj" }, NULL, &path);
switch (result) {
case(NFD_OKAY):
Project::LoadProject(path, project);
AssetManager::setAssetPath(project.GetProjectDirectory());
AssetManager::BuildAssetView();
break;
case(NFD_CANCEL):
break;
case(NFD_ERROR):
std::cout << "NFD_Error: " << NFD_GetError() << std::endl;
break;
}
}
if (ImGui::MenuItem("Save project as...")) {
nfdresult_t result = NFD_SaveDialog({ "yproj" }, NULL, &path);
switch (result) {
case(NFD_OKAY):
std::cout << "Save as: " << path << std::endl;
Project::SaveProject(path, project);
break;
case(NFD_CANCEL):
break;
case(NFD_ERROR):
std::cout << "NFD_Error: " << NFD_GetError() << std::endl;
break;
}
}
if (ImGui::MenuItem("Preferences"))
{
}
if (ImGui::MenuItem("Exit"))
{
// TODO: Exit application
}
ImGui::EndMenu();
}
}
void MainMenuBar::SceneMenu(Project& project, YoggieEngine::Scene& scene) {
if (ImGui::BeginMenu("Scene")) {
if (ImGui::MenuItem("Save scene"))
{
nfdresult_t result = NFD_SaveDialog({ "yscene" }, NULL, &path);
switch (result) {
case(NFD_OKAY):
SaveScene(path, scene);
break;
case(NFD_CANCEL):
break;
case(NFD_ERROR):
std::cout << "NFD_Error: " << NFD_GetError() << std::endl;
break;
}
}
if (ImGui::MenuItem("Load scene"))
{
auto result = NFD_OpenDialog({ "yscene" }, NULL, &path);
switch (result) {
case (NFD_OKAY):
LoadScene(path, scene);
break;
case(NFD_CANCEL):
break;
case(NFD_ERROR):
std::cout << "NFD_Error: " << NFD_GetError() << std::endl;
break;
}
}
if (ImGui::MenuItem("Add Entity"))
{
scene.AddEntity("New Entity");
}
if (ImGui::MenuItem("Import Model"))
{
auto result = NFD_OpenDialog("obj,fbx,gltf", NULL, &path);
switch (result) {
case(NFD_OKAY):
// Import Model
AssetManager::LoadFromSource(
path,
"build/Debug/Assets"//project.get()->GetProjectDirectory() / "Assets"
);
break;
case(NFD_CANCEL):
break;
case(NFD_ERROR):
std::cout << "NFD_Error: " << NFD_GetError() << std::endl;
break;
}
}
if (ImGui::MenuItem("Import MeshAsset (temp)"))
{
auto result = NFD_OpenDialog("mesh", NULL, &path);
switch (result) {
case(NFD_OKAY):
{
YoggieEngine::Mesh* importedMesh = AssetManager::LoadFromAssetFile(path);
if (importedMesh != nullptr)
{
auto full_name = std::filesystem::path(path);
auto importedModel = scene.AddEntity(full_name.filename().u8string());
auto& rendererComponent = importedModel.AddComponent<YoggieEngine::Render3DComponent>();
rendererComponent.mesh = *importedMesh;
}
}
break;
case(NFD_CANCEL):
spdlog::debug("User cancelled action");
break;
case(NFD_ERROR):
spdlog::warn("Something went wrong!");
break;
}
}
ImGui::EndMenu();
}
}
void MainMenuBar::DebugMenu()
{
if (ImGui::BeginMenu("Debug")) {
ImGui::EndMenu();
}
}
void MainMenuBar::SelectMenu() {
if (ImGui::BeginMenu("Select")) {
ImGui::EndMenu();
}
}
void MainMenuBar::WindowMenu() {
if (ImGui::BeginMenu("Window")) {
ImGui::EndMenu();
}
}
void MainMenuBar::Help() {
if (ImGui::BeginMenu("Help")) {
ImGui::EndMenu();
}
}
MainMenuBar::~MainMenuBar()
{
ImGui::EndMainMenuBar();
}

View File

@ -1,30 +0,0 @@
#pragma once
#include <imgui.h>
#include "AssetManagement/SceneSerializer.h"
#include "../../YoggieEngine/src/Scene/Scene.h"
#include "Project/Project.h"
class MainMenuBar {
public:
MainMenuBar();
void ApplicationMenu(Project& project);
void SceneMenu(Project& project, YoggieEngine::Scene& scene);
void DebugMenu();
void SelectMenu();
void WindowMenu();
void Help();
~MainMenuBar();
private:
char* path = nullptr;
};

View File

@ -20,7 +20,7 @@ void Project::SaveProject(std::filesystem::path path, Project& project)
projectFile.close();
}
void Project::LoadProject(std::filesystem::path path, Project& project)
void Project::LoadProject(std::filesystem::path path, std::unique_ptr<Project>& project)
{
std::string YAMLProject;
std::stringstream sstream;
@ -36,9 +36,10 @@ void Project::LoadProject(std::filesystem::path path, Project& project)
YAML::Node node = YAML::Load(YAMLProject);
// this is probably not perfect but it seems to work for now
project = node.as<Project>();
project.release();
project = std::make_unique<Project>(node.as<Project>());
std::cout << "loading..." << project.Name << std::endl;
std::cout << "loading..." << project.get()->Name << std::endl;

View File

@ -14,7 +14,7 @@ public:
const std::filesystem::path GetProjectDirectory() { return ProjectDirectory; }
static void SaveProject(std::filesystem::path path, Project& project);
static void LoadProject(std::filesystem::path path, Project& project);
static void LoadProject(std::filesystem::path path, std::unique_ptr<Project>& project);
private:
std::string Name;
std::filesystem::path ProjectDirectory;

View File

@ -1,7 +0,0 @@
#include "ProjectInfo.h"
void ProjectInfo::Draw()
{
ImGui::Text("Project: %s", project.GetName().c_str());
ImGui::Text("Directory: %s", project.GetProjectDirectory().u8string().c_str());
}

View File

@ -1,15 +0,0 @@
#pragma once
#include "../../YoggieEngine/src/YoggieEngine.h"
#include "../EditorWindow.h"
#include "Project.h"
class ProjectInfo : public EditorWindow {
public:
ProjectInfo(Project& project) : EditorWindow("Project Info"), project(project) {}
void Draw() override;
private:
Project& project;
};

View File

@ -1,48 +0,0 @@
#include "Settings.h"
void Settings::Draw() {
ImGui::LabelText("##title-settings", "Fine grain control over the engine!");
if (ImGui::BeginCombo("Graphics API", GraphicsAPI[selectedGfxAPI])) {
for (int i = 0; i < 3; i++) {
bool isSelected = i == selectedGfxAPI;
if (ImGui::Selectable(GraphicsAPI[i], isSelected)) {
selectedGfxAPI = i;
}
if (isSelected)
ImGui::SetItemDefaultFocus();
}
ImGui::EndCombo();
}
ImGui::NewLine();
if (ImGui::BeginCombo("Physics Engine", PhysicsEngine[selectedPhysicsEngine])) {
for (int i = 0; i < 2; i++) {
bool isSelected = i == selectedPhysicsEngine;
if (ImGui::Selectable(PhysicsEngine[i], isSelected)) {
selectedGfxAPI = i;
}
if (isSelected)
ImGui::SetItemDefaultFocus();
}
ImGui::EndCombo();
}
ImGui::InputFloat3("Gravity", glm::value_ptr(Gravity));
ImGui::NewLine();
if (ImGui::Button("Show Advanced options ")) {
ShowAdvancedOptions = !ShowAdvancedOptions;
}
if (ShowAdvancedOptions)
{
ImGui::Checkbox("Debug Engine", &DebugEngine);
}
}

View File

@ -1,30 +0,0 @@
#pragma once
#include "../../YoggieEngine/src/YoggieEngine.h"
#include "../EditorWindow.h"
class Settings : public EditorWindow {
public:
Settings() : EditorWindow("Settings") {}
void Draw() override;
private:
int selectedGfxAPI = 0;
int selectedPhysicsEngine = 0;
glm::vec3 Gravity = glm::vec3(0.0f, -9.81f, 0.0f);
bool ShowAdvancedOptions = false;
bool DebugEngine = false;
const char* PhysicsEngine[2] = {
"PhysX",
"Jolt Physics"
};
const char* GraphicsAPI[3] = {
"OpenGL",
"Vulkan",
"Metal (Apple)"
};
};

View File

@ -1,104 +0,0 @@
#include "Inspector.h"
void Inspector::Draw()
{
}
void Inspector::AddComponentDropDown(YoggieEngine::Entity& selected)
{
static char* names[] = { "Script Component", "Camera Component", "Light Component" };
if (ImGui::Button("Add Component"))
ImGui::OpenPopup("Component picker");
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 "
<< selected.GetComponent<YoggieEngine::IdentifierComponent>().name << std::endl;
}
ImGui::EndPopup();
}
ImGui::NewLine();
}
void Inspector::ShowComponents(YoggieEngine::Entity& selected)
{
auto component = selected.GetComponent<YoggieEngine::IdentifierComponent>();
ImGui::InputText("Name:", (char*)component.name.c_str(), component.name.size() * sizeof(char), ImGuiInputTextFlags_ReadOnly);
if (selected.HasComponent<YoggieEngine::TransformComponent>()) {
auto& transform = selected.GetComponent<YoggieEngine::TransformComponent>();
if (ImGui::CollapsingHeader("Transform", ImGuiTreeNodeFlags_DefaultOpen)) {
ImGui::DragFloat3("Position", glm::value_ptr(transform.Position), 0.1f);
ImGui::DragFloat3("Rotation", glm::value_ptr(transform.Rotation), 0.1f);
ImGui::DragFloat3("Scale", glm::value_ptr(transform.Scale), 0.1f, 0.0f);
}
if (selected.HasComponent<YoggieEngine::RelationComponent>()) {
ImGui::Text("Has relation");
}
}
if (selected.HasComponent<YoggieEngine::Render3DComponent>()) {
auto& render3d = selected.GetComponent<YoggieEngine::Render3DComponent>();
if (ImGui::CollapsingHeader("Render3D", ImGuiTreeNodeFlags_DefaultOpen)) {
ImGui::ColorEdit3("Colour", glm::value_ptr(render3d.color));
ImGui::Checkbox("Use static rendering:", &render3d.isStatic);
}
}
static bool deferred = true;
if (selected.HasComponent<YoggieEngine::LightComponent>()) {
auto& light = selected.GetComponent<YoggieEngine::LightComponent>();
if (ImGui::CollapsingHeader("Light", ImGuiTreeNodeFlags_DefaultOpen)) {
ImGui::ColorEdit3("Colour", glm::value_ptr(light.Color));
ImGui::Checkbox("Deferred", &deferred);
}
}
if (selected.HasComponent <YoggieEngine::CameraComponent>()) {
auto& camera = selected.GetComponent<YoggieEngine::CameraComponent>();
if (ImGui::CollapsingHeader("Camera")) {
ImGui::DragFloat3("Position:", glm::value_ptr(camera.Position), 0.01f);
ImGui::DragFloat3("Rotation:", glm::value_ptr(camera.Rotation), 0.01f);
}
}
if (selected.HasComponent<YoggieEngine::RigidBody>()) {
auto& rigibody = selected.GetComponent<YoggieEngine::RigidBody>();
if (ImGui::CollapsingHeader("RigidBody")) {
}
}
if (selected.HasComponent<YoggieEngine::ScriptComponent>()) {
ComponentView("Scripting", [] {
ImGui::LabelText("##--", "Hello scripting");
});
}
}
void ComponentView(const std::string& componentName, voidFunction func)
{
ImGuiWindowFlags_ window_flags = ImGuiWindowFlags_None;
ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 5.0f);
ImGui::BeginChild(componentName.c_str());
func();
ImGui::EndChild();
ImGui::PopStyleVar();
}

View File

@ -1,20 +0,0 @@
#pragma once
#include "../../YoggieEngine/src/YoggieEngine.h"
#include "../EditorWindow.h"
typedef void (*voidFunction) (void);
inline void ComponentView(const std::string& componentName, voidFunction func);
class Inspector : public EditorWindow {
public:
Inspector() : EditorWindow("Inspector") {}
void Draw()override;
void AddComponentDropDown(YoggieEngine::Entity& selected);
void ShowComponents(YoggieEngine::Entity& selected);
};

View File

@ -1,13 +0,0 @@
#include "SceneExplorer.h"
void SceneExplorer::Draw()
{
scene.getReg().each([&](entt::entity enttNumber) {
YoggieEngine::Entity entity = YoggieEngine::Entity(enttNumber, &scene);
auto id = entity.GetComponent<YoggieEngine::IdentifierComponent>();
if (ImGui::Selectable(id.name.c_str(), enttNumber == selected)) {
selected = enttNumber;
}
});
}

View File

@ -1,20 +0,0 @@
#pragma once
#include "../../YoggieEngine/src/YoggieEngine.h"
#include "../EditorWindow.h"
#include "../../src/Scene/Entity.h"
class SceneExplorer : public EditorWindow {
public:
SceneExplorer(entt::entity& selected, YoggieEngine::Scene& scene)
: EditorWindow("SceneExplorer"), scene(scene), selected(selected)
{}
void Draw() override;
private:
entt::entity selected;
YoggieEngine::Scene& scene;
};

View File

@ -1,27 +0,0 @@
#include "RuntimeControls.h"
void RuntimeControls::Draw() {
ImGui::SameLine((ImGui::GetWindowContentRegionMax().x / 2) - (numButtons * buttonSize.x));
for (int i = 0; i < numButtons; i++) {
ImVec4 color = button[i].Color;
ImGui::PushStyleColor(ImGuiCol_Button, color);
const float strengthIncrease = 1.5f;
ImGui::PushStyleColor(
ImGuiCol_ButtonHovered,
ImVec4{
color.x * strengthIncrease,
color.y * strengthIncrease,
color.z * strengthIncrease,
color.w
}
);
if (ImGui::Button(button[i].Name, buttonSize)) {
}
ImGui::PopStyleColor();
ImGui::PopStyleColor();
ImGui::SameLine();
}
}

View File

@ -1,26 +0,0 @@
#pragma once
#include "../../YoggieEngine/src/YoggieEngine.h"
#include "../EditorWindow.h"
#define RuntimeControlWindowFlags (ImGuiWindowFlags_)(ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse)
struct ButtonInfo {
const char* Name;
ImVec4 Color;
};
class RuntimeControls : public EditorWindow {
public:
RuntimeControls() : EditorWindow("RuntimeControls", RuntimeControlWindowFlags) {}
void Draw() override;
private:
ImVec2 buttonSize = ImVec2{ 90 ,25 };
unsigned int numButtons = 2;
ButtonInfo button[2] = {
{"Play" , ImVec4{ 0.001 * 12 , 0.001 * 201 , 0.001 * 69, 1.0f}},
{"Simulate", ImVec4{ 0.001 * 14, 0.001 * 157, 0.001 * 201, 1.0f}}
};
};

View File

@ -0,0 +1,134 @@
#pragma once
#include <yaml-cpp/yaml.h>
#include <yaml-cpp/node/type.h>
#include <string>
#include <filesystem>
#include <fstream>
#include "../../YoggieEngine/src/Scene/Entity.h"
void WriteFile(std::string& emitter, std::filesystem::path path)
{
std::cout << "Writing Scene file to: " << path.u8string() << std::endl;
std::ofstream sceneFile;
sceneFile.open(path.u8string());
sceneFile << emitter.c_str();
sceneFile.close();
}
YAML::Emitter& operator<< (YAML::Emitter& emitter, glm::vec3& vector) {
emitter << YAML::Flow << YAML::BeginSeq << vector.x << vector.y << vector.x << YAML::EndSeq;
return emitter;
}
std::string Serialize( Scene& scene) {
YAML::Emitter emitter;
emitter << YAML::BeginMap;
emitter << YAML::Key << "Scene" << YAML::Value << "test-Scene";
emitter << YAML::Key << "Entities" << YAML::Value << YAML::BeginSeq;
scene.getReg().each([&scene, &emitter](auto enttNumber) {
Entity entity = Entity(enttNumber, &scene);
emitter << YAML::BeginMap;
emitter << YAML::Key << "Entity" << YAML::Value << entity.GetComponent<IdentifierComponent>().name;
if (entity.HasComponent<IdentifierComponent>()) {
emitter << YAML::Key << "Ident";
emitter << YAML::BeginMap;
emitter << YAML::Value << entity.GetComponent<IdentifierComponent>().name;
emitter << YAML::EndMap;
}
if (entity.HasComponent<TransformComponent>()) {
emitter << YAML::Key << "Transform" << YAML::Value ;
emitter << YAML::BeginMap;
emitter << YAML::Key << "Position";
emitter << YAML::Value << entity.GetComponent<TransformComponent>().Position;
emitter << YAML::Key << "Rotation";
emitter << YAML::Value << entity.GetComponent<TransformComponent>().Rotation;
emitter << YAML::Key << "Scale";
emitter << YAML::Value << entity.GetComponent<TransformComponent>().Scale;
emitter << YAML::EndMap;
}
if (entity.HasComponent<LightComponent>()) {
emitter << YAML::Key << "Light";
emitter << YAML::Value;
emitter << YAML::BeginMap;
emitter << YAML::Key << "Color";
emitter << YAML::Value << entity.GetComponent<LightComponent>().Color;
emitter << YAML::EndMap;
}
emitter << YAML::EndMap;
});
emitter << YAML::EndSeq;
emitter << YAML::EndMap;
return std::string(emitter.c_str());
}
void SaveScene(std::filesystem::path path, Scene& scene) {
std::string YAMLString = Serialize(scene);
WriteFile(YAMLString, path);
}
void LoadScene(std::filesystem::path path, Scene& scene)
{
auto sceneYAML = YAML::LoadFile(path.u8string());
if (!sceneYAML["Scene"]) {
spdlog::error("Not a scene file!");
return;
}
scene.getReg().clear();
std::string SceneName = sceneYAML["Scene"].as<std::string>();
auto entities = sceneYAML["Entities"];
for (const auto& entity : entities) {
std::string entityID = entity["Ident"].as<std::string>();
YoggieEngine::Entity SE = scene.AddEntity(entityID);
if (entity["Transform"])
{
TransformComponent tc = SE.GetComponent<TransformComponent>();
auto positionNode = entity["Transform"]["Position"];
tc.Position = glm::vec3(positionNode[0].as<float>(), positionNode[1].as<float>(), positionNode[2].as<float>());
auto rotationNode = entity["Transform"]["Rotation"];
tc.Rotation = glm::vec3(rotationNode[0].as<float>(), rotationNode[1].as<float>(), rotationNode[2].as<float>());
auto scaleNode = entity["Transform"]["Scale"];
tc.Scale = glm::vec3(scaleNode[0].as<float>(), scaleNode[1].as<float>(), scaleNode[2].as<float>());
}
if (entity["Light"]) {
LightComponent lc = SE.AddComponent<LightComponent>();
lc.Color = glm::vec3(entity["Light"]["Color"][0].as<float>(), entity["Light"]["Color"][1].as<float>(), entity["Light"]["Color"][2].as<float>());
}
}
}

View File

@ -4,7 +4,7 @@
#include <nfd.h>
#include <iostream>
#include <functional>
#include "Project/Project.h"
#include "Project.h"
struct DialogSpec {
const std::string& id;
const std::string& Title;

View File

@ -1,21 +1,18 @@
#include "Console.h"
#include <stdio.h>
#include "EditorConsole.h"
Console::Console()
: EditorWindow("Console"), Items(ImVector<char*>()), AutoScroll(false), ScrollToBottom(false)
EditorConsole::EditorConsole()
: Items(ImVector<char*>()), AutoScroll(false), ScrollToBottom(false)
{
AddLog("Hello Editor console!");
}
Console::~Console() {
EditorConsole::~EditorConsole() {
}
void Console::Show() {
Draw();
}
void Console::Draw() {
void EditorConsole::Draw() {
ImGui::SetNextWindowSize(ImVec2(520, 600), ImGuiCond_FirstUseEver);
@ -27,7 +24,7 @@ void Console::Draw() {
}
void Console::AddLog(const char* fmt, ...) {
void EditorConsole::AddLog(const char* fmt, ...) {
char buf[1024];
va_list args;
va_start(args, fmt);

View File

@ -0,0 +1,18 @@
#pragma once
#include <imgui.h>
class EditorConsole
{
public:
EditorConsole();
~EditorConsole();
void Draw();
void AddLog(const char* fmt, ...);
private:
ImVector<char*> Items;
bool AutoScroll;
bool ScrollToBottom;
};

View File

@ -0,0 +1,11 @@
#pragma once
#include <imgui.h>
#include <string>
class EditorWindow {
public:
EditorWindow(const std::string& name, ImGuiWindowFlags_ flags = ImGuiWindowFlags_None ) { ImGui::Begin(name.c_str(), false ,flags); }
~EditorWindow() { ImGui::End(); }
};

View File

@ -0,0 +1,70 @@
#pragma once
#include <imgui.h>
#include <backends/imgui_impl_opengl3.h>
#include <backends/imgui_impl_glfw.h>
#include <ImGuizmo.h>
#include "../../src/YoggieEngine.h"
class GUIRenderer {
public:
GUIRenderer(YoggieEngine::NativeWindow& window ) {
IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO();
io.ConfigFlags |= ImGuiConfigFlags_::ImGuiConfigFlags_ViewportsEnable;
io.ConfigFlags |= ImGuiConfigFlags_::ImGuiConfigFlags_DockingEnable;
io.Fonts->AddFontFromFileTTF("build/Debug/Fonts/Roboto-Regular.ttf", 18);
ImGui::StyleColorsDark();
ImGui_ImplGlfw_InitForOpenGL(window.GetGLFWHandle(), true);
ImGui_ImplOpenGL3_Init("#version 450");
ImGuizmo::SetImGuiContext(ImGui::GetCurrentContext());
ImGuizmo::SetOrthographic(true);
}
void Begin ()
{
ImGui_ImplGlfw_NewFrame();
ImGui_ImplOpenGL3_NewFrame();
ImGui::NewFrame();
ImGuizmo::BeginFrame();
}
void End()
{
ImGui::EndFrame();
ImGui::Render();
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
if (ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{
GLFWwindow* last_context = glfwGetCurrentContext();
ImGui::UpdatePlatformWindows();
ImGui::RenderPlatformWindowsDefault();
glfwMakeContextCurrent(last_context);
}
}
~GUIRenderer(){
ImGui_ImplOpenGL3_Shutdown();
ImGui_ImplGlfw_Shutdown();
ImGui::DestroyContext();
}
};

187
Editor/src/UI/MainMenuBar.h Normal file
View File

@ -0,0 +1,187 @@
#pragma once
#include <imgui.h>
class MainMenuBar {
public:
MainMenuBar() { ImGui::BeginMainMenuBar(); }
void ApplicationMenu(std::unique_ptr<Project>& project) {
if (ImGui::BeginMenu("Application")) {
if (ImGui::MenuItem("Load Project"))
{
nfdresult_t result = NFD_OpenDialog({ "yproj" }, NULL, &path);
switch (result) {
case(NFD_OKAY):
Project::LoadProject(path, project);
AssetManager::setAssetPath(project.get()->GetProjectDirectory());
AssetManager::BuildAssetView();
break;
case(NFD_CANCEL):
break;
case(NFD_ERROR):
std::cout << "NFD_Error: " << NFD_GetError() << std::endl;
break;
}
}
if (ImGui::MenuItem("Save project as...")) {
nfdresult_t result = NFD_SaveDialog({ "yproj" }, NULL, &path);
switch (result) {
case(NFD_OKAY):
std::cout << "Save as: " << path << std::endl;
Project::SaveProject(path, *project.get());
break;
case(NFD_CANCEL):
break;
case(NFD_ERROR):
std::cout << "NFD_Error: " << NFD_GetError() << std::endl;
break;
}
}
if (ImGui::MenuItem("Preferences"))
{
}
if (ImGui::MenuItem("Exit"))
{
// TODO: Exit application
}
ImGui::EndMenu();
}
}
void SceneMenu(std::unique_ptr<Project>& project, Scene& scene) {
if (ImGui::BeginMenu("Scene")) {
if (ImGui::MenuItem("Save scene"))
{
nfdresult_t result = NFD_SaveDialog({ "yscene" }, NULL, &path);
switch (result) {
case(NFD_OKAY):
SaveScene(path, scene);
break;
case(NFD_CANCEL):
break;
case(NFD_ERROR):
std::cout << "NFD_Error: " << NFD_GetError() << std::endl;
break;
}
}
if (ImGui::MenuItem("Load scene"))
{
auto result = NFD_OpenDialog({ "yscene" }, NULL, &path);
switch (result) {
case (NFD_OKAY):
LoadScene(path, scene);
break;
case(NFD_CANCEL):
break;
case(NFD_ERROR):
std::cout << "NFD_Error: " << NFD_GetError() << std::endl;
break;
}
}
if (ImGui::MenuItem("Add Entity"))
{
scene.AddEntity("New Entity");
}
if (ImGui::MenuItem("Import Model"))
{
auto result = NFD_OpenDialog("obj,fbx,gltf", NULL, &path);
switch (result) {
case(NFD_OKAY):
// Import Model
AssetManager::LoadFromSource(
path,
"build/Debug/Assets"//project.get()->GetProjectDirectory() / "Assets"
);
break;
case(NFD_CANCEL):
break;
case(NFD_ERROR):
std::cout << "NFD_Error: " << NFD_GetError() << std::endl;
break;
}
}
if (ImGui::MenuItem("Import MeshAsset (temp)"))
{
auto result = NFD_OpenDialog("mesh", NULL, &path);
switch (result) {
case(NFD_OKAY):
{
YoggieEngine::Mesh* importedMesh = AssetManager::LoadFromAssetFile(path);
if (importedMesh != nullptr)
{
auto full_name = std::filesystem::path(path);
auto importedModel = scene.AddEntity(full_name.filename().u8string());
auto& rendererComponent = importedModel.AddComponent<Render3DComponent>();
rendererComponent.mesh = *importedMesh;
}
}
break;
case(NFD_CANCEL):
spdlog::debug("User cancelled action");
break;
case(NFD_ERROR):
spdlog::warn("Something went wrong!");
break;
}
}
ImGui::EndMenu();
}
}
void DebugMenu()
{
if (ImGui::BeginMenu("Debug")) {
ImGui::EndMenu();
}
}
void SelectMenu() {
if (ImGui::BeginMenu("Select")) {
ImGui::EndMenu();
}
}
void WindowMenu() {
if (ImGui::BeginMenu("Window")) {
ImGui::EndMenu();
}
}
void Help() {
if (ImGui::BeginMenu("Help")) {
ImGui::EndMenu();
}
}
~MainMenuBar() { ImGui::EndMainMenuBar(); }
private:
char* path = nullptr;
};

375
Editor/src/UI/widgets.h Normal file
View File

@ -0,0 +1,375 @@
#pragma once
#include <string>
#include <glm/glm.hpp>
#include <imgui.h>
#include "../../libs/guizmo/ImGuizmo.h"
#include "../../YoggieEngine/src/YoggieEngine.h"
#include "../../src/Scene/Entity.h"
#include "EditorWindow.h"
#include "EditorConsole.h"
#include "../Project/Project.h"
#include "../AssetManagement/AssetManager.h"
typedef void ( *voidFunction ) (void);
using namespace YoggieEngine;
auto matrix = glm::mat4(1.0f);
auto worldOrigin = glm::mat4(1.0f);
inline void ComponentView(const std::string& componentName, voidFunction func)
{
ImGuiWindowFlags_ window_flags = ImGuiWindowFlags_None;
ImGui::PushStyleVar(ImGuiStyleVar_ChildRounding, 5.0f);
ImGui::BeginChild(componentName.c_str());
func();
ImGui::EndChild();
ImGui::PopStyleVar();
}
class Inspector : EditorWindow {
public:
Inspector() : EditorWindow("Inspector") {}
void AddComponentDropDown(Entity& selected )
{
static char* names[] = { "Script Component", "Camera Component", "Light Component"};
if (ImGui::Button("Add Component"))
ImGui::OpenPopup("Component picker");
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 "
<< selected.GetComponent<IdentifierComponent>().name << std::endl;
}
ImGui::EndPopup();
}
ImGui::NewLine();
}
void ShowComponents(Entity& selected)
{
auto component = selected.GetComponent<IdentifierComponent>();
ImGui::InputText("Name:", (char*)component.name.c_str(), component.name.size() * sizeof(char), ImGuiInputTextFlags_ReadOnly);
if (selected.HasComponent<TransformComponent>()) {
auto& transform = selected.GetComponent<TransformComponent>();
if (ImGui::CollapsingHeader("Transform", ImGuiTreeNodeFlags_DefaultOpen)) {
ImGui::DragFloat3("Position", glm::value_ptr(transform.Position), 0.1f);
ImGui::DragFloat3("Rotation", glm::value_ptr(transform.Rotation), 0.1f);
ImGui::DragFloat3("Scale", glm::value_ptr(transform.Scale), 0.1f, 0.0f);
}
if (selected.HasComponent<RelationComponent>()) {
ImGui::Text("Has relation");
}
}
if (selected.HasComponent<Render3DComponent>()) {
auto& render3d = selected.GetComponent<Render3DComponent>();
if (ImGui::CollapsingHeader("Render3D", ImGuiTreeNodeFlags_DefaultOpen)) {
ImGui::ColorEdit3("Colour", glm::value_ptr(render3d.color));
}
}
static bool deferred = true;
if (selected.HasComponent<LightComponent>()) {
auto& light = selected.GetComponent<LightComponent>();
if (ImGui::CollapsingHeader("Light", ImGuiTreeNodeFlags_DefaultOpen)) {
ImGui::ColorEdit3("Colour", glm::value_ptr(light.Color));
ImGui::Checkbox("Deferred", &deferred);
}
}
if (selected.HasComponent <CameraComponent>()) {
auto& camera = selected.GetComponent<CameraComponent>();
if (ImGui::CollapsingHeader("Camera")) {
ImGui::DragFloat3("Position:",glm::value_ptr(camera.Position), 0.01f);
ImGui::DragFloat3("Rotation:", glm::value_ptr(camera.Rotation), 0.01f);
}
}
if (selected.HasComponent<ScriptComponent>()) {
ComponentView("Scripting", [] {
ImGui::LabelText("##--", "Hello scripting");
});
}
}
};
class SceneExplorer : EditorWindow {
public:
SceneExplorer(entt::entity& selected , Scene& scene) : EditorWindow("SceneExplorer") {
scene.getReg().each([&](entt::entity enttNumber) {
Entity entity = Entity(enttNumber, &scene);
auto id = entity.GetComponent<IdentifierComponent>();
if (ImGui::Selectable(id.name.c_str(), enttNumber == selected)) {
selected = enttNumber;
}
});
}
};
class Viewport : EditorWindow {
public:
Viewport (Framebuffer& fb, Camera cam) : EditorWindow("SceneView")
{
ImVec2 WinPos = ImGui::GetWindowPos();
ImVec2 ContentRegionMin = ImGui::GetWindowContentRegionMin();
ImVec2 ContentRegionMax = ImGui::GetWindowContentRegionMax();
ImVec2 ScreenSpaceMin = { ContentRegionMin.x + WinPos.x, ContentRegionMin.y + WinPos.y };
ImVec2 ScreenSpaceMax = { ContentRegionMax.x + WinPos.x,ContentRegionMax.y + WinPos.y };
ImGui::Image(
(void*)(intptr_t)fb.GetColourAttachment(),
ImVec2{ (float)ImGui::GetWindowWidth(),(float)ImGui::GetWindowHeight() }
);
ImGuizmo::Enable(true);
ImGuizmo::SetRect(ScreenSpaceMin.x, ScreenSpaceMin.y,ContentRegionMax.x, ContentRegionMax.y);
glm::mat4 transposed_view = glm::transpose(cam.ViewMatrix);
ImGuizmo::DrawGrid(glm::value_ptr(cam.ViewMatrix), glm::value_ptr(cam.ProjectionMatrix), glm::value_ptr(worldOrigin), 100.0f);
ImGuizmo::ViewManipulate(glm::value_ptr(transposed_view), 1, { ScreenSpaceMin.x,ScreenSpaceMin.y }, { 90,90 }, 0x22CCCCCC);
// Matrix is the model matrix we would want to manipulate
//ImGuizmo::Manipulate(glm::value_ptr(cam.ViewMatrix), glm::value_ptr(cam.ProjectionMatrix), ImGuizmo::TRANSLATE, ImGuizmo::WORLD, glm::value_ptr(cam.ViewMatrix));
if (ImGui::IsWindowFocused() )
{
isFocused = true;
}
else {
isFocused = false;
}
}
bool isFocused = false;
};
int selectedGfxAPI = 0;
int selectedPhysicsEngine = 0;
glm::vec3 Gravity = glm::vec3(0.0f, -9.81f, 0.0f);
bool ShowAdvancedOptions = false;
bool DebugEngine = false;
class Settings : EditorWindow {
public:
Settings() : EditorWindow("Settings")
{
ImGui::LabelText("##title-settings", "Fine grain control over the engine!");
if (ImGui::BeginCombo("Graphics API", GraphicsAPI[selectedGfxAPI])) {
for (int i = 0; i < 3; i++) {
bool isSelected = i == selectedGfxAPI;
if (ImGui::Selectable(GraphicsAPI[i], isSelected)) {
selectedGfxAPI = i;
}
if(isSelected)
ImGui::SetItemDefaultFocus();
}
ImGui::EndCombo();
}
ImGui::NewLine();
if (ImGui::BeginCombo("Physics Engine", PhysicsEngine[selectedPhysicsEngine])) {
for (int i = 0; i < 2; i++) {
bool isSelected = i == selectedPhysicsEngine;
if (ImGui::Selectable(PhysicsEngine[i], isSelected)) {
selectedGfxAPI = i;
}
if (isSelected)
ImGui::SetItemDefaultFocus();
}
ImGui::EndCombo();
}
ImGui::InputFloat3("Gravity", glm::value_ptr(Gravity));
ImGui::NewLine();
if (ImGui::Button("Show Advanced options ")) {
ShowAdvancedOptions = !ShowAdvancedOptions;
}
if (ShowAdvancedOptions)
{
ImGui::Checkbox("Debug Engine", &DebugEngine);
}
}
private:
const char* PhysicsEngine[2] = {
"PhysX",
"Jolt Physics"
};
const char* GraphicsAPI[3] = {
"OpenGL",
"Vulkan",
"Metal (Apple)"
};
};
class ProjectInfo : EditorWindow {
public:
ProjectInfo(Project& project) : EditorWindow("Project Info") {
ImGui::Text("Project: %s", project.GetName().c_str());
ImGui::Text("Directory: %s", project.GetProjectDirectory().u8string().c_str());
}
};
class Console : EditorWindow {
public:
Console() : EditorWindow("Console") {
s_console = std::make_unique<EditorConsole>();
}
void Show() {
s_console.get()->Draw();
}
private:
std::unique_ptr<EditorConsole> s_console;
};
class AssetFinder : EditorWindow {
public:
AssetFinder() : EditorWindow("Assets") {
ImGui::DragInt("IconSize", &iconSize, 1, 30, 90);
if (ImGui::BeginTable("##resources", 3))
{
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.f, 0.f, 0.f, 0.f));
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0.f, 0.f, 0.f, 0.f));
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(1.f, 1.f, 1.f, 0.2f));
Texture folderIcon = Texture("rsc/folderIcon.png");
Texture assetIcon = Texture("rsc/assetIcon.png");
int row = 0;
int column = 0;
for (auto& asset : AssetManager::assets) {
if (column % 3 == 0) {
ImGui::TableNextRow();
column = 0;
row++;
}
ImGui::TableSetColumnIndex(column);
if (asset.isFolder) {
ImGui::ImageButton(
(ImTextureID)folderIcon.GetID(),
ImVec2{ (float)iconSize,(float)iconSize });
ImGui::Text(asset.GetName(), row);
}
else {
ImGui::ImageButton(
(ImTextureID)assetIcon.GetID(),
ImVec2{ (float)iconSize, (float)iconSize });
ImGui::Text(asset.GetName(), row);
}
column++;
}
ImGui::PopStyleColor(3);
ImGui::EndTable();
const GLuint textures[2]{ assetIcon.GetID(), folderIcon.GetID() };
glDeleteTextures(2, textures );
}
}
private:
int iconSize = 60;
};
#define RuntimeControlWindowFlags (ImGuiWindowFlags_)(ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse)
struct ButtonInfo {
const char* Name;
ImVec4 Color;
};
class RuntimeControls : EditorWindow {
public:
RuntimeControls() : EditorWindow("RuntimeControls", RuntimeControlWindowFlags) {
ImGui::SameLine((ImGui::GetWindowContentRegionMax().x / 2) - ( numButtons * buttonSize.x ));
for (int i = 0; i < numButtons; i++) {
ImVec4 color = button[i].Color;
ImGui::PushStyleColor(ImGuiCol_Button, color);
const float strengthIncrease = 1.5f;
ImGui::PushStyleColor(
ImGuiCol_ButtonHovered,
ImVec4{
color.x * strengthIncrease,
color.y * strengthIncrease,
color.z * strengthIncrease,
color.w
}
);
if (ImGui::Button(button[i].Name, buttonSize)) {
}
ImGui::PopStyleColor();
ImGui::PopStyleColor();
ImGui::SameLine();
}
}
private:
ImVec2 buttonSize = ImVec2{ 90 ,25 };
unsigned int numButtons = 2;
ButtonInfo button[2] = {
{"Play" , ImVec4{ 0.001 * 12 , 0.001 * 201 , 0.001* 69, 1.0f}},
{"Simulate", ImVec4{ 0.001 * 14, 0.001 * 157, 0.001 * 201, 1.0f}}
};
};

View File

@ -1,55 +0,0 @@
#include "Viewport.h"
Viewport::Viewport(YoggieEngine::Scene& scene ):
EditorWindow("SceneView"),
renderer(YoggieEngine::RendererConfig{ 1200, 700, glm::vec3(0), true }),
cam(glm::vec3(14.0f, 1.0f, 0.0f), glm::vec3(0.0f, 0.0f, 0.0f), 90),
scene(scene)
{
renderer.SetMainCamera(cam);
}
void Viewport::Draw() {
auto group = scene.getReg().view<YoggieEngine::TransformComponent, YoggieEngine::Render3DComponent>();
group.each([&](auto enity, YoggieEngine::TransformComponent& t, YoggieEngine::Render3DComponent& renderComponent) {
renderer.Submit(renderComponent, t);
});
cam.Update();
renderer.Render(scene);
ImVec2 WinPos = ImGui::GetWindowPos();
ImVec2 ContentRegionMin = ImGui::GetWindowContentRegionMin();
ImVec2 ContentRegionMax = ImGui::GetWindowContentRegionMax();
ImVec2 ScreenSpaceMin = { ContentRegionMin.x + WinPos.x, ContentRegionMin.y + WinPos.y };
ImVec2 ScreenSpaceMax = { ContentRegionMax.x + WinPos.x,ContentRegionMax.y + WinPos.y };
ImGui::Image(
(void*)(intptr_t)renderer.getCurrentFrameBuffer().GetColourAttachment(),
ImVec2{ (float)ImGui::GetWindowWidth(),(float)ImGui::GetWindowHeight() }
);
ImGuizmo::Enable(true);
ImGuizmo::SetRect(ScreenSpaceMin.x, ScreenSpaceMin.y, ContentRegionMax.x, ContentRegionMax.y);
glm::mat4 transposed_view = glm::transpose(cam.ViewMatrix);
//ImGuizmo::DrawGrid(glm::value_ptr(cam.ViewMatrix), glm::value_ptr(cam.ProjectionMatrix), glm::value_ptr(worldOrigin), 100.0f);
//ImGuizmo::ViewManipulate(glm::value_ptr(cam.ViewMatrix), 1, { ScreenSpaceMin.x,ScreenSpaceMin.y }, { 90,90 }, 0x22CCCCCC);
// Matrix is the model matrix we would want to manipulate
//ImGuizmo::Manipulate(glm::value_ptr(cam.ViewMatrix), glm::value_ptr(cam.ProjectionMatrix), ImGuizmo::TRANSLATE, ImGuizmo::WORLD, glm::value_ptr(cam.ViewMatrix));
if (ImGui::IsWindowFocused())
{
isFocused = true;
}
else {
isFocused = false;
}
}

View File

@ -1,24 +0,0 @@
#pragma once
#include "../../YoggieEngine/src/YoggieEngine.h"
#include "../EditorWindow.h"
#include <glm/glm.hpp>
#include <imgui.h>
#include "../../libs/guizmo/ImGuizmo.h"
class Viewport : public EditorWindow {
public:
bool isFocused = false;
YoggieEngine::Camera cam;
Viewport(YoggieEngine::Scene& scene);
void Draw() override;
private:
YoggieEngine::Renderer renderer;
YoggieEngine::Scene& scene;
};

View File

@ -8,51 +8,72 @@
#include <glm/gtc/type_ptr.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include "UI/GUIRenderer.h"
#include "UI/Widgets.h"
#include "Project/Project.h"
#include "AssetManagement/SceneSerializer.h"
#include "SceneSerializer.h"
#include "AssetManagement/AssetManager.h"
#include "UI/MainMenuBar.h"
void CreateTestProject(std::unique_ptr<Project>& project, Scene& scene);
#include "Views/Viewport.h"
#include "PropertyPanels/SceneExplorer.h"
#include "AssetManagement/AssetFinder.h"
#include "MainMenuBar.h"
#include "PropertyPanels/Inspector.h"
#include "Project/ProjectInfo.h"
#include "Runtime/RuntimeControls.h"
#include "Project/Settings.h"
#include "Console.h"
using namespace YoggieEngine;
RendererConfig EditorSceneRendererConfig{
1200, // Screen Width
700, // Screen Height
glm::vec3{0,0,0}, // Clear Color
true // Depth testing
};
glm::vec3 temp = glm::vec3(0);
Camera cam = Camera(glm::vec3(14.0f, 1.0f, 0.0f), glm::vec3(0.0f, 0.0f, 0.0f), 90);
class Editor : public Application {
public:
Editor() : Application("Editor"), Selected((entt::entity)-1){}
void Run() override
Editor()
: Application("Editor"),
AppWindow(1200,700),
framebuffer(new Framebuffer(1200,700)),
viewportRenderer(EditorSceneRendererConfig),
EditorGUIRenderer(AppWindow),
Selected((entt::entity)-1)
{
LoadLastOrEmptyProject();
MainMenuBar menuBar = MainMenuBar();
ProjectInfo projectInfo(project);
Viewport sceneview = Viewport(scene);
RuntimeControls rc = RuntimeControls();
SceneExplorer explorer(Selected, scene);
Inspector inspector = Inspector();
Settings settings = Settings();
// AssetFinder assetsView = AssetFinder();
Console console = Console();
init_inputSystem(&AppWindow);
viewportRenderer.setCurrentFrameBuffer(*framebuffer);
}
double previous = glfwGetTime();
double lag = 0.0;
while (!appWindow.WindowShouldClose())
void RenderScene() {
// submit DrawCommands for all render3DComponents
auto group = ActiveScene.getReg().view<TransformComponent, Render3DComponent>();
group.each([&](auto enity, TransformComponent& t, Render3DComponent& renderComponent) {
viewportRenderer.Submit(renderComponent, t);
});
// Render scene
viewportRenderer.Render(ActiveScene);
}
void RenderEditorGUI() {
EditorGUIRenderer.Begin();
ImGui::DockSpaceOverViewport(ImGui::GetMainViewport());
// Show a menu bar
{
PollEvents();
double now = glfwGetTime();
double elapsed = now - previous ;
previous = now;
lag += elapsed;
MainMenuBar menuBar = MainMenuBar();
menuBar.ApplicationMenu(CurrentProject);
menuBar.SceneMenu(CurrentProject, ActiveScene);
menuBar.SelectMenu();
menuBar.WindowMenu();
menuBar.DebugMenu();
menuBar.Help();
}
{
ProjectInfo projectInfo(*(CurrentProject.get()));
}
{
Viewport sceneview = Viewport(*framebuffer, viewportRenderer.getCamera());
if (sceneview.isFocused)
{
const float movement_speed = 0.1f;
@ -60,11 +81,13 @@ public:
const float sensitivity = 0.1;
static bool firstMouse = true;
if (MouseButtonPressed(YOGGIE_MOUSE_BUTTON_RIGHT)) {
glfwSetInputMode(appWindow.GetGLFWHandle(), GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
auto newX = getCursorPosX(&appWindow);
auto newY = getCursorPosY(&appWindow);
if (MouseButtonPressed(YOGGIE_MOUSE_BUTTON_MIDDLE) ){
auto newX = getCursorPosX(&AppWindow);
auto newY = getCursorPosY(&AppWindow);
if (firstMouse)
{
@ -83,124 +106,145 @@ public:
xoffset *= sensitivity;
yoffset *= sensitivity;
sceneview.cam.yaw += xoffset;
sceneview.cam.pitch += yoffset;
cam.yaw += xoffset;
cam.pitch += yoffset;
if (sceneview.cam.pitch > 89.0f)
sceneview.cam.pitch = 89.0f;
if (sceneview.cam.pitch < -89.0f)
sceneview.cam.pitch = -89.0f;
if (cam.pitch > 89.0f)
cam.pitch = 89.0f;
if (cam.pitch < -89.0f)
cam.pitch = -89.0f;
}
else if (firstMouse == false)
{
glfwSetInputMode(appWindow.GetGLFWHandle(), GLFW_CURSOR, GLFW_CURSOR_NORMAL);
firstMouse = true;
}
// Check for Camara movement input here!
if (keyIsPressed(YOGGIE_KEY_W))
sceneview.cam.Position += sceneview.cam.Front * movement_speed;
if (keyIsPressed(YOGGIE_KEY_W)) {
cam.Position += cam.Front * movement_speed;
}
if (keyIsPressed(YOGGIE_KEY_A))
sceneview.cam.Position -= sceneview.cam.Right * movement_speed;
{
cam.Position -= cam.Right * movement_speed;
}
if (keyIsPressed(YOGGIE_KEY_S)) {
cam.Position -= cam.Front * movement_speed;
}
if (keyIsPressed(YOGGIE_KEY_D)) {
cam.Position += cam.Right * movement_speed;
}
if (keyIsPressed(YOGGIE_KEY_S))
sceneview.cam.Position -= sceneview.cam.Front * movement_speed;
if (keyIsPressed(YOGGIE_KEY_D))
sceneview.cam.Position += sceneview.cam.Right * movement_speed;
}
GuiBegin();
}
// Show a menu bar
menuBar.ApplicationMenu(project);
menuBar.SceneMenu(project, scene);
menuBar.SelectMenu();
menuBar.WindowMenu();
menuBar.DebugMenu();
menuBar.Help();
{
RuntimeControls rc = RuntimeControls();
}
if (scene.getReg().valid(Selected)) {
Entity SelectedEntity = Entity(Selected, &scene);
{
SceneExplorer explorer(Selected, ActiveScene);
}
{
Inspector inspector = Inspector();
if (ActiveScene.getReg().valid(Selected)) {
Entity SelectedEntity = Entity(Selected, &ActiveScene);
inspector.AddComponentDropDown(SelectedEntity);
inspector.ShowComponents(SelectedEntity);
}
projectInfo.Update();
sceneview.Update();
rc.Update();
explorer.Update();
settings.Update();
inspector.Update();
console.Update();
ImGui::ShowDemoWindow();
ImGui::ShowMetricsWindow();
GuiEnd();
SwapBuffers();
}
{
Settings settings = Settings();
}
{
// AssetFinder assetsView = AssetFinder();
}
{
Console console = Console();
console.Show();
}
ImGui::ShowDemoWindow();
ImGui::ShowMetricsWindow();
EditorGUIRenderer.End();
}
void LoadLastOrEmptyProject() {
// Check if there is a last known loaded project and
// load that one .
// Otherwise load no project..
// OR
// Load an empty project.
std::string path = (std::filesystem::current_path()).string();
project.setProjectDirectory(path);
AssetManager::Init();
AssetManager::setAssetPath(project.GetProjectDirectory());
AssetManager::BuildAssetView();
// Create a level and load it as the current level
auto importer = ModelImporter();
void Run() override
{
CreateTestProject(CurrentProject, ActiveScene);
ActiveScene.Start();
// create an ambient light source
auto light = scene.AddEntity("Light");
auto& lightComponent = light.AddComponent<LightComponent>();
lightComponent.Color = glm::vec3(1.0f);
// Create the physics engine demo!
Physics Physics;
Physics.Demo();
/*Physics.EnableDebugVisuals();
Physics.Step(0);
Physics.SubmitMesh();
*/
double previous = glfwGetTime();
double lag = 0.0;
while (!AppWindow.WindowShouldClose())
{
double current = glfwGetTime();
double elapsed = current - previous;
previous = current;
lag += elapsed;
AppWindow.Poll();
cam.Update();
Physics.Step(elapsed);
ActiveScene.Update();
RenderScene();
/*Physics.DebugRender(*framebuffer);*/
RenderEditorGUI();
AppWindow.SwapBuffers();
glClear(GL_COLOR_BUFFER_BIT| GL_DEPTH_BUFFER_BIT);
// Create a cube
auto model = importer.Import("build/Debug/Models/Cube.obj");
}
auto cube = scene.AddEntity("Cube");
auto& render3DComponent = cube.AddComponent<Render3DComponent>();
render3DComponent.mesh = *(model->renderable->mesh);
delete framebuffer;
ActiveScene.Stop();
cube.GetComponent<TransformComponent>().Position = glm::vec3(1.0f, 0.0f, 5.0f);
auto cube2 = scene.AddEntity("Cube2");
auto& rendercube2 = cube2.AddComponent<Render3DComponent>();
rendercube2.mesh = *(model->renderable->mesh);
auto& relationcube = cube.AddComponent<RelationComponent>(cube2);
auto& rigidbodycomp = cube.AddComponent<RigidBody>();
auto& rigidbodycomp2 = cube2.AddComponent<RigidBody>();
auto Grass = scene.AddEntity("Grass/Window-Pane");
//auto& renderGrass = Grass.AddComponent<Render3DComponent>();
}
private:
NativeWindow AppWindow;
Framebuffer* framebuffer;
Renderer viewportRenderer;
GUIRenderer EditorGUIRenderer;
// Editor State
bool SimulatePhysics = true;
entt::entity Selected;
Project project;
Scene scene;
std::unique_ptr<Project> CurrentProject;
Scene ActiveScene;
};
@ -209,3 +253,43 @@ YoggieEngine::Application* CreateApplication() {
return new Editor();
}
void CreateTestProject(std::unique_ptr<Project>& project, Scene& scene ) {
project = std::make_unique<Project>();
std::string path = (std::filesystem::current_path()).string();
project.get()->setProjectDirectory(path);
AssetManager::Init();
AssetManager::setAssetPath(project.get()->GetProjectDirectory());
AssetManager::BuildAssetView();
// Create a level and load it as the current level
auto importer = ModelImporter();
// create an ambient light source
auto light = scene.AddEntity("Light");
auto lightComponent = light.AddComponent<LightComponent>();
lightComponent.Color = glm::vec3(1.0f);
// Create a cube
auto model = importer.Import("build/Debug/Models/Cube.obj");
auto cube = scene.AddEntity("Cube");
auto& render3DComponent = cube.AddComponent<Render3DComponent>();
render3DComponent.mesh = *(model->renderable->mesh);
cube.GetComponent<TransformComponent>().Position = glm::vec3(1.0f, 0.0f, 5.0f);
auto cube2 = scene.AddEntity("Cube2");
auto& rendercube2 = cube2.AddComponent<Render3DComponent>();
rendercube2.mesh = *(model->renderable->mesh);
auto relationcube = cube.AddComponent<RelationComponent>(cube2);
auto Grass = scene.AddEntity("Grass/Window-Pane");
//auto& renderGrass = Grass.AddComponent<Render3DComponent>();
}

View File

@ -1,37 +1,16 @@
#include <YoggieEngine.h>
#include "Application.h"
#include <imgui.h>
#include <backends/imgui_impl_opengl3.h>
#include <backends/imgui_impl_glfw.h>
#include "../../libs/guizmo/ImGuizmo.h"
namespace YoggieEngine {
Application::Application(const std::string& name)
: m_AppName(name), appWindow(1200, 700)
: m_AppName(name)
{
// Initialize engine should possibly happen here
EngineInstrumentation::PerfomanceSamplerInit();
// Initilize ImGui for this application
IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO();
io.ConfigFlags |= ImGuiConfigFlags_::ImGuiConfigFlags_ViewportsEnable;
io.ConfigFlags |= ImGuiConfigFlags_::ImGuiConfigFlags_DockingEnable;
io.Fonts->AddFontFromFileTTF("build/Debug/Fonts/Roboto-Regular.ttf", 18);
ImGui::StyleColorsDark();
ImGui_ImplGlfw_InitForOpenGL(appWindow.GetGLFWHandle(), true);
ImGui_ImplOpenGL3_Init("#version 450");
ImGuizmo::SetImGuiContext(ImGui::GetCurrentContext());
ImGuizmo::SetOrthographic(true);
init_inputSystem(&appWindow);
}
@ -40,46 +19,5 @@ namespace YoggieEngine {
}
void Application::PollEvents() {
appWindow.Poll();
}
void Application::SwapBuffers()
{
appWindow.SwapBuffers();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
void Application::GuiBegin() {
ImGui_ImplGlfw_NewFrame();
ImGui_ImplOpenGL3_NewFrame();
ImGui::NewFrame();
ImGuizmo::BeginFrame();
ImGui::DockSpaceOverViewport(ImGui::GetMainViewport());
}
void Application::GuiEnd() {
ImGui::EndFrame();
ImGui::Render();
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
if (ImGui::GetIO().ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{
GLFWwindow* last_context = glfwGetCurrentContext();
ImGui::UpdatePlatformWindows();
ImGui::RenderPlatformWindowsDefault();
glfwMakeContextCurrent(last_context);
}
}
Application::~Application() {
ImGui_ImplOpenGL3_Shutdown();
ImGui_ImplGlfw_Shutdown();
ImGui::DestroyContext();
}
Application::~Application() {}
}

View File

@ -10,17 +10,9 @@ namespace YoggieEngine {
~Application();
virtual void Run();
void PollEvents();
void SwapBuffers();
void GuiBegin();
void GuiEnd();
protected:
std::string m_AppName;
NativeWindow appWindow;
friend class ApplicationRuntime;
};

View File

@ -3,7 +3,6 @@ namespace YoggieEngine {
class Camera {
public:
Camera() = default;
Camera(const Camera& other);
Camera(glm::vec3 position, glm::vec3 rotation, float zoom);
~Camera();

View File

@ -2,14 +2,12 @@
#include "Scene/Components.h"
namespace YoggieEngine {
struct DrawCommand {
bool isDynamic;
unsigned int VAO_identifier;
unsigned int num_elements;
unsigned int IBO_identifier;
TransformComponent& transform;
Shader& shader;
glm::vec3& color;
// Material
};
};

View File

@ -6,6 +6,7 @@
#include "../Graphics/Memory/VertexArray.h"
#include "../Graphics/Primitives/DrawCommand.h"
extern YoggieEngine::Camera cam;
namespace YoggieEngine {
unsigned int quadVAO = 0;
unsigned int quadVBO = 0;
@ -20,6 +21,7 @@ std::vector<glm::vec3> vegetation = {
unsigned int transparentVAO, transparentVBO;
Texture grassTexture;
float skyboxVertices[]{
// positions
-1.0f, 1.0f, -1.0f,
@ -70,8 +72,7 @@ Renderer::Renderer(RendererConfig& config)
gBufferShader("build/Debug/Shaders/deferred/geometry.vert", "build/Debug/Shaders/deferred/geometry.frag"),
lightingPassShader("build/Debug/Shaders/deferred/lightPass.vert", "build/Debug/Shaders/deferred/lightPass.frag"),
SkyboxShader("build/Debug/Shaders/Cubemaps/Skybox.vert", "build/Debug/Shaders/Cubemaps/Skybox.frag"),
BlendingShader("build/Debug/Shaders/forward/Blending.vert", "build/Debug/Shaders/forward/Blending.frag"),
forwardShader("build/Debug/Shaders/forward/geometry.vert", "build/Debug/Shaders/forward/geometry.frag")
BlendingShader("build/Debug/Shaders/forward/Blending.vert", "build/Debug/Shaders/forward/Blending.frag")
{
width = config.ScreenWidth;
height = config.ScreenHeight;
@ -158,6 +159,10 @@ Renderer::Renderer(RendererConfig& config)
Renderer::~Renderer(){}
Camera& Renderer::getCamera() {
return cam;
}
void SubmitVegetationDemo() {
@ -226,7 +231,7 @@ void Renderer::Submit( Render3DComponent& renderComponent, TransformComponent& t
renderComponent.IBO = elementBuffer.getBufferID();
}
DrawCommand dc = { renderComponent.isStatic , renderComponent.VAO, renderComponent.mesh.elements.size(), renderComponent.IBO, transform, renderComponent.color };
DrawCommand dc = { renderComponent.VAO, renderComponent.mesh.elements.size(), renderComponent.IBO, transform, renderComponent.shader, renderComponent.color };
commands.push_back(dc);
}
@ -237,16 +242,13 @@ void Renderer::GeometryPass() {
for (const DrawCommand& command : commands)
{
if (command.isDynamic == true)
continue;
glBindVertexArray(command.VAO_identifier);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, command.IBO_identifier);
gBufferShader.setUniformVec3("Color", command.color);
gBufferShader.setUniformMat4("Model", command.transform.LocalTransform);
gBufferShader.setUniformMat4("View", MainCamera.ViewMatrix);
gBufferShader.setUniformMat4("Projection", MainCamera.ProjectionMatrix);
gBufferShader.setUniformMat4("View", cam.ViewMatrix);
gBufferShader.setUniformMat4("Projection", cam.ProjectionMatrix);
glDrawElements(GL_TRIANGLES, static_cast<unsigned int>(command.num_elements),
GL_UNSIGNED_INT, NULL);
@ -261,8 +263,8 @@ void Renderer::SkyboxPass() {
// Render skybox
glDepthMask(GL_FALSE);
SkyboxShader.Use();
SkyboxShader.setUniformMat4("projection", MainCamera.ProjectionMatrix);
SkyboxShader.setUniformMat4("view", glm::mat4(glm::mat3(MainCamera.ViewMatrix))); // remove rotation from the view matrix
SkyboxShader.setUniformMat4("projection", cam.ProjectionMatrix);
SkyboxShader.setUniformMat4("view", glm::mat4(glm::mat3(cam.ViewMatrix))); // remove rotation from the view matrix
glBindVertexArray(skyboxVAO);
glBindTexture(GL_TEXTURE_CUBE_MAP, sky.getID());
glDrawArrays(GL_TRIANGLES, 0, 36);
@ -309,7 +311,7 @@ void Renderer::lightingPass(Scene& scene){
lightnr++;
});
lightingPassShader.setUniformVec3("viewPos", MainCamera.Position);
lightingPassShader.setUniformVec3("viewPos", getCamera().Position);
// render to quad
if (quadVAO == 0)
@ -348,8 +350,8 @@ void Renderer::BlendingPass() {
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, grassTexture.GetID());
BlendingShader.setUniformMat4("V", MainCamera.ViewMatrix);
BlendingShader.setUniformMat4("P", MainCamera.ProjectionMatrix);
BlendingShader.setUniformMat4("V", cam.ViewMatrix);
BlendingShader.setUniformMat4("P", cam.ProjectionMatrix);
for (unsigned int i = 0; i < vegetation.size(); i++) {
@ -367,6 +369,10 @@ void Renderer::BlendingPass() {
}
void Renderer::Render(Scene& scene)
{
SubmitVegetationDemo();
@ -390,18 +396,15 @@ void Renderer::Render(Scene& scene)
for (const DrawCommand& command : commands)
{
if (command.isDynamic == false)
continue;
glBindVertexArray(command.VAO_identifier);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, command.IBO_identifier);
forwardShader.Use();
command.shader.Use();
forwardShader.setUniformVec3("Color", command.color);
forwardShader.setUniformMat4("M", command.transform.LocalTransform);
forwardShader.setUniformMat4("V", MainCamera.ViewMatrix);
forwardShader.setUniformMat4("P", MainCamera.ProjectionMatrix);
command.shader.setUniformVec3("Color", command.color);
command.shader.setUniformMat4("M", command.transform.LocalTransform);
command.shader.setUniformMat4("V", cam.ViewMatrix);
command.shader.setUniformMat4("P", cam.ProjectionMatrix);
glDrawElements(GL_TRIANGLES, static_cast<unsigned int>(command.num_elements),
GL_UNSIGNED_INT, NULL);
@ -423,6 +426,7 @@ void Renderer::Render(Scene& scene)
*/
commands.clear();
glBindFramebuffer(GL_FRAMEBUFFER, 0);
}

View File

@ -8,7 +8,6 @@
#include "../Scene/Components.h"
#include"../Scene/Scene.h"
#include "Graphics/Primitives/DrawCommand.h"
#include "Primitives/Camera.h"
namespace YoggieEngine {
@ -30,9 +29,8 @@ namespace YoggieEngine {
void setCurrentFrameBuffer(const Framebuffer& fb);
void setClearColor(const glm::vec3& ClearColor);
void SetMainCamera(const Camera& camera) { MainCamera = camera; }
Camera& getCamera();
Framebuffer& getCurrentFrameBuffer() { return m_framebuffer; }
private:
void GeometryPass();
void SkyboxPass();
@ -47,13 +45,11 @@ namespace YoggieEngine {
glm::vec3 m_clearColor;
bool m_depthTest;
std::vector<DrawCommand> commands;
Camera MainCamera;
unsigned int skyboxVAO = 0;
CubeMap sky;
Shader forwardShader;
// deferred rending parameters
unsigned int gBuffer, gPosition, gNormal, gColorSpec, gDepth;
Shader lightingPassShader;

View File

@ -28,6 +28,7 @@ namespace YoggieEngine {
gMaterial = nullptr;
mScene = nullptr;
}
Physics::~Physics()
@ -152,19 +153,6 @@ namespace YoggieEngine {
}
void Physics::addRigidBody(glm::mat4& transform)
{
PxShape* shape = mPhysics->createShape(PxBoxGeometry(1.0f, 1.0f, 1.0f), *gMaterial);
PxTransform localtm = PxTransform((const PxMat44&) transform);
PxRigidDynamic* body = mPhysics->createRigidDynamic(localtm);
body->attachShape(*shape);
PxRigidBodyExt::updateMassAndInertia(*body, 10.0f);
mScene->addActor(*body);
}
void Physics::createScene()
{
PxSceneDesc sceneDesc(mPhysics->getTolerancesScale());

View File

@ -31,20 +31,16 @@ namespace YoggieEngine {
void DebugRender(Framebuffer& framebuffer);
void addRigidBody(glm::mat4& transform);
void createScene();
void createGroundPlane();
void SetupPvdDebug();
private:
Shader debugDraw = Shader("build/Debug/Shaders/forward/debug.vert", "build/Debug/Shaders/forward/debug.frag");
PxRigidDynamic* createDynamic(const PxTransform& t, const PxGeometry& geometry, const PxVec3& velocity);
void createStack(const PxTransform& t, PxU32 size, PxReal halfextent);
void createScene();
void createGroundPlane();
void SetupPvdDebug();

View File

@ -42,31 +42,17 @@ namespace YoggieEngine {
std::string file; // TODO : replace with proper properties
};
struct RigidBody {
float Mass;
// Physics Material
};
struct BoxCollider {
glm::vec3 extents;
};
struct PlaneCollider {
};
struct Render3DComponent {
unsigned int VAO = 0;
unsigned int IBO = 0;
Mesh mesh;
// TODO: becomes a material
glm::vec3 color;
bool isStatic;
Shader shader;
Render3DComponent()
: color(glm::vec3(1.0f, 0.0f, 0.0f)) , isStatic(true)
: shader(Shader("build/Debug/Shaders/forward/geometry.vert", "build/Debug/Shaders/forward/geometry.frag")),
color(glm::vec3(1.0f, 0.0f, 0.0f))
{
}
};

View File

@ -26,7 +26,6 @@ namespace YoggieEngine{
void Scene::Start()
{
// Execute start functions in scripts etc....
}
void Scene::Update()

View File

@ -31,7 +31,6 @@ extern "C"
// Main library stuff
#include "Platform/Window.h"
#include "Graphics/Primitives/Mesh.h"
@ -54,4 +53,3 @@ extern "C"
#include "Scene/Scene.h"
#include "Scene/Components.h"
#include "Application.h"