Compare commits
No commits in common. "ba69726e336c0619ec1328162d72ce71d5972285" and "145338d666c4bf2f2454ec0fbe7902d7f30f6788" have entirely different histories.
ba69726e33
...
145338d666
7
.gitignore
vendored
7
.gitignore
vendored
@ -16,9 +16,4 @@ x64/
|
||||
*.gltf
|
||||
!sponza.gltf
|
||||
|
||||
imgui.ini
|
||||
libs/physx/physx/include/
|
||||
libs/physx/physx/compiler/
|
||||
libs/physx/physx/buildtools/
|
||||
libs/physx/physx/bin/
|
||||
libs/nativefiledialog/build/
|
||||
imgui.ini
|
6
.gitmodules
vendored
6
.gitmodules
vendored
@ -36,9 +36,3 @@
|
||||
[submodule "libs/nativefiledialog"]
|
||||
path = libs/nativefiledialog
|
||||
url = https://git.barink.dev/Nigel/nativefiledialog.git
|
||||
[submodule "libs/mINI"]
|
||||
path = libs/mINI
|
||||
url = https://github.com/pulzed/mINI.git
|
||||
[submodule "libs/imgui-filebrowser"]
|
||||
path = libs/imgui-filebrowser
|
||||
url = https://github.com/AirGuanZ/imgui-filebrowser.git
|
||||
|
BIN
Editor/Assets/Cube.mesh
Normal file
BIN
Editor/Assets/Cube.mesh
Normal file
Binary file not shown.
@ -30,7 +30,6 @@ includedirs{
|
||||
incfolder["entt"],
|
||||
incfolder["yamlcpp"],
|
||||
incfolder["nativefiledialog"],
|
||||
incfolder["mINI"]
|
||||
|
||||
|
||||
}
|
||||
|
@ -47,9 +47,6 @@ void MainMenuBar::ApplicationMenu(Project& project) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (ImGui::MenuItem("Preferences"))
|
||||
{
|
||||
@ -75,9 +72,6 @@ void MainMenuBar::SceneMenu(Project& project, YoggieEngine::Scene& scene) {
|
||||
switch (result) {
|
||||
case(NFD_OKAY):
|
||||
SaveScene(path, scene);
|
||||
|
||||
project.AddScene(scene);
|
||||
|
||||
break;
|
||||
case(NFD_CANCEL):
|
||||
break;
|
||||
|
@ -13,15 +13,6 @@ void Project::SaveProject(std::filesystem::path path, Project& project)
|
||||
projectYAML << YAML::Key << "Project" << YAML::Value << project.Name;
|
||||
projectYAML << YAML::Key << "Directory" << YAML::Value << path.parent_path().u8string();
|
||||
projectYAML << YAML::EndMap;
|
||||
projectYAML << YAML::BeginMap;
|
||||
|
||||
|
||||
projectYAML << YAML::Key << "Scenes" << YAML::Value << YAML::BeginSeq;
|
||||
for (auto scene : project.Scenes) {
|
||||
projectYAML << scene->name;
|
||||
}
|
||||
projectYAML << YAML::EndSeq;
|
||||
|
||||
std::ofstream projectFile;
|
||||
|
||||
projectFile.open(path.u8string());
|
||||
@ -65,12 +56,10 @@ namespace YAML {
|
||||
return false;
|
||||
rhs.setName(node["Project"].as<std::string>());
|
||||
rhs.setProjectDirectory(node["Directory"].as<std::string>());
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
@ -1,10 +1,6 @@
|
||||
#pragma once
|
||||
#include <filesystem>
|
||||
#include <iostream>
|
||||
#include "../../YoggieEngine/src/YoggieEngine.h"
|
||||
#include <yaml-cpp/yaml.h>
|
||||
|
||||
|
||||
class Project {
|
||||
public:
|
||||
Project() = default;
|
||||
@ -17,21 +13,10 @@ public:
|
||||
void setProjectDirectory(std::string& path) { ProjectDirectory = std::filesystem::path(path); }
|
||||
const std::filesystem::path GetProjectDirectory() { return ProjectDirectory; }
|
||||
|
||||
|
||||
void AddScene(YoggieEngine::Scene& scene)
|
||||
{
|
||||
Scenes.push_back(&scene);
|
||||
}
|
||||
|
||||
static void SaveProject(std::filesystem::path path, Project& project);
|
||||
static void LoadProject(std::filesystem::path path, Project& project);
|
||||
private:
|
||||
std::string Name;
|
||||
std::filesystem::path ProjectDirectory;
|
||||
|
||||
std::vector<YoggieEngine::Scene*> Scenes;
|
||||
|
||||
friend class YAML::convert<Project>;
|
||||
|
||||
};
|
||||
|
||||
|
@ -3,14 +3,11 @@
|
||||
|
||||
void Inspector::Draw()
|
||||
{
|
||||
if (selected.isValid()) {
|
||||
AddComponentDropDown();
|
||||
ShowComponents();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void Inspector::AddComponentDropDown()
|
||||
void Inspector::AddComponentDropDown(YoggieEngine::Entity& selected)
|
||||
{
|
||||
static char* names[] = { "Script Component", "Camera Component", "Light Component" };
|
||||
if (ImGui::Button("Add Component"))
|
||||
@ -31,7 +28,7 @@ void Inspector::AddComponentDropDown()
|
||||
}
|
||||
|
||||
|
||||
void Inspector::ShowComponents()
|
||||
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);
|
||||
|
@ -8,15 +8,13 @@ inline void ComponentView(const std::string& componentName, voidFunction func);
|
||||
|
||||
class Inspector : public EditorWindow {
|
||||
public:
|
||||
Inspector( YoggieEngine::Entity& selected ) : EditorWindow("Inspector"), selected(selected){}
|
||||
Inspector() : EditorWindow("Inspector") {}
|
||||
|
||||
void Draw()override;
|
||||
|
||||
private:
|
||||
|
||||
void AddComponentDropDown();
|
||||
void ShowComponents();
|
||||
void AddComponentDropDown(YoggieEngine::Entity& selected);
|
||||
|
||||
void ShowComponents(YoggieEngine::Entity& selected);
|
||||
|
||||
YoggieEngine::Entity& selected;
|
||||
};
|
||||
|
@ -6,8 +6,8 @@ void SceneExplorer::Draw()
|
||||
YoggieEngine::Entity entity = YoggieEngine::Entity(enttNumber, &scene);
|
||||
auto id = entity.GetComponent<YoggieEngine::IdentifierComponent>();
|
||||
|
||||
if (ImGui::Selectable(id.name.c_str(), entity == selected)) {
|
||||
selected = YoggieEngine::Entity(enttNumber, &scene);
|
||||
if (ImGui::Selectable(id.name.c_str(), enttNumber == selected)) {
|
||||
selected = enttNumber;
|
||||
}
|
||||
});
|
||||
}
|
@ -5,7 +5,7 @@
|
||||
|
||||
class SceneExplorer : public EditorWindow {
|
||||
public:
|
||||
SceneExplorer(YoggieEngine::Entity& selected, YoggieEngine::Scene& scene)
|
||||
SceneExplorer(entt::entity& selected, YoggieEngine::Scene& scene)
|
||||
: EditorWindow("SceneExplorer"), scene(scene), selected(selected)
|
||||
{}
|
||||
|
||||
@ -13,7 +13,7 @@ public:
|
||||
|
||||
|
||||
private:
|
||||
YoggieEngine::Entity& selected;
|
||||
entt::entity selected;
|
||||
YoggieEngine::Scene& scene;
|
||||
|
||||
|
||||
|
@ -1,10 +1,17 @@
|
||||
#include "../../YoggieEngine/src/EntryPoint.h"
|
||||
#include <mini/ini.h>
|
||||
#include "../../YoggieEngine/src/AssetManager/ModelImporter.h"
|
||||
#include "../../YoggieEngine/src/Physics/Physics.h"
|
||||
|
||||
#include <nfd.h>
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/type_ptr.hpp>
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
|
||||
#include "Project/Project.h"
|
||||
#include "AssetManagement/SceneSerializer.h"
|
||||
#include "AssetManagement/AssetManager.h"
|
||||
|
||||
#include "Views/Viewport.h"
|
||||
#include "PropertyPanels/SceneExplorer.h"
|
||||
#include "AssetManagement/AssetFinder.h"
|
||||
@ -17,32 +24,25 @@
|
||||
|
||||
using namespace YoggieEngine;
|
||||
|
||||
|
||||
class Editor : public Application {
|
||||
public:
|
||||
Editor() : Application("Editor"){}
|
||||
Editor() : Application("Editor"), Selected((entt::entity)-1){}
|
||||
|
||||
void Run() override
|
||||
{
|
||||
std::string path = (std::filesystem::current_path()).string();
|
||||
project.setProjectDirectory(path);
|
||||
|
||||
AssetManager::Init();
|
||||
AssetManager::setAssetPath(project.GetProjectDirectory());
|
||||
AssetManager::BuildAssetView();
|
||||
|
||||
LoadLastOrEmptyProject();
|
||||
|
||||
MainMenuBar menuBar = MainMenuBar();
|
||||
ProjectInfo projectInfo(project);
|
||||
Viewport sceneview = Viewport(scene);
|
||||
RuntimeControls rc = RuntimeControls();
|
||||
SceneExplorer explorer(Selected, scene);
|
||||
Inspector inspector = Inspector(Selected);
|
||||
Inspector inspector = Inspector();
|
||||
Settings settings = Settings();
|
||||
// AssetFinder assetsView = AssetFinder();
|
||||
Console console = Console();
|
||||
|
||||
Selected = YoggieEngine::Entity((entt::entity) -1, &scene);
|
||||
|
||||
double previous = glfwGetTime();
|
||||
double lag = 0.0;
|
||||
while (!appWindow.WindowShouldClose())
|
||||
@ -114,19 +114,23 @@ public:
|
||||
}
|
||||
|
||||
GuiBegin();
|
||||
{
|
||||
MainMenuBar menuBar = MainMenuBar();
|
||||
|
||||
// Show a menu bar
|
||||
menuBar.ApplicationMenu(project);
|
||||
menuBar.SceneMenu(project, scene);
|
||||
menuBar.SelectMenu();
|
||||
menuBar.WindowMenu();
|
||||
menuBar.DebugMenu();
|
||||
menuBar.Help();
|
||||
|
||||
}
|
||||
// Show a menu bar
|
||||
menuBar.ApplicationMenu(project);
|
||||
menuBar.SceneMenu(project, scene);
|
||||
menuBar.SelectMenu();
|
||||
menuBar.WindowMenu();
|
||||
menuBar.DebugMenu();
|
||||
menuBar.Help();
|
||||
|
||||
|
||||
if (scene.getReg().valid(Selected)) {
|
||||
Entity SelectedEntity = Entity(Selected, &scene);
|
||||
inspector.AddComponentDropDown(SelectedEntity);
|
||||
inspector.ShowComponents(SelectedEntity);
|
||||
}
|
||||
|
||||
|
||||
projectInfo.Update();
|
||||
sceneview.Update();
|
||||
rc.Update();
|
||||
@ -152,33 +156,48 @@ public:
|
||||
// Otherwise load no project..
|
||||
// OR
|
||||
// Load an empty project.
|
||||
mINI::INIStructure ini;
|
||||
|
||||
if (std::filesystem::exists("build\\Debug\\Editor.ini"))
|
||||
{
|
||||
mINI::INIFile file("build\\Debug\\Editor.ini");
|
||||
file.read(ini);
|
||||
}
|
||||
else
|
||||
{
|
||||
spdlog::debug("Could not find an `Editor.ini` file.");
|
||||
}
|
||||
std::string path = (std::filesystem::current_path()).string();
|
||||
project.setProjectDirectory(path);
|
||||
|
||||
if (ini["editor"]["openlastproject"] == "TRUE")
|
||||
{
|
||||
Project::LoadProject(ini["cache"]["project"], project);
|
||||
LoadScene(ini["cache"]["scene"], scene);
|
||||
AssetManager::Init();
|
||||
AssetManager::setAssetPath(project.GetProjectDirectory());
|
||||
AssetManager::BuildAssetView();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
spdlog::debug("Starting without a project. Please create one.");
|
||||
}
|
||||
// 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& rigidbodycomp = cube.AddComponent<RigidBody>();
|
||||
auto& rigidbodycomp2 = cube2.AddComponent<RigidBody>();
|
||||
|
||||
|
||||
auto Grass = scene.AddEntity("Grass/Window-Pane");
|
||||
//auto& renderGrass = Grass.AddComponent<Render3DComponent>();
|
||||
}
|
||||
|
||||
private:
|
||||
bool SimulatePhysics = true;
|
||||
YoggieEngine::Entity Selected;
|
||||
entt::entity Selected;
|
||||
|
||||
Project project;
|
||||
Scene scene;
|
||||
|
@ -1,8 +1,7 @@
|
||||
#pragma once
|
||||
#include "Scene.h"
|
||||
|
||||
typedef uint64_t ENTITY_UUID;
|
||||
namespace YoggieEngine {
|
||||
|
||||
class Scene;
|
||||
class Entity {
|
||||
public:
|
||||
Entity() = default;
|
||||
@ -26,15 +25,8 @@ namespace YoggieEngine {
|
||||
}
|
||||
|
||||
// NOTE: Not Scene context aware!!
|
||||
inline bool operator== (Entity& other) {
|
||||
return m_entity == other.m_entity;// && other.m_scene == m_scene;
|
||||
}
|
||||
|
||||
inline bool isValid() {
|
||||
if (m_scene == nullptr)
|
||||
return false;
|
||||
|
||||
return m_scene->m_registry.valid(m_entity);
|
||||
bool operator== (Entity& other) {
|
||||
return m_entity == other.m_entity;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -4,11 +4,6 @@
|
||||
using namespace entt;
|
||||
|
||||
namespace YoggieEngine{
|
||||
|
||||
Scene::Scene(const std::string& name): name(name)
|
||||
{
|
||||
}
|
||||
|
||||
Scene::Scene()
|
||||
{
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ namespace YoggieEngine {
|
||||
class Scene
|
||||
{
|
||||
public:
|
||||
Scene(const std::string& name );
|
||||
Scene();
|
||||
~Scene();
|
||||
|
||||
@ -16,7 +15,6 @@ namespace YoggieEngine {
|
||||
void Stop();
|
||||
|
||||
entt::registry& getReg() { return m_registry; }
|
||||
std::string name;
|
||||
|
||||
private:
|
||||
entt::registry m_registry;
|
||||
|
@ -6,7 +6,7 @@ incfolder["assimp"] = "%{wks.location}/libs/assimp/include"
|
||||
incfolder["glm"] = "%{wks.location}/libs/glm"
|
||||
incfolder["entt"] = "%{wks.location}/libs/entt/src"
|
||||
incfolder["yamlcpp"] = "%{wks.location}/libs/yaml-cpp/include"
|
||||
incfolder["mINI"] = "%{wks.location}/libs/mINI/src"
|
||||
|
||||
-- Graphics
|
||||
incfolder["glad"] = "%{wks.location}/libs/glad/include"
|
||||
incfolder["glfw"] = "%{wks.location}/libs/glfw/include"
|
||||
|
@ -1 +0,0 @@
|
||||
Subproject commit cfccc2aab651cb19cbc2c3ad36be78c36078ec76
|
@ -1 +0,0 @@
|
||||
Subproject commit a1ff72e8898db8b53282e9eb7c7ec5973519787e
|
Loading…
x
Reference in New Issue
Block a user