Big clean up, getting ready for new AssetManagement
* Removing Old EventSystem * Removing Assets from Editor project * Clean up of EditorLayer.h * Moving primitives of renderer out of their subfolder
This commit is contained in:
		@ -6,7 +6,6 @@ buildmessage "Building editor ..."
 | 
			
		||||
links{
 | 
			
		||||
  "YoggieEngine",
 | 
			
		||||
  "ImGuizmo",
 | 
			
		||||
  "yaml-cpp",
 | 
			
		||||
  "nfd"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								Editor/rsc/Yoggie2.jpeg
									 (Stored with Git LFS)
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Editor/rsc/Yoggie2.jpeg
									 (Stored with Git LFS)
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							@ -1,56 +0,0 @@
 | 
			
		||||
#pragma once
 | 
			
		||||
#include "../../YoggieEngine/src/YoggieEngine.h"
 | 
			
		||||
#include <filesystem>
 | 
			
		||||
#include <string>
 | 
			
		||||
#include "uuid.h"
 | 
			
		||||
 | 
			
		||||
enum class ASSET_TYPE {
 | 
			
		||||
	Unknown = -1,
 | 
			
		||||
	Mesh,
 | 
			
		||||
	Texture,
 | 
			
		||||
	Material,
 | 
			
		||||
	Shader,
 | 
			
		||||
	Model,
 | 
			
		||||
	File
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
class Asset {
 | 
			
		||||
public:
 | 
			
		||||
	Asset(const char* name):  name(name) {}
 | 
			
		||||
 | 
			
		||||
	virtual ASSET_TYPE GetType() { return detectAssetType(); }
 | 
			
		||||
	
 | 
			
		||||
	const char* GetName() const { return name.c_str(); }
 | 
			
		||||
	void setName(std::string& name) { name = name.c_str(); }
 | 
			
		||||
	void setFilPath(std::string& path) { file = std::filesystem::path(path); }
 | 
			
		||||
 | 
			
		||||
	std::string getId() { return Id.String(); }
 | 
			
		||||
 | 
			
		||||
	
 | 
			
		||||
protected:
 | 
			
		||||
	uuid::v4::UUID Id = uuid::v4::UUID::New();
 | 
			
		||||
 | 
			
		||||
	std::string name;
 | 
			
		||||
	std::filesystem::path file;
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	ASSET_TYPE detectAssetType() {
 | 
			
		||||
		auto ext = (file.extension()).string();
 | 
			
		||||
		if (ext == ".obj" || ext == ".gltf" || ext == ".fbx" || ext == ".stl") {
 | 
			
		||||
			return ASSET_TYPE::Model;
 | 
			
		||||
		}
 | 
			
		||||
		else if (ext == ".yproj") {
 | 
			
		||||
			return ASSET_TYPE::File;
 | 
			
		||||
		}
 | 
			
		||||
		else if (ext == ".vs" || ext == ".fs") {
 | 
			
		||||
			return ASSET_TYPE::File;
 | 
			
		||||
		}
 | 
			
		||||
		else {
 | 
			
		||||
			spdlog::warn("unknown file!");
 | 
			
		||||
			return ASSET_TYPE::Unknown;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
};
 | 
			
		||||
@ -1,105 +0,0 @@
 | 
			
		||||
#pragma once
 | 
			
		||||
#include "../../YoggieEngine/src/YoggieEngine.h"
 | 
			
		||||
#include "../EditorWindow.h"
 | 
			
		||||
#include "AssetRegistry.h"
 | 
			
		||||
 | 
			
		||||
const char* hidden_extensions [] {
 | 
			
		||||
    ".exe",
 | 
			
		||||
    ".pdb",
 | 
			
		||||
    ".idb",
 | 
			
		||||
    ".dll",
 | 
			
		||||
    ".ini"
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
class AssetFinder : public EditorWindow {
 | 
			
		||||
public:
 | 
			
		||||
    AssetFinder () : EditorWindow("Assets") {}
 | 
			
		||||
    AssetFinder(const std::filesystem::path& projectdirectory) : EditorWindow("Assets")
 | 
			
		||||
    {
 | 
			
		||||
        assetIcon = YoggieEngine::Texture("rsc/AssetIcon.png");
 | 
			
		||||
 | 
			
		||||
        spdlog::info("asset iconID: {0}", assetIcon.GetID());
 | 
			
		||||
 | 
			
		||||
        for (auto& dir_entry : std::filesystem::directory_iterator(projectdirectory)) {
 | 
			
		||||
            auto filepath = dir_entry.path();
 | 
			
		||||
 | 
			
		||||
            if (dir_entry.is_directory() || dir_entry.is_symlink() || dir_entry.is_socket())
 | 
			
		||||
                continue;
 | 
			
		||||
 | 
			
		||||
            bool has_hidden_extension = false;
 | 
			
		||||
            for (auto hide : hidden_extensions) {
 | 
			
		||||
                if (filepath.extension() == hide)
 | 
			
		||||
                {
 | 
			
		||||
                    has_hidden_extension = true;
 | 
			
		||||
                    break;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (has_hidden_extension)
 | 
			
		||||
                continue;
 | 
			
		||||
 | 
			
		||||
            Asset asset(filepath.filename().string().c_str());
 | 
			
		||||
 | 
			
		||||
            auto filepathStr = filepath.string();
 | 
			
		||||
            asset.setFilPath(filepathStr);
 | 
			
		||||
            spdlog::info("Created asset: {0}", asset.GetName());
 | 
			
		||||
            files.push_back(asset);
 | 
			
		||||
 | 
			
		||||
        
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void Draw() override {
 | 
			
		||||
 | 
			
		||||
        ImGui::DragInt("IconSize", &iconSize, 1, 30, 90);
 | 
			
		||||
        ImGui::DragInt("Maximum Columns", &maxColumns, 1, 1, 6);
 | 
			
		||||
        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));
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            
 | 
			
		||||
            int row = 0;
 | 
			
		||||
            int column = 0;
 | 
			
		||||
            for (auto& asset : files ) {
 | 
			
		||||
                if (column % 3 == 0) {
 | 
			
		||||
                    ImGui::TableNextRow();
 | 
			
		||||
                    column = 0;
 | 
			
		||||
                    row++;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                ImGui::TableSetColumnIndex(column);
 | 
			
		||||
 | 
			
		||||
                ImGui::ImageButton(
 | 
			
		||||
                    (ImTextureID)assetIcon.GetID(),
 | 
			
		||||
                    ImVec2{ (float)iconSize, (float)iconSize });
 | 
			
		||||
                ImGui::Text(asset.GetName(), row);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                column++;
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
 | 
			
		||||
            
 | 
			
		||||
            ImGui::PopStyleColor(3);
 | 
			
		||||
            ImGui::EndTable();
 | 
			
		||||
            
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    std::vector <Asset> files = std::vector<Asset>();
 | 
			
		||||
 | 
			
		||||
    int iconSize = 60;
 | 
			
		||||
    int maxColumns = 3;
 | 
			
		||||
 | 
			
		||||
    YoggieEngine::Texture folderIcon;
 | 
			
		||||
    YoggieEngine::Texture assetIcon;
 | 
			
		||||
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@ -1,9 +0,0 @@
 | 
			
		||||
#pragma once
 | 
			
		||||
#include <filesystem>
 | 
			
		||||
#include "../Asset.h"
 | 
			
		||||
class AssetLoader {
 | 
			
		||||
public:
 | 
			
		||||
	virtual Asset LoadAsset(std::filesystem::path& path) = 0;
 | 
			
		||||
	// virtual void PackageAsset(Asset& asset ) = 0; 
 | 
			
		||||
 | 
			
		||||
};
 | 
			
		||||
@ -1,109 +0,0 @@
 | 
			
		||||
#include "ModelLoader.h"
 | 
			
		||||
#include <assimp/Importer.hpp>
 | 
			
		||||
#include <assimp/postprocess.h>
 | 
			
		||||
#include <assimp/scene.h>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void ProcessVertices(aiMesh* mesh, std::vector<YoggieEngine::Vertex>& out_vertices) {
 | 
			
		||||
	for (unsigned int i = 0; i < mesh->mNumVertices; i++) {
 | 
			
		||||
		YoggieEngine::Vertex v{};
 | 
			
		||||
 | 
			
		||||
		glm::vec3 vector;
 | 
			
		||||
		vector.x = mesh->mVertices[i].x;
 | 
			
		||||
		vector.y = mesh->mVertices[i].y;
 | 
			
		||||
		vector.z = mesh->mVertices[i].z;
 | 
			
		||||
 | 
			
		||||
		v.vertices = vector;
 | 
			
		||||
 | 
			
		||||
		if (mesh->mTextureCoords[0]) {
 | 
			
		||||
			glm::vec2 texCoord;
 | 
			
		||||
 | 
			
		||||
			texCoord.x = mesh->mTextureCoords[0][i].x;
 | 
			
		||||
			texCoord.y = mesh->mTextureCoords[0][i].y;
 | 
			
		||||
 | 
			
		||||
			v.uv = texCoord;
 | 
			
		||||
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		out_vertices.push_back(v);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void ProcessIndices(aiMesh* mesh, std::vector<unsigned int>& out_indices) {
 | 
			
		||||
	for (unsigned int i = 0; i < mesh->mNumFaces; i++) {
 | 
			
		||||
		aiFace face = mesh->mFaces[i];
 | 
			
		||||
		if (face.mNumIndices < 3)
 | 
			
		||||
			continue;
 | 
			
		||||
		for (unsigned int j = 0; j < face.mNumIndices; j++) {
 | 
			
		||||
			out_indices.push_back(face.mIndices[j]);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
YoggieEngine::Mesh processMesh(aiMesh* mesh, const aiScene* scene) {
 | 
			
		||||
	std::vector<unsigned int> indices;
 | 
			
		||||
	std::vector<YoggieEngine::Vertex> vertices;
 | 
			
		||||
 | 
			
		||||
	ProcessVertices(mesh, vertices);
 | 
			
		||||
	ProcessIndices(mesh, indices);
 | 
			
		||||
 | 
			
		||||
	YoggieEngine::Mesh result;
 | 
			
		||||
	result.vertices = vertices;
 | 
			
		||||
	result.elements = indices;
 | 
			
		||||
 | 
			
		||||
	return result;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
std::vector<YoggieEngine::Mesh> processNode(aiNode* node, const aiScene* scene) {
 | 
			
		||||
 | 
			
		||||
	std::vector<YoggieEngine::Mesh> meshes = std::vector<YoggieEngine::Mesh>();
 | 
			
		||||
 | 
			
		||||
	for (unsigned int i = 0; i < node->mNumMeshes; i++) {
 | 
			
		||||
		aiMesh* mesh = scene->mMeshes[node->mMeshes[i]];
 | 
			
		||||
		meshes.push_back(processMesh(mesh, scene));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	for (unsigned int i = 0; i < node->mNumChildren; i++) {
 | 
			
		||||
		auto m2 = processNode(node->mChildren[i], scene);
 | 
			
		||||
 | 
			
		||||
		for (auto m : m2) {
 | 
			
		||||
			meshes.push_back(m);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return meshes;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
Asset ModelLoader::LoadAsset(std::filesystem::path& path) {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	Assimp::Importer importer;
 | 
			
		||||
 | 
			
		||||
	const aiScene* scene = importer.ReadFile(path.string(), aiProcess_Triangulate | aiProcess_FlipUVs);
 | 
			
		||||
 | 
			
		||||
	aiNode* currentNode = scene->mRootNode;
 | 
			
		||||
 | 
			
		||||
	
 | 
			
		||||
	spdlog::info("Loading meshes!" );
 | 
			
		||||
 | 
			
		||||
	auto meshes = processNode(currentNode, scene);
 | 
			
		||||
 | 
			
		||||
	spdlog::info("Model file contained {0} meshes", meshes.size() );
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	return Asset("Mesh");
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@ -1,8 +0,0 @@
 | 
			
		||||
#pragma once
 | 
			
		||||
#include "AssetLoader.h"
 | 
			
		||||
 | 
			
		||||
class  ModelLoader : AssetLoader {
 | 
			
		||||
public:
 | 
			
		||||
	Asset LoadAsset(std::filesystem::path& path);
 | 
			
		||||
 | 
			
		||||
};
 | 
			
		||||
@ -1,140 +0,0 @@
 | 
			
		||||
#include "AssetRegistry.h"
 | 
			
		||||
 | 
			
		||||
#include <iostream>
 | 
			
		||||
#include <fstream>
 | 
			
		||||
#include <spdlog/spdlog.h>
 | 
			
		||||
/*
 | 
			
		||||
* this is still a very naive approach to the asset manager
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
AssetRegistry::AssetRegistry() 
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void AssetRegistry::RegisterAsset(Asset& asset) 
 | 
			
		||||
{
 | 
			
		||||
	Assets.try_emplace(asset.getId() , asset);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void AssetRegistry::UnregisterAsset(Asset& asset) {
 | 
			
		||||
	Assets.erase(asset.getId());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
YoggieEngine::Mesh* AssetRegistry::LoadFromAssetFile(const std::filesystem::path assetPath)
 | 
			
		||||
{
 | 
			
		||||
	YoggieEngine::Mesh* imported = nullptr;
 | 
			
		||||
 | 
			
		||||
	std::ifstream AssetFile;
 | 
			
		||||
	AssetFile.open(assetPath, std::ios::binary);
 | 
			
		||||
	if (AssetFile.is_open()) {
 | 
			
		||||
 | 
			
		||||
		char* Header = (char*)malloc(8);
 | 
			
		||||
		unsigned long long  Vsize = 0;
 | 
			
		||||
		uint32_t Vnum = 0;
 | 
			
		||||
		uint32_t Enum = 0;
 | 
			
		||||
 | 
			
		||||
		// Read header 
 | 
			
		||||
		AssetFile.read(Header, 8);
 | 
			
		||||
		AssetFile.read((char*)&Vsize, sizeof(unsigned long long));
 | 
			
		||||
		AssetFile.read((char*)&Vnum, sizeof(uint32_t));
 | 
			
		||||
		AssetFile.read((char*)&Enum, sizeof(uint32_t));
 | 
			
		||||
 | 
			
		||||
		// print Header info 
 | 
			
		||||
		spdlog::info("File has header: {0}", Header);
 | 
			
		||||
		spdlog::info ( "Vertex size: {0}", Vsize );
 | 
			
		||||
		spdlog::info("Number of Vertices: {0}" ,Vnum );
 | 
			
		||||
		spdlog::info ("Number of Elements: " , Enum );
 | 
			
		||||
		free(Header);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		imported = new YoggieEngine::Mesh();
 | 
			
		||||
		// Load Vertices (Vertex + UV )
 | 
			
		||||
		imported->vertices = std::vector < YoggieEngine::Vertex>();
 | 
			
		||||
		for (int i = 0; i < Vnum; i++)
 | 
			
		||||
		{
 | 
			
		||||
			YoggieEngine::Vertex data = YoggieEngine::Vertex();
 | 
			
		||||
			AssetFile.read((char*)&data, Vsize);
 | 
			
		||||
 | 
			
		||||
			imported->vertices.push_back(data);
 | 
			
		||||
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// skip x bytes 
 | 
			
		||||
		AssetFile.ignore(sizeof(char) * 3);
 | 
			
		||||
 | 
			
		||||
		// Load Elements
 | 
			
		||||
		imported->elements = std::vector<unsigned int>();
 | 
			
		||||
		for (int i = 0; i < Enum; i++) {
 | 
			
		||||
			unsigned int data = 0;
 | 
			
		||||
			AssetFile.read((char*)&data, sizeof(unsigned int));
 | 
			
		||||
			imported->elements.push_back(data);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
	else {
 | 
			
		||||
		spdlog::error( "Failed ot open mesh " );
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return imported;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
/*
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
YoggieEngine::Renderable* AssetRegistry::LoadFromSource(const std::filesystem::path srcPath, const std::filesystem::path assetFolder)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
	* 	auto model = (YoggieEngine::ModelImporter()).Import(srcPath.string());
 | 
			
		||||
	YoggieEngine::Mesh* exportMesh = model->renderable->mesh;
 | 
			
		||||
	std::filesystem::path MeshFileName = assetFolder / srcPath.filename().replace_extension(".mesh");
 | 
			
		||||
	spdlog::info( "Save path: {0}" , MeshFileName );
 | 
			
		||||
 | 
			
		||||
	std::ofstream meshAsset;
 | 
			
		||||
	meshAsset.open(MeshFileName, std::ios::binary);
 | 
			
		||||
	if (meshAsset.is_open()) {
 | 
			
		||||
 | 
			
		||||
		// write a header
 | 
			
		||||
		static const char* HEADER = "MESH";
 | 
			
		||||
		meshAsset.write(HEADER, sizeof(HEADER));
 | 
			
		||||
		auto Vsize = sizeof(YoggieEngine::Vertex);
 | 
			
		||||
		spdlog::info( "size of vertex: {0}" ,Vsize );
 | 
			
		||||
		spdlog::info("Addr of vSize: {0}" , &Vsize );
 | 
			
		||||
		auto Vnum = exportMesh->vertices.size();
 | 
			
		||||
		auto Enum = exportMesh->elements.size();
 | 
			
		||||
 | 
			
		||||
		meshAsset.write((char*)&Vsize, sizeof(unsigned long long));
 | 
			
		||||
		meshAsset.write((char*)&Vnum, sizeof(uint32_t));
 | 
			
		||||
		meshAsset.write((char*)&Enum, sizeof(uint32_t));
 | 
			
		||||
		// write all vertices 
 | 
			
		||||
		for (auto& vertice : exportMesh->vertices)
 | 
			
		||||
		{
 | 
			
		||||
			meshAsset.write((char*)&vertice, sizeof(vertice));
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// write 3 x 0 byte
 | 
			
		||||
		meshAsset.write((const char*)"\0\0\0", sizeof(char) * 3);
 | 
			
		||||
 | 
			
		||||
		// write all indices 
 | 
			
		||||
		for (auto index : exportMesh->elements) {
 | 
			
		||||
			meshAsset.write((char*)&index, sizeof(index));
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		meshAsset.close();
 | 
			
		||||
	}
 | 
			
		||||
	else {
 | 
			
		||||
 | 
			
		||||
		spdlog::error("Failed to create/open mesh file.");
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return model->renderable;
 | 
			
		||||
 | 
			
		||||
	return nullptr;
 | 
			
		||||
}
 | 
			
		||||
	*/
 | 
			
		||||
@ -1,26 +0,0 @@
 | 
			
		||||
#pragma once
 | 
			
		||||
#include <vector>
 | 
			
		||||
#include "Asset.h"
 | 
			
		||||
#include "uuid.h"
 | 
			
		||||
 | 
			
		||||
class AssetRegistry {
 | 
			
		||||
public:
 | 
			
		||||
 | 
			
		||||
	AssetRegistry();
 | 
			
		||||
	//AssetRegistry(AssetPack);
 | 
			
		||||
 | 
			
		||||
	void RegisterAsset(Asset& asset);
 | 
			
		||||
	void UnregisterAsset(Asset& asset);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	void Update();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	static YoggieEngine::Mesh* LoadFromAssetFile(const std::filesystem::path assetPath);
 | 
			
		||||
//	static YoggieEngine::Renderable* LoadFromSource(const std::filesystem::path srcPath, const std::filesystem::path assetFolder);
 | 
			
		||||
	
 | 
			
		||||
private: 
 | 
			
		||||
	int unique_number = 0;
 | 
			
		||||
	std::map<std::string , Asset> Assets = std::map<std::string, Asset> ();
 | 
			
		||||
};
 | 
			
		||||
@ -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)
 | 
			
		||||
{
 | 
			
		||||
	spdlog::info( "Writing Scene file to: {0}" , path.u8string());
 | 
			
		||||
	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>());
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@ -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);
 | 
			
		||||
@ -1,63 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
* 
 | 
			
		||||
* SOURCE: https://github.com/rkg82/uuid-v4/blob/main/uuid/v4/uuid.h
 | 
			
		||||
*
 | 
			
		||||
*/
 | 
			
		||||
#ifndef __UUID__
 | 
			
		||||
#define __UUID__
 | 
			
		||||
 | 
			
		||||
#include <random>
 | 
			
		||||
#include <string>
 | 
			
		||||
 | 
			
		||||
namespace uuid::v4
 | 
			
		||||
{
 | 
			
		||||
    // Encaasulate the genaeration of a Version 4 UUID object
 | 
			
		||||
    // A Version 4 UUID is a universally unique identifier that is generated using random numbers.
 | 
			
		||||
    class UUID
 | 
			
		||||
    {
 | 
			
		||||
    public:
 | 
			
		||||
        // Factory method for creating UUID object.
 | 
			
		||||
        static UUID New()
 | 
			
		||||
        {
 | 
			
		||||
            UUID uuid;
 | 
			
		||||
            std::random_device rd;
 | 
			
		||||
            std::mt19937 engine{ rd() };
 | 
			
		||||
            std::uniform_int_distribution<int> dist{ 0, 256 }; //Limits of the interval
 | 
			
		||||
 | 
			
		||||
            for (int index = 0; index < 16; ++index)
 | 
			
		||||
            {
 | 
			
		||||
                uuid._data[index] = (unsigned char)dist(engine);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            uuid._data[6] = ((uuid._data[6] & 0x0f) | 0x40); // Version 4
 | 
			
		||||
            uuid._data[8] = ((uuid._data[8] & 0x3f) | 0x80); // Variant is 10
 | 
			
		||||
 | 
			
		||||
            return uuid;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Returns UUID as formatted string
 | 
			
		||||
        std::string String()
 | 
			
		||||
        {
 | 
			
		||||
            // Formats to "0065e7d7-418c-4da4-b4d6-b54b6cf7466a"
 | 
			
		||||
            char buffer[256] = { 0 };
 | 
			
		||||
            std::snprintf(buffer, 255,
 | 
			
		||||
                "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
 | 
			
		||||
                _data[0], _data[1], _data[2], _data[3],
 | 
			
		||||
                _data[4], _data[5],
 | 
			
		||||
                _data[6], _data[7],
 | 
			
		||||
                _data[8], _data[9],
 | 
			
		||||
                _data[10], _data[11], _data[12], _data[13], _data[14], _data[15]);
 | 
			
		||||
 | 
			
		||||
            std::string uuid = buffer;
 | 
			
		||||
 | 
			
		||||
            return uuid;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    private:
 | 
			
		||||
        UUID() {}
 | 
			
		||||
 | 
			
		||||
        unsigned char _data[16] = { 0 };
 | 
			
		||||
    };
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif // #ifndef __UUID__
 | 
			
		||||
@ -1,31 +1,16 @@
 | 
			
		||||
#pragma once
 | 
			
		||||
#include <iostream>
 | 
			
		||||
#include <mini/ini.h>
 | 
			
		||||
#include <glm/glm.hpp>
 | 
			
		||||
#include <glm/gtc/type_ptr.hpp>
 | 
			
		||||
#include <glm/gtc/matrix_transform.hpp>
 | 
			
		||||
#include <nfd.h>
 | 
			
		||||
 | 
			
		||||
#include "AssetManagement/SceneSerializer.h"
 | 
			
		||||
#include "AssetManagement/AssetFinder.h"
 | 
			
		||||
#include "PropertyPanels/Inspector.h"
 | 
			
		||||
#include "AssetManagement/uuid.h"
 | 
			
		||||
#include "Project/Settings.h"
 | 
			
		||||
#include "Console.h"
 | 
			
		||||
#include "AssetManagement/AssetLoaders/ModelLoader.h"
 | 
			
		||||
#include "IconsMaterialDesign.h"
 | 
			
		||||
#include "Project/Project.h"
 | 
			
		||||
#include <ImGuizmo.h>
 | 
			
		||||
#include "EditorCamera.h"
 | 
			
		||||
#include "../../YoggieEngine/src/Graphics/Memory/VertexArray.h"
 | 
			
		||||
#include "../../YoggieEngine/src/Graphics/Memory/Buffer.h"
 | 
			
		||||
 | 
			
		||||
#include "Inspector.h"
 | 
			
		||||
#include "Console.h"
 | 
			
		||||
#include "IconsMaterialDesign.h"
 | 
			
		||||
#include "Project.h"
 | 
			
		||||
#include "EditorCamera.h"
 | 
			
		||||
using namespace YoggieEngine;
 | 
			
		||||
 | 
			
		||||
const float movement_speed = 0.1f;
 | 
			
		||||
static float lastX = 400, lastY = 300;
 | 
			
		||||
const float sensitivity = 0.1;
 | 
			
		||||
static bool firstMouse = true;
 | 
			
		||||
 | 
			
		||||
class EditorLayer : public Layer {
 | 
			
		||||
 | 
			
		||||
@ -33,129 +18,31 @@ class EditorLayer : public Layer {
 | 
			
		||||
public:
 | 
			
		||||
    EditorLayer() : 
 | 
			
		||||
        Layer(),
 | 
			
		||||
        Logo("rsc/Yoggie.png"),
 | 
			
		||||
        inspector(Selected),
 | 
			
		||||
        scene(),
 | 
			
		||||
        renderer()
 | 
			
		||||
    {
 | 
			
		||||
        
 | 
			
		||||
        spdlog::info("Colour attachment id: {0}", renderer.getCurrentFrameBuffer().GetColourAttachment());
 | 
			
		||||
 | 
			
		||||
        Selected = YoggieEngine::Entity((entt::entity)-1, &scene);
 | 
			
		||||
 | 
			
		||||
        AssetRegistry assetManager = AssetRegistry();
 | 
			
		||||
       // ModelLoader modelLoader = ModelLoader();
 | 
			
		||||
 | 
			
		||||
        Logo.Load("rsc/Yoggie.png");
 | 
			
		||||
        spdlog::info("{0}", project.GetProjectDirectory().string());
 | 
			
		||||
 | 
			
		||||
        //auto latern = modelLoader.LoadAsset(std::filesystem::path("build/debug/Models/Latern.gltf"));
 | 
			
		||||
        //spdlog::info("Loaded mesh: {0}", latern.GetName());
 | 
			
		||||
 | 
			
		||||
        Selected = YoggieEngine::Entity((entt::entity)-1, &scene);
 | 
			
		||||
        
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
	void OnStartup() override {
 | 
			
		||||
        std::string path = (std::filesystem::current_path()).string();
 | 
			
		||||
        project.setProjectDirectory(path);
 | 
			
		||||
        assetsView = AssetFinder(project.GetProjectDirectory());
 | 
			
		||||
        LoadLastOrEmptyProject();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        auto cubePath = std::filesystem::path("build/debug/Models/cube.obj");
 | 
			
		||||
 | 
			
		||||
        cube = (ModelLoader()).LoadAsset(cubePath);
 | 
			
		||||
        //Settings settings = Settings();
 | 
			
		||||
        //Console console = Console();
 | 
			
		||||
       
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	void OnUpdate() override {
 | 
			
		||||
        scene.Update();
 | 
			
		||||
 | 
			
		||||
        auto components = scene.getReg().view<Render3DComponent>();
 | 
			
		||||
        for(auto component : components){
 | 
			
		||||
            auto& renderComponent = YoggieEngine::Entity(component, &scene).GetComponent<Render3DComponent>();
 | 
			
		||||
 | 
			
		||||
            renderComponent.mesh = cube;
 | 
			
		||||
 | 
			
		||||
            if (renderComponent.VAO == 0 || renderComponent.IBO == 0) {
 | 
			
		||||
                VertexArray va = VertexArray();
 | 
			
		||||
                Buffer vertexBuffer = Buffer();
 | 
			
		||||
                Buffer elementBuffer = Buffer();
 | 
			
		||||
 | 
			
		||||
                va.Create();
 | 
			
		||||
                va.Bind();
 | 
			
		||||
 | 
			
		||||
                vertexBuffer.createBuffer();
 | 
			
		||||
                vertexBuffer.Bind(false);
 | 
			
		||||
                vertexBuffer.setBufferData((void*)&renderComponent.mesh.vertices[0], renderComponent.mesh.vertices.size() * sizeof(Vertex), false);
 | 
			
		||||
 | 
			
		||||
                elementBuffer.createBuffer();
 | 
			
		||||
                elementBuffer.Bind(true);
 | 
			
		||||
                elementBuffer.setBufferData((void*)&renderComponent.mesh.elements[0], renderComponent.mesh.elements.size() * sizeof(unsigned int), true);
 | 
			
		||||
 | 
			
		||||
                va.AttachAttribute(0, 3, sizeof(Vertex));
 | 
			
		||||
 | 
			
		||||
                glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)0);
 | 
			
		||||
                glEnableVertexAttribArray(0);
 | 
			
		||||
                glEnableVertexAttribArray(1);
 | 
			
		||||
 | 
			
		||||
                va.Unbind();
 | 
			
		||||
                vertexBuffer.Unbind(false);
 | 
			
		||||
                elementBuffer.Unbind(true);
 | 
			
		||||
 | 
			
		||||
                renderComponent.VAO = va.getID();
 | 
			
		||||
                renderComponent.IBO = elementBuffer.getBufferID();
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
      
 | 
			
		||||
        renderer.Render(scene, *camera);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
    bool OnKey(int key, int mode) override {
 | 
			
		||||
       
 | 
			
		||||
        if (SceneisFocused) {
 | 
			
		||||
            if (key == YOGGIE_KEY_UP)
 | 
			
		||||
                camera->Rotation.x += movement_speed;
 | 
			
		||||
 | 
			
		||||
            if (key == YOGGIE_KEY_DOWN)
 | 
			
		||||
                camera->Rotation.x -= movement_speed;
 | 
			
		||||
 | 
			
		||||
            if (key == YOGGIE_KEY_LEFT)
 | 
			
		||||
                camera->Rotation.y += movement_speed;
 | 
			
		||||
 | 
			
		||||
            if (key == YOGGIE_KEY_RIGHT)
 | 
			
		||||
                camera->Rotation.y -= movement_speed;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            if (key == YOGGIE_KEY_A)
 | 
			
		||||
                camera->Position += glm::vec3(1.0f, 0.0f, 0.0f) * movement_speed;
 | 
			
		||||
 | 
			
		||||
            if (key == YOGGIE_KEY_S)
 | 
			
		||||
                camera->Position += glm::vec3(0.0f, 0.0f, -1.0f) * movement_speed;
 | 
			
		||||
 | 
			
		||||
            if (key == YOGGIE_KEY_D)
 | 
			
		||||
                camera->Position -= glm::vec3(1.0f, 0.0f, 0.0f) * movement_speed;
 | 
			
		||||
 | 
			
		||||
            if (key == GLFW_KEY_W)
 | 
			
		||||
                camera->Position -= glm::vec3(0.0f, 0.0f, -1.0f) * movement_speed;
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    ImGuizmo::OPERATION activeOperation = ImGuizmo::OPERATION::TRANSLATE;
 | 
			
		||||
 | 
			
		||||
    void OnUI() override {
 | 
			
		||||
        ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, { ImGui::GetWindowWidth(), 7 });
 | 
			
		||||
@ -272,15 +159,6 @@ public:
 | 
			
		||||
                switch (result) {
 | 
			
		||||
                case(NFD_OKAY):
 | 
			
		||||
                {
 | 
			
		||||
                    YoggieEngine::Mesh* importedMesh = AssetRegistry::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;
 | 
			
		||||
 | 
			
		||||
@ -307,13 +185,6 @@ public:
 | 
			
		||||
 | 
			
		||||
        ImGui::SameLine(ImGui::GetWindowWidth() - 120);
 | 
			
		||||
       
 | 
			
		||||
        /*
 | 
			
		||||
        ImGui::PopStyleColor();
 | 
			
		||||
        ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.1f, 0.1f, 0.1f, 0.01f));
 | 
			
		||||
        if (ImGui::Button(ICON_MD_MINIMIZE)) { spdlog::info("Minimize"); }
 | 
			
		||||
        if (ImGui::Button(ICON_MD_MAXIMIZE)) { spdlog::info("Maximize"); }
 | 
			
		||||
        if (ImGui::Button(ICON_MD_CLOSE)) { spdlog::info("Quit"); }
 | 
			
		||||
        */
 | 
			
		||||
        ImGui::PopStyleColor(1);
 | 
			
		||||
        ImGui::PopStyleVar();
 | 
			
		||||
 | 
			
		||||
@ -412,7 +283,7 @@ public:
 | 
			
		||||
       // spdlog::info("{0}x{1}", ImGui::GetWindowWidth(), ImGui::GetWindowHeight());
 | 
			
		||||
        SceneisFocused = ImGui::IsWindowFocused() || ImGui::IsWindowHovered();
 | 
			
		||||
        ImGui::Image((ImTextureID)(intptr_t)renderer.getCurrentFrameBuffer().GetColourAttachment(),
 | 
			
		||||
            ImVec2{(float)ImGui::GetWindowWidth(),(float)ImGui::GetWindowHeight()},ImVec2{1,1}, ImVec2{0,0});
 | 
			
		||||
            ImVec2{(float)ImGui::GetWindowWidth(),(float)ImGui::GetWindowHeight()});
 | 
			
		||||
 | 
			
		||||
       
 | 
			
		||||
       
 | 
			
		||||
@ -472,14 +343,74 @@ public:
 | 
			
		||||
 | 
			
		||||
        ImGui::End();
 | 
			
		||||
 | 
			
		||||
        inspector.Update();
 | 
			
		||||
        /*
 | 
			
		||||
        {
 | 
			
		||||
            ImGui::Begin("Asset", nullptr);
 | 
			
		||||
 | 
			
		||||
            const char* hidden_extensions[]{
 | 
			
		||||
        ".exe",
 | 
			
		||||
        ".pdb",
 | 
			
		||||
        ".idb",
 | 
			
		||||
        ".dll",
 | 
			
		||||
        ".ini"
 | 
			
		||||
            };
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        //settings.Update();
 | 
			
		||||
        //console.Update();
 | 
			
		||||
            std::vector <Asset> files = std::vector<Asset>();
 | 
			
		||||
 | 
			
		||||
        assetsView.Update();
 | 
			
		||||
            int iconSize = 60;
 | 
			
		||||
            int maxColumns = 3;
 | 
			
		||||
 | 
			
		||||
            YoggieEngine::Texture folderIcon;
 | 
			
		||||
            YoggieEngine::Texture assetIcon;
 | 
			
		||||
 | 
			
		||||
            assetIcon = YoggieEngine::Texture("rsc/AssetIcon.png");
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            ImGui::DragInt("IconSize", &iconSize, 1, 30, 90);
 | 
			
		||||
            ImGui::DragInt("Max. Columns", &maxColumns, 1, 1, 6);
 | 
			
		||||
 | 
			
		||||
            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));
 | 
			
		||||
 | 
			
		||||
                int row = 0;
 | 
			
		||||
                int column = 0;
 | 
			
		||||
                for (auto& asset : files) {
 | 
			
		||||
                    if (column % 3 == 0) {
 | 
			
		||||
                        ImGui::TableNextRow();
 | 
			
		||||
                        column = 0;
 | 
			
		||||
                        row++;
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                    ImGui::TableSetColumnIndex(column);
 | 
			
		||||
 | 
			
		||||
                    ImGui::ImageButton(
 | 
			
		||||
                        (ImTextureID)assetIcon.GetID(),
 | 
			
		||||
                        ImVec2{ (float)iconSize, (float)iconSize });
 | 
			
		||||
                    ImGui::Text(asset.GetName(), row);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                    column++;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                ImGui::PopStyleColor(3);
 | 
			
		||||
                ImGui::EndTable();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            ImGui::End();
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
        */
 | 
			
		||||
       
 | 
			
		||||
        
 | 
			
		||||
        ImGui::ShowDemoWindow();
 | 
			
		||||
        //ImGui::ShowMetricsWindow();
 | 
			
		||||
    }
 | 
			
		||||
@ -496,23 +427,64 @@ public:
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    bool OnKey(int key, int mode) override {
 | 
			
		||||
        float movement_speed = 0.10f;
 | 
			
		||||
 | 
			
		||||
        if (SceneisFocused) {
 | 
			
		||||
            if (key == YOGGIE_KEY_UP)
 | 
			
		||||
                camera->Rotation.x += movement_speed;
 | 
			
		||||
 | 
			
		||||
            if (key == YOGGIE_KEY_DOWN)
 | 
			
		||||
                camera->Rotation.x -= movement_speed;
 | 
			
		||||
 | 
			
		||||
            if (key == YOGGIE_KEY_LEFT)
 | 
			
		||||
                camera->Rotation.y += movement_speed;
 | 
			
		||||
 | 
			
		||||
            if (key == YOGGIE_KEY_RIGHT)
 | 
			
		||||
                camera->Rotation.y -= movement_speed;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            if (key == YOGGIE_KEY_A)
 | 
			
		||||
                camera->Position += glm::vec3(1.0f, 0.0f, 0.0f) * movement_speed;
 | 
			
		||||
 | 
			
		||||
            if (key == YOGGIE_KEY_S)
 | 
			
		||||
                camera->Position += glm::vec3(0.0f, 0.0f, -1.0f) * movement_speed;
 | 
			
		||||
 | 
			
		||||
            if (key == YOGGIE_KEY_D)
 | 
			
		||||
                camera->Position -= glm::vec3(1.0f, 0.0f, 0.0f) * movement_speed;
 | 
			
		||||
 | 
			
		||||
            if (key == GLFW_KEY_W)
 | 
			
		||||
                camera->Position -= glm::vec3(0.0f, 0.0f, -1.0f) * movement_speed;
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    Inspector inspector;
 | 
			
		||||
    AssetFinder assetsView;
 | 
			
		||||
    Renderer renderer;
 | 
			
		||||
 | 
			
		||||
    EditorCamera* camera = new EditorCamera();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    bool SimulatePhysics = true;
 | 
			
		||||
    YoggieEngine::Entity  Selected;
 | 
			
		||||
    Project project;
 | 
			
		||||
    Scene scene;
 | 
			
		||||
    char* path = nullptr;
 | 
			
		||||
    Texture Logo;
 | 
			
		||||
    Renderer renderer;
 | 
			
		||||
    EditorCamera* camera = new EditorCamera();
 | 
			
		||||
    Mesh cube ;
 | 
			
		||||
 | 
			
		||||
    bool SimulatePhysics = true;
 | 
			
		||||
    bool SceneisFocused = false;
 | 
			
		||||
 | 
			
		||||
    YoggieEngine::Entity  Selected;
 | 
			
		||||
    ImGuizmo::OPERATION activeOperation = ImGuizmo::OPERATION::TRANSLATE;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    char* path = nullptr;
 | 
			
		||||
    Texture Logo;
 | 
			
		||||
    
 | 
			
		||||
    void LoadLastOrEmptyProject() {
 | 
			
		||||
        // Check if there is a last known loaded project and 
 | 
			
		||||
       // load that one .
 | 
			
		||||
@ -536,7 +508,7 @@ private:
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
            Project::LoadProject(ini["cache"]["project"], project);
 | 
			
		||||
            LoadScene(ini["cache"]["scene"], scene);
 | 
			
		||||
            ///LoadScene(ini["cache"]["scene"], scene);
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
 | 
			
		||||
@ -1,6 +1,6 @@
 | 
			
		||||
#include "Inspector.h"
 | 
			
		||||
#include "../TransformVec3.h"
 | 
			
		||||
#include "../IconsMaterialDesign.h"
 | 
			
		||||
#include "TransformVec3.h"
 | 
			
		||||
#include "IconsMaterialDesign.h"
 | 
			
		||||
 | 
			
		||||
void Inspector::Draw() 
 | 
			
		||||
{
 | 
			
		||||
@ -1,6 +1,6 @@
 | 
			
		||||
#pragma once
 | 
			
		||||
#include "../../YoggieEngine/src/YoggieEngine.h"
 | 
			
		||||
#include "../EditorWindow.h"
 | 
			
		||||
#include "EditorWindow.h"
 | 
			
		||||
 | 
			
		||||
typedef void (*voidFunction) (void);
 | 
			
		||||
 | 
			
		||||
@ -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);
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@ -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)"
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
};
 | 
			
		||||
@ -12,7 +12,6 @@ public:
 | 
			
		||||
    void Run() override
 | 
			
		||||
    {
 | 
			
		||||
        PushLayer(new EditorLayer());
 | 
			
		||||
 | 
			
		||||
        Application::Run();
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user