diff --git a/Deer/Include/Deer/DataStore.h b/Deer/Include/Deer/DataStore.h index 94a2beb..7420946 100755 --- a/Deer/Include/Deer/DataStore.h +++ b/Deer/Include/Deer/DataStore.h @@ -13,7 +13,7 @@ #define DEER_VOXEL_ASPECT_PATH "voxels/aspect" #define DEER_VOXEL_TEXTURE_PATH "voxels/textures" #define DEER_VOXEL_SHADER_PATH "voxels/shaders" -#define DEER_EDITOR_PATH "editor" +#define DEER_EDITOR_PATH "Editor" #define DEER_MESH_PATH "meshes" #define DEER_MESH_EXTENSION ".dmesh" diff --git a/Deer/Include/DeerRender/Components.h b/Deer/Include/DeerRender/Components.h index 02e1409..1a767d7 100755 --- a/Deer/Include/DeerRender/Components.h +++ b/Deer/Include/DeerRender/Components.h @@ -78,27 +78,16 @@ namespace Deer { uint16_t shaderId; }; - struct TextureBindingComponent { - TextureBindingComponent() { - for (int x = 0; x < MAX_TEXTURE_BINDINGS; x++) { - textureAssetID[x] = 0; - textureBindID[x] = 0; - } - } - TextureBindingComponent(const TextureBindingComponent&) = default; - - uint32_t textureAssetID[MAX_TEXTURE_BINDINGS]; - unsigned char textureBindID[MAX_TEXTURE_BINDINGS]; - }; - struct CameraComponent { CameraComponent() = default; CameraComponent(const CameraComponent&) = default; - CameraComponent(float _fov, float _aspect, float _nearZ, float _farZ) : fov(_fov), aspect(_aspect), nearZ(_nearZ), farZ(_farZ) { } + + float fov = glm::radians(50.0f); + float aspect = 16 / 9; + float nearZ = 0.1f; + float farZ = 1000; inline glm::mat4 getMatrix() const { return glm::perspective(fov, aspect, nearZ, farZ); } - - float fov = glm::radians(50.0f), aspect = 16 / 9, nearZ = 0.1f, farZ = 1000; }; } \ No newline at end of file diff --git a/Deer/src/Deer/Scene/Entity.cpp b/Deer/src/Deer/Scene/Entity.cpp index 8f34bdd..d0f8e85 100755 --- a/Deer/src/Deer/Scene/Entity.cpp +++ b/Deer/src/Deer/Scene/Entity.cpp @@ -63,11 +63,6 @@ namespace Deer { if (m_environment->m_registry.any_of(m_entityHandle)) creation.addComponent( getComponent()); - - if (m_environment->m_registry.any_of( - m_entityHandle)) - creation.addComponent( - getComponent()); #endif return creation; } diff --git a/Deer/src/Deer/Scene/Serialization/EntitySerialization.h b/Deer/src/Deer/Scene/Serialization/EntitySerialization.h index f587eaf..5d4ba9d 100755 --- a/Deer/src/Deer/Scene/Serialization/EntitySerialization.h +++ b/Deer/src/Deer/Scene/Serialization/EntitySerialization.h @@ -52,8 +52,6 @@ namespace Deer { archive, "meshRenderComponent", entity); saveComponent(archive, "cameraComponent", entity); - saveComponent( - archive, "textureBindingComponent", entity); } #endif saveComponent(archive, "scriptComponent", @@ -80,8 +78,6 @@ namespace Deer { archive, "meshRenderComponent", entity); loadComponent(archive, "cameraComponent", entity); - loadComponent( - archive, "textureBindingComponent", entity); } #endif loadComponent(archive, "scriptComponent", diff --git a/Deer/src/DeerRender/Scene/Serialization/Components/TextureBindingSerializationComponent.h b/Deer/src/DeerRender/Scene/Serialization/Components/TextureBindingSerializationComponent.h index d2cd09d..788cec1 100755 --- a/Deer/src/DeerRender/Scene/Serialization/Components/TextureBindingSerializationComponent.h +++ b/Deer/src/DeerRender/Scene/Serialization/Components/TextureBindingSerializationComponent.h @@ -22,49 +22,4 @@ namespace Deer { archive(cereal::make_nvp("bindingID", textureBinding.bindingID)); } - template - void load(Archive& archive, - TextureBindingComponent& textureBinding) { - std::vector bindings; - - // TO IMPLEMENT - /* - - archive(cereal::make_nvp("bindings", bindings)); - - int id = 0; - for (auto& binding : bindings) { - if (id >= MAX_TEXTURE_BINDINGS) - break; - - textureBinding.textureAssetID[id] = AssetManager::loadAsset( - std::filesystem::path(binding.texturePath)); - textureBinding.textureBindID[id] = binding.bindingID; - } - - */ - } - - template - void save(Archive& archive, - TextureBindingComponent const& textureBinding) { - std::vector bindings; - - // TO IMPLEMENT - /* - for (int x = 0; x < MAX_TEXTURE_BINDINGS; x++) { - if (textureBinding.textureAssetID[x] != 0) { - bindings.push_back(TextureBinding( - AssetManager::getAssetLocation(textureBinding.textureAssetID[x]).generic_string(), - textureBinding.textureBindID[x] - )); - } - } - - std::sort(bindings.begin(), bindings.end(), [](TextureBinding& a, TextureBinding& b) { - return a.bindingID < b.bindingID; }); - - archive(cereal::make_nvp("bindings", bindings)); - */ - } } \ No newline at end of file diff --git a/DeerLSP/Build.lua b/DeerLSP/Build.lua new file mode 100755 index 0000000..ef9f51b --- /dev/null +++ b/DeerLSP/Build.lua @@ -0,0 +1,49 @@ +project "DeerLSP" + kind "ConsoleApp" + language "C++" + cppdialect "C++20" + targetdir "bin/%{cfg.buildcfg}" + staticruntime "off" + + debugdir "../Roe" + + files { "src/**.h", "src/**.cpp" } + + + includedirs + { + "src", + "include" + } + + + targetdir ("../bin/" .. OutputDir .. "/%{prj.name}") + objdir ("../bin/int/" .. OutputDir .. "/%{prj.name}") + + filter "system:linux" + toolset "clang" + defines { "LINUX" } + links { "GL", "glfw" } + links { "glad" } + buildoptions { "-std=c++20" } + + filter "system:windows" + systemversion "latest" + defines { "WINDOWS" } + + filter "configurations:Debug" + defines { "DEBUG" } + runtime "Debug" + symbols "On" + + filter "configurations:Release" + defines { "RELEASE" } + runtime "Release" + optimize "On" + symbols "On" + + filter "configurations:Dist" + defines { "DIST" } + runtime "Release" + optimize "On" + symbols "Off" diff --git a/DeerStudio/src/DeerStudio/Editor/Icons.cpp b/DeerStudio/src/DeerStudio/Editor/Icons.cpp index 83de5b4..5eb64d3 100755 --- a/DeerStudio/src/DeerStudio/Editor/Icons.cpp +++ b/DeerStudio/src/DeerStudio/Editor/Icons.cpp @@ -15,15 +15,15 @@ namespace Deer { Ref Icons::info_icon; void Icons::setupIcons() { - Icons::scene_icon = Texture2D::create(DataStore::rootPath / "editor/icons/scene.png"); - Icons::folder_icon = Texture2D::create(DataStore::rootPath / "editor/icons/folder.png"); - Icons::add_icon = Texture2D::create(DataStore::rootPath / "editor/icons/add.png"); - Icons::substract_icon = Texture2D::create(DataStore::rootPath / "editor/icons/substract.png"); - Icons::fill_icon = Texture2D::create(DataStore::rootPath / "editor/icons/fill.png"); - Icons::fill_empty_icon = Texture2D::create(DataStore::rootPath / "editor/icons/fill_empty.png"); - Icons::box_select_icon = Texture2D::create(DataStore::rootPath / "editor/icons/box_select.png"); - Icons::face_voxel_selection_icon = Texture2D::create(DataStore::rootPath / "editor/icons/face_voxel_selection.png"); - Icons::internal_voxel_selection_icon = Texture2D::create(DataStore::rootPath / "editor/icons/internal_voxel_selection.png"); - Icons::info_icon = Texture2D::create(DataStore::rootPath / "editor/icons/info.png"); + Icons::scene_icon = Texture2D::create(DataStore::rootPath / "Editor/icons/scene.png"); + Icons::folder_icon = Texture2D::create(DataStore::rootPath / "Editor/icons/folder.png"); + Icons::add_icon = Texture2D::create(DataStore::rootPath / "Editor/icons/add.png"); + Icons::substract_icon = Texture2D::create(DataStore::rootPath / "Editor/icons/substract.png"); + Icons::fill_icon = Texture2D::create(DataStore::rootPath / "Editor/icons/fill.png"); + Icons::fill_empty_icon = Texture2D::create(DataStore::rootPath / "Editor/icons/fill_empty.png"); + Icons::box_select_icon = Texture2D::create(DataStore::rootPath / "Editor/icons/box_select.png"); + Icons::face_voxel_selection_icon = Texture2D::create(DataStore::rootPath / "Editor/icons/face_voxel_selection.png"); + Icons::internal_voxel_selection_icon = Texture2D::create(DataStore::rootPath / "Editor/icons/internal_voxel_selection.png"); + Icons::info_icon = Texture2D::create(DataStore::rootPath / "Editor/icons/info.png"); } } diff --git a/DeerStudio/src/DeerStudio/EditorEngine/API/Entity.h b/DeerStudio/src/DeerStudio/EditorEngine/API/Entity.h index b03851f..d346887 100644 --- a/DeerStudio/src/DeerStudio/EditorEngine/API/Entity.h +++ b/DeerStudio/src/DeerStudio/EditorEngine/API/Entity.h @@ -27,7 +27,7 @@ namespace Deer { // // bool == //} - struct EntityStruct : EntityRefStruct { + struct EntityStruct : EntityHandleStruct { EntityStruct(uint16_t entId = 0) { entityId = entId; } std::string getName(); @@ -39,33 +39,40 @@ namespace Deer { bool isRoot(); void destroy(); - EntityRefStruct createChild(std::string&); + EntityHandleStruct createChild(std::string&); - void setParent(EntityRefStruct parent); - EntityRefStruct getParent(); + void setParent(EntityHandleStruct parent); + EntityHandleStruct getParent(); - bool isDescendantOf(EntityRefStruct parent); - bool opEquals(const EntityRefStruct& other); + bool isDescendantOf(EntityHandleStruct parent); + bool opEquals(const EntityHandleStruct& other); //COMPONENTS - EntityRefStruct getMeshComponent(); + EntityHandleStruct getMeshComponent(); + EntityHandleStruct createMeshComponent(); bool hasMeshComponent(); void removeMeshComponent(); - EntityRefStruct getShaderComponent(); + EntityHandleStruct getShaderComponent(); + EntityHandleStruct createShaderComponent(); bool hasShaderComponent(); void removeShaderComponent(); + EntityHandleStruct getCameraComponent(); + EntityHandleStruct createCameraComponent(); + bool hasCameraComponent(); + void removeCameraComponent(); + // This function can be adapted to get a specific transform since the data is the same - EntityRefStruct getSelf(); + EntityHandleStruct getSelf(); }; - struct EntityChildArrayStruct : EntityRefStruct { + struct EntityChildArrayStruct : EntityHandleStruct { int getChildCount(); - EntityRefStruct getChild(int); + EntityHandleStruct getChild(int); }; - struct TransformComponentStruct : EntityRefStruct { + struct TransformComponentStruct : EntityHandleStruct { glm::vec3 getPosition(); glm::vec3 getScale(); glm::vec3 getRotation(); @@ -75,7 +82,7 @@ namespace Deer { void setRotation(glm::vec3); }; - struct MeshComponentStruct : EntityRefStruct { + struct MeshComponentStruct : EntityHandleStruct { bool isActive(); void setActive(bool); @@ -88,7 +95,7 @@ namespace Deer { bool assertMeshComponent(const char* funcName); }; - struct ShaderComponentStruct : EntityRefStruct { + struct ShaderComponentStruct : EntityHandleStruct { bool hasShader(); void clear(); @@ -98,7 +105,21 @@ namespace Deer { bool assertShaderComponent(const char* funcName); }; - EntityRefStruct getRoot(); + struct CameraComponentStruct : EntityHandleStruct { + float getFov(); + float getAspectRation(); + float getNearZ(); + float getFarZ(); + + void setFov(float); + void setAspectRation(float); + void setNearZ(float); + void setFarZ(float); + + bool assertCameraComponent(const char* funcName); + }; + + EntityHandleStruct getRoot(); void constructEntityStruct(int id, void* memory); void copyEntityStruct(int id, void* memory); diff --git a/DeerStudio/src/DeerStudio/EditorEngine/API/Environment.h b/DeerStudio/src/DeerStudio/EditorEngine/API/Environment.h index 978c2ba..dedf701 100644 --- a/DeerStudio/src/DeerStudio/EditorEngine/API/Environment.h +++ b/DeerStudio/src/DeerStudio/EditorEngine/API/Environment.h @@ -4,16 +4,16 @@ namespace Deer { namespace EditorEngine { - struct EnvironmentStruct : EnvironmentRefStruct { - void render(EntityRefStruct cameraEntity, FrameBufferRefStruct); + struct EnvironmentStruct : EnvironmentHandleStruct { + void render(EntityHandleStruct cameraEntity, FrameBufferHandleStruct); - EntityRefStruct getRootEntity(); - EntityRefStruct getEntity(int); + EntityHandleStruct getRootEntity(); + EntityHandleStruct getEntity(int); }; - EnvironmentRefStruct getMainEnvironment(); + EnvironmentHandleStruct getMainEnvironment(); - EnvironmentRefStruct createEnvironment(std::string&); - EnvironmentRefStruct getEnvironment(std::string&); + EnvironmentHandleStruct createEnvironment(std::string&); + EnvironmentHandleStruct getEnvironment(std::string&); } } \ No newline at end of file diff --git a/DeerStudio/src/DeerStudio/EditorEngine/API/FrameBuffer.h b/DeerStudio/src/DeerStudio/EditorEngine/API/FrameBuffer.h index 31db95b..af2f9a0 100644 --- a/DeerStudio/src/DeerStudio/EditorEngine/API/FrameBuffer.h +++ b/DeerStudio/src/DeerStudio/EditorEngine/API/FrameBuffer.h @@ -1,10 +1,11 @@ #pragma once +#include "DeerStudio/EditorEngine/API/GenericRefStructs.h" #include #include namespace Deer { namespace EditorEngine { - struct FrameBufferStruct : FrameBufferRefStruct{ + struct FrameBufferStruct : FrameBufferHandleStruct{ FrameBufferStruct(uint16_t _id) { frameBufferId = _id; } int getWidth(); diff --git a/DeerStudio/src/DeerStudio/EditorEngine/API/GenericRefStructs.h b/DeerStudio/src/DeerStudio/EditorEngine/API/GenericRefStructs.h index 7e39a9d..2d396f3 100644 --- a/DeerStudio/src/DeerStudio/EditorEngine/API/GenericRefStructs.h +++ b/DeerStudio/src/DeerStudio/EditorEngine/API/GenericRefStructs.h @@ -3,7 +3,7 @@ namespace Deer { namespace EditorEngine { - struct EntityRefStruct { + struct EntityHandleStruct { uint16_t entityId; uint16_t environmentId; @@ -11,11 +11,11 @@ namespace Deer { bool assertEntity(const char* funcName); }; - struct EnvironmentRefStruct { + struct EnvironmentHandleStruct { uint16_t environmentId; }; - struct FrameBufferRefStruct { + struct FrameBufferHandleStruct { uint16_t frameBufferId; }; } diff --git a/DeerStudio/src/DeerStudio/EditorEngine/API/Layout.h b/DeerStudio/src/DeerStudio/EditorEngine/API/Layout.h index 0f46906..01c7305 100644 --- a/DeerStudio/src/DeerStudio/EditorEngine/API/Layout.h +++ b/DeerStudio/src/DeerStudio/EditorEngine/API/Layout.h @@ -17,6 +17,8 @@ namespace Deer { // Renders a component node bool componentNode(std::string&, CScriptAny*, asIScriptFunction*); + // Renders a component node with option to menu + bool componentNode_contextMenu(std::string&, CScriptAny*, asIScriptFunction*, asIScriptFunction*); // Renders a tree leaf void treeNode(std::string&, bool); // Renders a tree node with its sub nodes diff --git a/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/Entity.cpp b/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/Entity.cpp index a6a5e75..5fa3536 100644 --- a/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/Entity.cpp +++ b/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/Entity.cpp @@ -1,21 +1,26 @@ #include "DeerStudio/EditorEngine/API/Entity.h" -#include "Deer/Enviroment.h" -#include "DeerStudio/EditorEngine.h" #include "DeerStudio/EditorEngine/DockPanelObject.h" +#include "DeerStudio/EditorEngine.h" + +#include "DeerRender/Components.h" + +#include "Deer/Enviroment.h" #include "Deer/Scene.h" #define GET_ENTITY(id) Scene::environment.getEntity(id) #define GET_MESH_COMPONENT(id) Scene::environment.getEntity(id).getComponent() #define GET_SHADER_COMPONENT(id) Scene::environment.getEntity(id).getComponent() +#define GET_CAMERA_COMPONENT(id) Scene::environment.getEntity(id).getComponent() #define ASSERT_ENTITY(func, ret) if (!assertEntity(func)) ret; #define ASSERT_MESH_COMPONENT(func, ret) if (!assertMeshComponent(func)) ret; #define ASSERT_SHADER_COMPONENT(func, ret) if (!assertShaderComponent(func)) ret; +#define ASSERT_CAMERA_COMPONENT(func, ret) if (!assertCameraComponent(func)) ret; namespace Deer { namespace EditorEngine { - EntityRefStruct getRoot() { + EntityHandleStruct getRoot() { return EntityStruct(0); } @@ -27,7 +32,7 @@ namespace Deer { return entityId; } - bool EntityRefStruct::assertEntity(const char* funcName) { + bool EntityHandleStruct::assertEntity(const char* funcName) { if (!Scene::environment.entityExists(entityId)) { DEER_UI_ENGINE_ERROR("Error, invalid entity calling {0}, entityId : {1}", funcName, entityId); if (currentDockPanelExecution) @@ -74,7 +79,7 @@ namespace Deer { .entityExists(entityId); } - void EntityStruct::setParent(EntityRefStruct parent_struct) { + void EntityStruct::setParent(EntityHandleStruct parent_struct) { ASSERT_ENTITY("setParent()", return); Entity& parent = GET_ENTITY(parent_struct.entityId); @@ -83,7 +88,7 @@ namespace Deer { .setParent(parent); } - EntityRefStruct EntityStruct::getParent() { + EntityHandleStruct EntityStruct::getParent() { ASSERT_ENTITY("getParent()", return *this); Entity& self = GET_ENTITY(entityId); @@ -93,7 +98,7 @@ namespace Deer { return EntityStruct(self.getParentId()); } - bool EntityStruct::isDescendantOf(EntityRefStruct parent_struct) { + bool EntityStruct::isDescendantOf(EntityHandleStruct parent_struct) { ASSERT_ENTITY("isDescendantOf()", return false); Entity& parent = GET_ENTITY(parent_struct.entityId); @@ -102,13 +107,13 @@ namespace Deer { .isDescendantOf(parent); } - bool EntityStruct::opEquals(const EntityRefStruct& other) { + bool EntityStruct::opEquals(const EntityHandleStruct& other) { ASSERT_ENTITY("opEquals()", return false); return entityId == other.entityId; } - EntityRefStruct EntityStruct::getSelf() { + EntityHandleStruct EntityStruct::getSelf() { ASSERT_ENTITY("getSelf()", return *this); return *this; @@ -177,7 +182,7 @@ namespace Deer { return true; } - EntityRefStruct EntityChildArrayStruct::getChild(int i) { + EntityHandleStruct EntityChildArrayStruct::getChild(int i) { ASSERT_ENTITY("getChild()", return *this); RelationshipComponent& rc = GET_ENTITY(entityId) @@ -194,7 +199,7 @@ namespace Deer { return EntityStruct(rc.getChildrenId(i)); } - EntityRefStruct EntityStruct::createChild(std::string& name) { + EntityHandleStruct EntityStruct::createChild(std::string& name) { ASSERT_ENTITY("createChild()", return *this); Entity& me = GET_ENTITY(entityId); @@ -207,11 +212,29 @@ namespace Deer { return EntityStruct(newEnt.getId()); } - EntityRefStruct EntityStruct::getMeshComponent() { + EntityHandleStruct EntityStruct::getMeshComponent() { ASSERT_ENTITY("getMeshComponent()", return *this); Entity& self = GET_ENTITY(entityId); + if (!self.hasComponent()) { + DEER_CORE_ERROR("Error, entity {0} with id {1} does not have MeshComponent", + GET_ENTITY(entityId).getComponent().tag.c_str(), + entityId + ); + + if (currentDockPanelExecution) + currentDockPanelExecution->invalidate(); + } + + return *this; + } + + EntityHandleStruct EntityStruct::createMeshComponent() { + ASSERT_ENTITY("createMeshComponent()", return *this); + + Entity& self = GET_ENTITY(entityId); + if (!self.hasComponent()) { self.addComponent(); } @@ -237,11 +260,77 @@ namespace Deer { } } - EntityRefStruct EntityStruct::getShaderComponent() { + EntityHandleStruct EntityStruct::getCameraComponent() { + ASSERT_ENTITY("getCameraComponent()", return *this); + + Entity& self = GET_ENTITY(entityId); + + if (!self.hasComponent()) { + DEER_CORE_ERROR("Error, entity {0} with id {1} does not have Camera Component", + GET_ENTITY(entityId).getComponent().tag.c_str(), + entityId + ); + + if (currentDockPanelExecution) + currentDockPanelExecution->invalidate(); + } + + return *this; + } + + EntityHandleStruct EntityStruct::createCameraComponent() { + ASSERT_ENTITY("createCameraComponent()", return *this); + + Entity& self = GET_ENTITY(entityId); + + if (!self.hasComponent()) { + self.addComponent(); + } + + return *this; + } + + bool EntityStruct::hasCameraComponent() { + ASSERT_ENTITY("hasCameraComponent()", return false); + + Entity& self = GET_ENTITY(entityId); + + return self.hasComponent(); + } + + void EntityStruct::removeCameraComponent() { + ASSERT_ENTITY("removeMeshComponent()", return); + + Entity& self = GET_ENTITY(entityId); + + if (self.hasComponent()) { + self.removeComponent(); + } + } + + EntityHandleStruct EntityStruct::getShaderComponent() { ASSERT_ENTITY("getShaderComponent()", return *this); Entity& self = GET_ENTITY(entityId); + if (!self.hasComponent()) { + DEER_CORE_ERROR("Error, entity {0} with id {1} does not have Shader Component", + GET_ENTITY(entityId).getComponent().tag.c_str(), + entityId + ); + + if (currentDockPanelExecution) + currentDockPanelExecution->invalidate(); + } + + return *this; + } + + EntityHandleStruct EntityStruct::createShaderComponent() { + ASSERT_ENTITY("createShaderComponent()", return *this); + + Entity& self = GET_ENTITY(entityId); + if (!self.hasComponent()) { self.addComponent(); } @@ -346,5 +435,71 @@ namespace Deer { GET_SHADER_COMPONENT(entityId).setShader(shaderId); } + + bool CameraComponentStruct::assertCameraComponent(const char* funcName) { + if (!assertEntity(funcName)) return false; + Entity& ent = Scene::environment.getEntity(entityId); + + if (!ent.hasComponent()) { + DEER_UI_ENGINE_ERROR("Error, calling CameraComponent.{0} entity {1} with id {2} has no CameraComponent", + funcName, + ent.getComponent().tag.c_str(), + entityId + ); + + if (currentDockPanelExecution) + currentDockPanelExecution->invalidate(); + return false; + } + + return true; + } + + float CameraComponentStruct::getFov() { + ASSERT_CAMERA_COMPONENT("getFov()", return 0); + + return GET_CAMERA_COMPONENT(entityId).fov / 3.141f * 180.0f; + } + + float CameraComponentStruct::getAspectRation() { + ASSERT_CAMERA_COMPONENT("getAspectRation()", return 0); + + return GET_CAMERA_COMPONENT(entityId).aspect; + } + + float CameraComponentStruct::getNearZ() { + ASSERT_CAMERA_COMPONENT("getNearZ()", return 0); + + return GET_CAMERA_COMPONENT(entityId).nearZ; + } + + float CameraComponentStruct::getFarZ() { + ASSERT_CAMERA_COMPONENT("getFarZ()", return 0); + + return GET_CAMERA_COMPONENT(entityId).farZ; + } + + void CameraComponentStruct::setFov(float v) { + ASSERT_CAMERA_COMPONENT("getFarZ()", return); + + GET_CAMERA_COMPONENT(entityId).fov = v * 3.141f / 180.0f; + } + void CameraComponentStruct::setAspectRation(float v) { + ASSERT_CAMERA_COMPONENT("setAspectRation()", return); + + GET_CAMERA_COMPONENT(entityId).aspect = v; + } + void CameraComponentStruct::setNearZ(float v) { + ASSERT_CAMERA_COMPONENT("setNearZ()", return); + + GET_CAMERA_COMPONENT(entityId).nearZ = v; + } + void CameraComponentStruct::setFarZ(float v) { + ASSERT_CAMERA_COMPONENT("setFarZ()", return); + + GET_CAMERA_COMPONENT(entityId).farZ = v; + } + + } } \ No newline at end of file diff --git a/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/Entity_Register.cpp b/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/Entity_Register.cpp index 611b55d..929e4bc 100644 --- a/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/Entity_Register.cpp +++ b/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/Entity_Register.cpp @@ -11,28 +11,33 @@ namespace Deer { void registerTransformComponentFunctions(); void registerMeshComponentFunction(); void registerShaderComponentFunctions(); + void registerComponentComponentFunctions(); void registerEntityStructs() { - AS_CHECK(scriptEngine->RegisterObjectType("Entity", sizeof(EntityRefStruct), - asOBJ_VALUE | asOBJ_POD | asGetTypeTraits() | asOBJ_APP_CLASS_ALLINTS)); + AS_CHECK(scriptEngine->RegisterObjectType("Entity", sizeof(EntityHandleStruct), + asOBJ_VALUE | asOBJ_POD | asGetTypeTraits() | asOBJ_APP_CLASS_ALLINTS)); - AS_CHECK(scriptEngine->RegisterObjectType("EntityChilds", sizeof(EntityRefStruct), - asOBJ_VALUE | asOBJ_POD | asGetTypeTraits() | asOBJ_APP_CLASS_ALLINTS)); + AS_CHECK(scriptEngine->RegisterObjectType("EntityChilds", sizeof(EntityHandleStruct), + asOBJ_VALUE | asOBJ_POD | asGetTypeTraits() | asOBJ_APP_CLASS_ALLINTS)); - AS_CHECK(scriptEngine->RegisterObjectType("TransformComponent", sizeof(EntityRefStruct), - asOBJ_VALUE | asOBJ_POD | asGetTypeTraits() | asOBJ_APP_CLASS_ALLINTS)); + AS_CHECK(scriptEngine->RegisterObjectType("TransformComponent", sizeof(EntityHandleStruct), + asOBJ_VALUE | asOBJ_POD | asGetTypeTraits() | asOBJ_APP_CLASS_ALLINTS)); - AS_CHECK(scriptEngine->RegisterObjectType("MeshComponent", sizeof(EntityRefStruct), - asOBJ_VALUE | asOBJ_POD | asGetTypeTraits() | asOBJ_APP_CLASS_ALLINTS)); + AS_CHECK(scriptEngine->RegisterObjectType("MeshComponent", sizeof(EntityHandleStruct), + asOBJ_VALUE | asOBJ_POD | asGetTypeTraits() | asOBJ_APP_CLASS_ALLINTS)); - AS_CHECK(scriptEngine->RegisterObjectType("ShaderComponent", sizeof(EntityRefStruct), - asOBJ_VALUE | asOBJ_POD | asGetTypeTraits() | asOBJ_APP_CLASS_ALLINTS)); + AS_CHECK(scriptEngine->RegisterObjectType("ShaderComponent", sizeof(EntityHandleStruct), + asOBJ_VALUE | asOBJ_POD | asGetTypeTraits() | asOBJ_APP_CLASS_ALLINTS)); + + AS_CHECK(scriptEngine->RegisterObjectType("CameraComponent", sizeof(EntityHandleStruct), + asOBJ_VALUE | asOBJ_POD | asGetTypeTraits() | asOBJ_APP_CLASS_ALLINTS)); } void registerEntityFunctions() { registerTransformComponentFunctions(); registerMeshComponentFunction(); registerShaderComponentFunctions(); + registerComponentComponentFunctions(); // ENTITY AS_CHECK(scriptEngine->RegisterObjectMethod( @@ -126,7 +131,6 @@ namespace Deer { asCALL_THISCALL )); - AS_CHECK(scriptEngine->RegisterObjectMethod( "Entity", "MeshComponent getMeshComponent()", @@ -134,6 +138,13 @@ namespace Deer { asCALL_THISCALL )); + AS_CHECK(scriptEngine->RegisterObjectMethod( + "Entity", + "MeshComponent createMeshComponent()", + asMETHOD(EntityStruct, createMeshComponent), + asCALL_THISCALL + )); + AS_CHECK(scriptEngine->RegisterObjectMethod( "Entity", "bool hasMeshComponent()", @@ -176,6 +187,13 @@ namespace Deer { asCALL_THISCALL )); + AS_CHECK(scriptEngine->RegisterObjectMethod( + "Entity", + "ShaderComponent createShaderComponent() ", + asMETHOD(EntityStruct, createShaderComponent), + asCALL_THISCALL + )); + AS_CHECK(scriptEngine->RegisterObjectMethod( "Entity", "bool hasShaderComponent() ", @@ -189,6 +207,34 @@ namespace Deer { asMETHOD(EntityStruct, removeShaderComponent), asCALL_THISCALL )); + + AS_CHECK(scriptEngine->RegisterObjectMethod( + "Entity", + "CameraComponent getCameraComponent() ", + asMETHOD(EntityStruct, getCameraComponent), + asCALL_THISCALL + )); + + AS_CHECK(scriptEngine->RegisterObjectMethod( + "Entity", + "CameraComponent createCameraComponent() ", + asMETHOD(EntityStruct, createCameraComponent), + asCALL_THISCALL + )); + + AS_CHECK(scriptEngine->RegisterObjectMethod( + "Entity", + "bool hasCameraComponent() ", + asMETHOD(EntityStruct, hasCameraComponent), + asCALL_THISCALL + )); + + AS_CHECK(scriptEngine->RegisterObjectMethod( + "Entity", + "void removeCameraComponent() ", + asMETHOD(EntityStruct, removeCameraComponent), + asCALL_THISCALL + )); } void registerMeshComponentFunction() { @@ -312,5 +358,56 @@ namespace Deer { )); } + void registerComponentComponentFunctions() { + AS_CHECK(scriptEngine->RegisterObjectMethod( + "CameraComponent", + "float get_fov() const property ", + asMETHOD(CameraComponentStruct, getFov), + asCALL_THISCALL + )); + AS_CHECK(scriptEngine->RegisterObjectMethod( + "CameraComponent", + "float get_aspectRatio() const property ", + asMETHOD(CameraComponentStruct, getAspectRation), + asCALL_THISCALL + )); + AS_CHECK(scriptEngine->RegisterObjectMethod( + "CameraComponent", + "float get_nearZ() const property ", + asMETHOD(CameraComponentStruct, getNearZ), + asCALL_THISCALL + )); + AS_CHECK(scriptEngine->RegisterObjectMethod( + "CameraComponent", + "float get_farZ() const property ", + asMETHOD(CameraComponentStruct, getFarZ), + asCALL_THISCALL + )); + + AS_CHECK(scriptEngine->RegisterObjectMethod( + "CameraComponent", + "void set_fov(float) property ", + asMETHOD(CameraComponentStruct, setFov), + asCALL_THISCALL + )); + AS_CHECK(scriptEngine->RegisterObjectMethod( + "CameraComponent", + "void set_aspectRatio(float) property ", + asMETHOD(CameraComponentStruct, setAspectRation), + asCALL_THISCALL + )); + AS_CHECK(scriptEngine->RegisterObjectMethod( + "CameraComponent", + "void set_nearZ(float) property ", + asMETHOD(CameraComponentStruct, setNearZ), + asCALL_THISCALL + )); + AS_CHECK(scriptEngine->RegisterObjectMethod( + "CameraComponent", + "void set_farZ(float) property ", + asMETHOD(CameraComponentStruct, setFarZ), + asCALL_THISCALL + )); + } } } \ No newline at end of file diff --git a/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/Environment.cpp b/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/Environment.cpp new file mode 100644 index 0000000..acdfa4a --- /dev/null +++ b/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/Environment.cpp @@ -0,0 +1,7 @@ +#include "DeerStudio/EditorEngine/API/Environment.h" + +namespace Deer { + namespace DeerEngine { + + } +} \ No newline at end of file diff --git a/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/Layout.cpp b/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/Layout.cpp index da86834..1ad0915 100644 --- a/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/Layout.cpp +++ b/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/Layout.cpp @@ -103,6 +103,63 @@ namespace Deer { return false; } + bool componentNode_contextMenu(std::string& txt, CScriptAny* data, asIScriptFunction* func, asIScriptFunction* menu) { + + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(4, 4)); + ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, 0)); + + ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags_SpanAvailWidth | + ImGuiTreeNodeFlags_Framed | + ImGuiTreeNodeFlags_AllowItemOverlap | + ImGuiTreeNodeFlags_FramePadding | + ImGuiTreeNodeFlags_DefaultOpen; + + if (ImGui::TreeNodeEx(txt.c_str(), flags)){ + ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(10, 10)); + if (ImGui::BeginPopupContextItem(txt.c_str())) { + if (scriptContext && scriptContext->PushState() == asSUCCESS) { + + AS_CHECK( scriptContext->Prepare(menu)); + + AS_CHECK(scriptContext->SetArgObject(0, data)); + + AS_CHECK(scriptContext->Execute()); + + scriptContext->PopState(); + } else { + ImGui::Text("Something failed"); + } + ImGui::EndPopup(); + } + ImGui::PopStyleVar(); + + ImGui::Dummy(ImVec2(0, 10)); + ImGui::PushID(txt.c_str()); + if (scriptContext && scriptContext->PushState() == asSUCCESS) { + + AS_CHECK( scriptContext->Prepare(func)); + + AS_CHECK(scriptContext->SetArgObject(0, data)); + + AS_CHECK(scriptContext->Execute()); + + scriptContext->PopState(); + } else { + ImGui::Text("Something failed"); + } + + ImGui::Dummy(ImVec2(0, 10)); + ImGui::PopID(); + ImGui::TreePop(); + + ImGui::PopStyleVar(2); + return true; + } + + ImGui::PopStyleVar(2); + return false; + } + void setupColumns(int i) { ImGui::Columns(i, nullptr, false); } diff --git a/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/UI.cpp b/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/UI.cpp index d1a3197..b5d30c5 100644 --- a/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/UI.cpp +++ b/DeerStudio/src/DeerStudio/EditorEngine/API_Implementation/UI.cpp @@ -289,8 +289,12 @@ namespace Deer { float tmp = value; bool value_changed = false; + ImGui::Columns(2, nullptr, false); + ImGui::Text("%s", txt.c_str()); ImGui::SameLine(); + + ImGui::NextColumn(); if (id == ImGui::GetID(txt.c_str())) { @@ -323,6 +327,8 @@ namespace Deer { ImGui::SetKeyboardFocusHere(0); } } + + ImGui::Columns(); if (value_changed) value = tmp; diff --git a/DeerStudio/src/DeerStudio/EditorEngine/RegisterFunctions.cpp b/DeerStudio/src/DeerStudio/EditorEngine/RegisterFunctions.cpp index 12103e6..5447dba 100644 --- a/DeerStudio/src/DeerStudio/EditorEngine/RegisterFunctions.cpp +++ b/DeerStudio/src/DeerStudio/EditorEngine/RegisterFunctions.cpp @@ -99,6 +99,12 @@ namespace Deer { asCALL_CDECL )); + AS_CHECK(scriptEngine->RegisterGlobalFunction( + "bool componentNode_contextMenu(const string& in, any@+, ReciverFunc@+, ReciverFunc@+)", + asFUNCTION(componentNode_contextMenu), + asCALL_CDECL + )); + AS_CHECK(scriptEngine->RegisterGlobalFunction( "void contextItemPopup(const string& in, any@+, ReciverFunc@+)", asFUNCTION(contextItemPopup), diff --git a/DeerStudio/src/DeerStudio/Fonts.cpp b/DeerStudio/src/DeerStudio/Fonts.cpp index 476dbe5..6df7093 100644 --- a/DeerStudio/src/DeerStudio/Fonts.cpp +++ b/DeerStudio/src/DeerStudio/Fonts.cpp @@ -11,7 +11,7 @@ namespace Deer { ImFontConfig cnfg; // cnfg.SizePixels = 26 - Path rfPath = DataStore::rootPath / "editor/fonts/Roboto-Regular.ttf"; + Path rfPath = DataStore::rootPath / "Editor/fonts/Roboto-Regular.ttf"; normalText = io.Fonts->AddFontFromFileTTF(rfPath.generic_string().c_str(), 18); titleText = diff --git a/premake5.lua b/premake5.lua index f2f2e18..8a6a256 100755 --- a/premake5.lua +++ b/premake5.lua @@ -21,10 +21,14 @@ include "Deer/vendor/imgui/Build.lua" include "Deer/vendor/angelScript/Build.lua" group "" +group "scripting" +include "DeerLSP/Build.lua" +group "" + -- group "Runtime" -- include "DeerRuntime/Build.lua" -- group "" group "Studio" include "DeerStudio/Build.lua" -group "" \ No newline at end of file +group "" diff --git a/roe/editor/properties/addComponentMenu.as b/roe/Editor/Properties/AddComponent.as similarity index 70% rename from roe/editor/properties/addComponentMenu.as rename to roe/Editor/Properties/AddComponent.as index 725fb37..ca752ee 100644 --- a/roe/editor/properties/addComponentMenu.as +++ b/roe/Editor/Properties/AddComponent.as @@ -18,7 +18,7 @@ void addComponentRendering(any@ data) { menuItemDisabled("Mesh Render Component"); } else { if (menuItem("Mesh Render Component")) { - entity.getMeshComponent(); + entity.createMeshComponent(); } } @@ -26,7 +26,15 @@ void addComponentRendering(any@ data) { menuItemDisabled("Shader Render Component"); } else { if (menuItem("Shader Render Component")) { - entity.getShaderComponent(); + entity.createShaderComponent(); + } + } + + if (entity.hasCameraComponent()) { + menuItemDisabled("Camera Component"); + } else { + if (menuItem("Camera Component")) { + entity.createCameraComponent(); } } } \ No newline at end of file diff --git a/roe/Editor/Properties/CameraProperties.as b/roe/Editor/Properties/CameraProperties.as new file mode 100644 index 0000000..95f8187 --- /dev/null +++ b/roe/Editor/Properties/CameraProperties.as @@ -0,0 +1,47 @@ +void renderCameraComponent(any@ data) { + Entity entity; + data.retrieve(entity); + + if (!entity.hasCameraComponent()) + return; + + CameraComponent cameraComponent = entity.getCameraComponent(); + + float fov = cameraComponent.fov; + float aspect = cameraComponent.aspectRatio; + float nearZ = cameraComponent.nearZ; + float farZ = cameraComponent.farZ; + + fov = magicSlider("Fov", fov, 0.1); + if (fov > 180) + fov = 180; + if (fov < 0) + fov = 0; + + aspect = magicSlider("Aspect Ratio", aspect, 0.1); + if (aspect < 0.1) + aspect = 0.1; + nearZ = magicSlider("Near Z", nearZ, 0.1); + if (nearZ < 0) + nearZ = 0; + farZ = magicSlider("Far Z", farZ, 0.1); + if (farZ < 0) + farZ = 0; + + if (nearZ > farZ) + farZ = nearZ; + + cameraComponent.fov = fov; + cameraComponent.aspectRatio = aspect; + cameraComponent.nearZ = nearZ; + cameraComponent.farZ = farZ; +} + +void removeCameraComponent(any@ entity) { + Entity ent; + entity.retrieve(ent); + + if (menuItem("Remove")) { + ent.removeCameraComponent(); + } +} \ No newline at end of file diff --git a/roe/Editor/Properties/MeshProperties.as b/roe/Editor/Properties/MeshProperties.as new file mode 100644 index 0000000..505ff1f --- /dev/null +++ b/roe/Editor/Properties/MeshProperties.as @@ -0,0 +1,63 @@ + +void renderMeshComponent(any@ data) { + Entity entity; + data.retrieve(entity); + + if (!entity.hasMeshComponent()) + return; + + MeshComponent meshComponent = entity.getMeshComponent(); + + if (meshComponent.hasMesh) { + drawIcon("object3d", 32); + } else { + drawIcon("empty", 32); + } + + dragDropTarget("MESH", any(meshComponent), setMeshComponentMesh); + + if (meshComponent.hasMesh) { + sameline(); + space(); + sameline(); + + titleCenterY(meshComponent.getMesh(), 32); + dragDropTarget("MESH", any(meshComponent), setMeshComponentMesh); + } + + space(20, 20); + + if (button("Clear")) { + meshComponent.clear(); + } + + sameline(); + space(10, 20); + sameline(); + + if (meshComponent.hasMesh) { + meshComponent.isActive = checkbox("Active", meshComponent.isActive); + } else { + checkboxDisabled("Active", meshComponent.isActive); + } +} + + +void setMeshComponentMesh(any@ meshComponent_data, any@ mesh_data){ + string mesh; + mesh_data.retrieve(mesh); + + MeshComponent meshComponent; + meshComponent_data.retrieve(meshComponent); + + meshComponent.setMesh(mesh); +} + +void removeMeshComponent(any@ entity) { + Entity ent; + entity.retrieve(ent); + + if (menuItem("Remove")) { + ent.removeMeshComponent(); + } +} \ No newline at end of file diff --git a/roe/editor/properties/properties_pannel.as b/roe/Editor/Properties/PropertiesPannel.as similarity index 76% rename from roe/editor/properties/properties_pannel.as rename to roe/Editor/Properties/PropertiesPannel.as index a3ceaa9..d455a82 100644 --- a/roe/editor/properties/properties_pannel.as +++ b/roe/Editor/Properties/PropertiesPannel.as @@ -30,12 +30,18 @@ class PropertiesPannel : DockPanel { componentNode("Transform Component", any(entity), renderTransformComponent); if (entity.hasMeshComponent()) { - componentNode("Mesh Component", any(entity), renderMeshComponent); + componentNode_contextMenu("Mesh Component", any(entity), renderMeshComponent, removeMeshComponent); } if (entity.hasShaderComponent()) { - componentNode("Shader Component", any(entity), renderShaderComponent); + componentNode_contextMenu("Shader Component", any(entity), renderShaderComponent, removeShaderComponent); } + + if (entity.hasCameraComponent()) { + componentNode_contextMenu("Camera Component", any(entity), renderCameraComponent, removeCameraComponent); + } + + space(); separator(); diff --git a/roe/Editor/Properties/ShaderProperties.as b/roe/Editor/Properties/ShaderProperties.as new file mode 100644 index 0000000..1ab6d8b --- /dev/null +++ b/roe/Editor/Properties/ShaderProperties.as @@ -0,0 +1,51 @@ + +void setShaderComponent(any@ shaderComponent_data, any@ shader_data) { + string shader; + shader_data.retrieve(shader); + + ShaderComponent shaderComponent; + shaderComponent_data.retrieve(shaderComponent); + + shaderComponent.setShader(shader); +} + +void renderShaderComponent(any@ data) { + Entity entity; + data.retrieve(entity); + + if (!entity.hasShaderComponent()) + return; + + ShaderComponent shaderComponent = entity.getShaderComponent(); + + if (shaderComponent.hasShader) { + drawIcon("shader", 32); + } else { + drawIcon("empty", 32); + } + dragDropTarget("SHADER", any(shaderComponent), setShaderComponent); + + if (shaderComponent.hasShader) { + sameline(); + space(); + sameline(); + + titleCenterY(shaderComponent.getShader(), 32); + dragDropTarget("SHADER", any(shaderComponent), setShaderComponent); + } + + space(20, 20); + + if (button("Clear")) { + shaderComponent.clear(); + } +} + +void removeShaderComponent(any@ entity) { + Entity ent; + entity.retrieve(ent); + + if (menuItem("Remove")) { + ent.removeShaderComponent(); + } +} diff --git a/roe/Editor/Properties/TransformProperties.as b/roe/Editor/Properties/TransformProperties.as new file mode 100644 index 0000000..7dcd8d1 --- /dev/null +++ b/roe/Editor/Properties/TransformProperties.as @@ -0,0 +1,13 @@ +void renderTransformComponent(any@ data) { + Entity entity; + data.retrieve(entity); + + TransformComponent transform = entity.transform; + vec3 position = transform.position; + vec3 scale = transform.scale; + vec3 rotation = transform.rotation; + + transform.position = magicSlider3("Posiiton", position, 0.1); + transform.scale = magicSlider3("Scale", scale, 0.1); + transform.rotation = magicSlider3("Rotation", rotation, 0.1); +} diff --git a/roe/editor/active_entity.as b/roe/Editor/active_entity.as similarity index 100% rename from roe/editor/active_entity.as rename to roe/Editor/active_entity.as diff --git a/roe/editor/fonts/OpenSans-VariableFont_wdth,wght.ttf b/roe/Editor/fonts/OpenSans-VariableFont_wdth,wght.ttf similarity index 100% rename from roe/editor/fonts/OpenSans-VariableFont_wdth,wght.ttf rename to roe/Editor/fonts/OpenSans-VariableFont_wdth,wght.ttf diff --git a/roe/editor/fonts/PixelifySans-Regular.ttf b/roe/Editor/fonts/PixelifySans-Regular.ttf similarity index 100% rename from roe/editor/fonts/PixelifySans-Regular.ttf rename to roe/Editor/fonts/PixelifySans-Regular.ttf diff --git a/roe/editor/fonts/Roboto-Regular.ttf b/roe/Editor/fonts/Roboto-Regular.ttf similarity index 100% rename from roe/editor/fonts/Roboto-Regular.ttf rename to roe/Editor/fonts/Roboto-Regular.ttf diff --git a/roe/editor/icons/add.png b/roe/Editor/icons/add.png similarity index 100% rename from roe/editor/icons/add.png rename to roe/Editor/icons/add.png diff --git a/roe/editor/icons/box_select.png b/roe/Editor/icons/box_select.png similarity index 100% rename from roe/editor/icons/box_select.png rename to roe/Editor/icons/box_select.png diff --git a/roe/editor/icons/empty.png b/roe/Editor/icons/empty.png similarity index 100% rename from roe/editor/icons/empty.png rename to roe/Editor/icons/empty.png diff --git a/roe/editor/icons/emptyIcon.png b/roe/Editor/icons/emptyIcon.png similarity index 100% rename from roe/editor/icons/emptyIcon.png rename to roe/Editor/icons/emptyIcon.png diff --git a/roe/editor/icons/face_voxel_selection.png b/roe/Editor/icons/face_voxel_selection.png similarity index 100% rename from roe/editor/icons/face_voxel_selection.png rename to roe/Editor/icons/face_voxel_selection.png diff --git a/roe/editor/icons/file.png b/roe/Editor/icons/file.png similarity index 100% rename from roe/editor/icons/file.png rename to roe/Editor/icons/file.png diff --git a/roe/editor/icons/fill.png b/roe/Editor/icons/fill.png similarity index 100% rename from roe/editor/icons/fill.png rename to roe/Editor/icons/fill.png diff --git a/roe/editor/icons/fill_empty.png b/roe/Editor/icons/fill_empty.png similarity index 100% rename from roe/editor/icons/fill_empty.png rename to roe/Editor/icons/fill_empty.png diff --git a/roe/editor/icons/folder.png b/roe/Editor/icons/folder.png similarity index 100% rename from roe/editor/icons/folder.png rename to roe/Editor/icons/folder.png diff --git a/roe/editor/icons/info.png b/roe/Editor/icons/info.png similarity index 100% rename from roe/editor/icons/info.png rename to roe/Editor/icons/info.png diff --git a/roe/editor/icons/internal_voxel_selection.png b/roe/Editor/icons/internal_voxel_selection.png similarity index 100% rename from roe/editor/icons/internal_voxel_selection.png rename to roe/Editor/icons/internal_voxel_selection.png diff --git a/roe/editor/icons/object.png b/roe/Editor/icons/object.png similarity index 100% rename from roe/editor/icons/object.png rename to roe/Editor/icons/object.png diff --git a/roe/editor/icons/object3d.png b/roe/Editor/icons/object3d.png similarity index 100% rename from roe/editor/icons/object3d.png rename to roe/Editor/icons/object3d.png diff --git a/roe/editor/icons/scene.png b/roe/Editor/icons/scene.png similarity index 100% rename from roe/editor/icons/scene.png rename to roe/Editor/icons/scene.png diff --git a/roe/editor/icons/shader.png b/roe/Editor/icons/shader.png similarity index 100% rename from roe/editor/icons/shader.png rename to roe/Editor/icons/shader.png diff --git a/roe/editor/icons/substract.png b/roe/Editor/icons/substract.png similarity index 100% rename from roe/editor/icons/substract.png rename to roe/Editor/icons/substract.png diff --git a/roe/editor/mesh_explorer.as b/roe/Editor/mesh_explorer.as similarity index 100% rename from roe/editor/mesh_explorer.as rename to roe/Editor/mesh_explorer.as diff --git a/roe/editor/rename_entity.as b/roe/Editor/rename_entity.as similarity index 100% rename from roe/editor/rename_entity.as rename to roe/Editor/rename_entity.as diff --git a/roe/editor/shader_explorer.as b/roe/Editor/shader_explorer.as similarity index 100% rename from roe/editor/shader_explorer.as rename to roe/Editor/shader_explorer.as diff --git a/roe/editor/tree_pannel.as b/roe/Editor/tree_pannel.as similarity index 100% rename from roe/editor/tree_pannel.as rename to roe/Editor/tree_pannel.as index 8d3741a..3a05591 100644 --- a/roe/editor/tree_pannel.as +++ b/roe/Editor/tree_pannel.as @@ -8,19 +8,6 @@ class TreePannel : DockPanel { modalPopup("Rename entity", renameEntity); } - void entityInteraction(Entity entity) { - any data = any(entity); - - dragDropSource("ENTITY", data, entity.name); - dragDropTarget("ENTITY", data, TransferFunc(this.entityDrop)); - contextItemPopup("POP_ENTITY_" + entity.id, data, ReciverFunc(this.entityContextMenu)); - - // We can't select the entity - if (isItemClicked(0)) { - activeEntity = entity; - } - } - void renderNode(any@ data) { Entity entity; data.retrieve(entity); @@ -56,6 +43,19 @@ class TreePannel : DockPanel { } } + void entityInteraction(Entity entity) { + any data = any(entity); + + dragDropSource("ENTITY", data, entity.name); + dragDropTarget("ENTITY", data, TransferFunc(this.entityDrop)); + contextItemPopup("POP_ENTITY_" + entity.id, data, ReciverFunc(this.entityContextMenu)); + + // We can't select the entity + if (isItemClicked(0)) { + activeEntity = entity; + } + } + void entityContextMenu(any@ data) { Entity entity; data.retrieve(entity); diff --git a/roe/editor/properties/components_render.as b/roe/editor/properties/components_render.as deleted file mode 100644 index 2360836..0000000 --- a/roe/editor/properties/components_render.as +++ /dev/null @@ -1,102 +0,0 @@ -void renderTransformComponent(any@ data) { - Entity entity; - data.retrieve(entity); - - TransformComponent transform = entity.transform; - vec3 position = transform.position; - vec3 scale = transform.scale; - vec3 rotation = transform.rotation; - - transform.position = magicSlider3("Posiiton", position, 0.1); - transform.scale = magicSlider3("Scale", scale, 0.1); - transform.rotation = magicSlider3("Rotation", rotation, 0.1); -} - -void renderMeshComponent(any@ data) { - Entity entity; - data.retrieve(entity); - - MeshComponent meshComponent = entity.getMeshComponent(); - - if (meshComponent.hasMesh) { - drawIcon("object3d", 32); - } else { - drawIcon("empty", 32); - } - - dragDropTarget("MESH", any(meshComponent), setMeshComponentMesh); - - if (meshComponent.hasMesh) { - sameline(); - space(); - sameline(); - - titleCenterY(meshComponent.getMesh(), 32); - dragDropTarget("MESH", any(meshComponent), setMeshComponentMesh); - } - - space(20, 20); - - if (button("Clear")) { - meshComponent.clear(); - } - - sameline(); - space(10, 20); - sameline(); - - if (meshComponent.hasMesh) { - meshComponent.isActive = checkbox("Active", meshComponent.isActive); - } else { - checkboxDisabled("Active", meshComponent.isActive); - } -} - -void renderShaderComponent(any@ data) { - Entity entity; - data.retrieve(entity); - - ShaderComponent shaderComponent = entity.getShaderComponent(); - - if (shaderComponent.hasShader) { - drawIcon("shader", 32); - } else { - drawIcon("empty", 32); - } - dragDropTarget("SHADER", any(shaderComponent), setShaderComponent); - - if (shaderComponent.hasShader) { - sameline(); - space(); - sameline(); - - titleCenterY(shaderComponent.getShader(), 32); - dragDropTarget("SHADER", any(shaderComponent), setShaderComponent); - } - - space(20, 20); - - if (button("Clear")) { - shaderComponent.clear(); - } -} - -void setMeshComponentMesh(any@ meshComponent_data, any@ mesh_data){ - string mesh; - mesh_data.retrieve(mesh); - - MeshComponent meshComponent; - meshComponent_data.retrieve(meshComponent); - - meshComponent.setMesh(mesh); -} - -void setShaderComponent(any@ shaderComponent_data, any@ shader_data) { - string shader; - shader_data.retrieve(shader); - - ShaderComponent shaderComponent; - shaderComponent_data.retrieve(shaderComponent); - - shaderComponent.setShader(shader); -} \ No newline at end of file diff --git a/roe/imgui.ini b/roe/imgui.ini index 63a45b2..d8a805c 100644 --- a/roe/imgui.ini +++ b/roe/imgui.ini @@ -15,8 +15,8 @@ Collapsed=0 DockId=0x00000004,1 [Window][Game Window] -Pos=365,24 -Size=504,503 +Pos=412,24 +Size=457,487 Collapsed=0 DockId=0x00000006,0 @@ -28,13 +28,13 @@ DockId=0x00000001,0 [Window][Terrain Editor] Pos=871,24 -Size=409,503 +Size=409,487 Collapsed=0 DockId=0x00000004,0 [Window][Viewport] -Pos=365,24 -Size=504,503 +Pos=412,24 +Size=457,487 Collapsed=0 DockId=0x00000006,1 @@ -57,14 +57,14 @@ Collapsed=0 DockId=0x00000008,1 [Window][MeshExplorer] -Pos=0,529 -Size=1280,191 +Pos=0,513 +Size=1280,207 Collapsed=0 DockId=0x00000008,0 [Window][TreePannel] Pos=0,24 -Size=363,503 +Size=410,487 Collapsed=0 DockId=0x00000005,0 @@ -80,7 +80,7 @@ Collapsed=0 [Window][PropertiesPannel] Pos=871,24 -Size=409,503 +Size=409,487 Collapsed=0 DockId=0x00000004,1 @@ -91,19 +91,19 @@ Collapsed=0 DockId=0x00000004,1 [Window][ShaderExplorer] -Pos=0,529 -Size=1280,191 +Pos=0,513 +Size=1280,207 Collapsed=0 DockId=0x00000008,1 [Docking][Data] DockSpace ID=0xA1672E74 Window=0x4647B76E Pos=0,24 Size=1280,696 Split=Y - DockNode ID=0x00000007 Parent=0xA1672E74 SizeRef=1280,503 Split=Y + DockNode ID=0x00000007 Parent=0xA1672E74 SizeRef=1280,487 Split=Y DockNode ID=0x00000001 Parent=0x00000007 SizeRef=2560,363 Split=X Selected=0x13926F0B DockNode ID=0x00000003 Parent=0x00000001 SizeRef=869,338 Split=X Selected=0x13926F0B - DockNode ID=0x00000005 Parent=0x00000003 SizeRef=363,446 Selected=0xE45B9F93 - DockNode ID=0x00000006 Parent=0x00000003 SizeRef=504,446 CentralNode=1 Selected=0x13926F0B + DockNode ID=0x00000005 Parent=0x00000003 SizeRef=410,446 Selected=0xE45B9F93 + DockNode ID=0x00000006 Parent=0x00000003 SizeRef=457,446 CentralNode=1 Selected=0x13926F0B DockNode ID=0x00000004 Parent=0x00000001 SizeRef=409,338 Selected=0x2A2C795E DockNode ID=0x00000002 Parent=0x00000007 SizeRef=2560,331 Selected=0xCF339702 - DockNode ID=0x00000008 Parent=0xA1672E74 SizeRef=1280,191 Selected=0xD962995A + DockNode ID=0x00000008 Parent=0xA1672E74 SizeRef=1280,207 Selected=0xD962995A