Working on Deer LSP

This commit is contained in:
Arnau Alier Torres 2025-05-11 03:39:50 +02:00
parent c5ca30dcfb
commit 84be4e6c9b
52 changed files with 693 additions and 267 deletions

View File

@ -13,7 +13,7 @@
#define DEER_VOXEL_ASPECT_PATH "voxels/aspect" #define DEER_VOXEL_ASPECT_PATH "voxels/aspect"
#define DEER_VOXEL_TEXTURE_PATH "voxels/textures" #define DEER_VOXEL_TEXTURE_PATH "voxels/textures"
#define DEER_VOXEL_SHADER_PATH "voxels/shaders" #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_PATH "meshes"
#define DEER_MESH_EXTENSION ".dmesh" #define DEER_MESH_EXTENSION ".dmesh"

View File

@ -78,27 +78,16 @@ namespace Deer {
uint16_t shaderId; 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 { struct CameraComponent {
CameraComponent() = default; CameraComponent() = default;
CameraComponent(const 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); } 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;
}; };
} }

View File

@ -63,11 +63,6 @@ namespace Deer {
if (m_environment->m_registry.any_of<CameraComponent>(m_entityHandle)) if (m_environment->m_registry.any_of<CameraComponent>(m_entityHandle))
creation.addComponent<CameraComponent>( creation.addComponent<CameraComponent>(
getComponent<CameraComponent>()); getComponent<CameraComponent>());
if (m_environment->m_registry.any_of<TextureBindingComponent>(
m_entityHandle))
creation.addComponent<TextureBindingComponent>(
getComponent<TextureBindingComponent>());
#endif #endif
return creation; return creation;
} }

View File

@ -52,8 +52,6 @@ namespace Deer {
archive, "meshRenderComponent", entity); archive, "meshRenderComponent", entity);
saveComponent<Archive, CameraComponent>(archive, "cameraComponent", saveComponent<Archive, CameraComponent>(archive, "cameraComponent",
entity); entity);
saveComponent<Archive, TextureBindingComponent>(
archive, "textureBindingComponent", entity);
} }
#endif #endif
saveComponent<Archive, ScriptComponent>(archive, "scriptComponent", saveComponent<Archive, ScriptComponent>(archive, "scriptComponent",
@ -80,8 +78,6 @@ namespace Deer {
archive, "meshRenderComponent", entity); archive, "meshRenderComponent", entity);
loadComponent<Archive, CameraComponent>(archive, "cameraComponent", loadComponent<Archive, CameraComponent>(archive, "cameraComponent",
entity); entity);
loadComponent<Archive, TextureBindingComponent>(
archive, "textureBindingComponent", entity);
} }
#endif #endif
loadComponent<Archive, ScriptComponent>(archive, "scriptComponent", loadComponent<Archive, ScriptComponent>(archive, "scriptComponent",

View File

@ -22,49 +22,4 @@ namespace Deer {
archive(cereal::make_nvp("bindingID", textureBinding.bindingID)); archive(cereal::make_nvp("bindingID", textureBinding.bindingID));
} }
template<class Archive>
void load(Archive& archive,
TextureBindingComponent& textureBinding) {
std::vector<TextureBinding> 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<Texture2D>(
std::filesystem::path(binding.texturePath));
textureBinding.textureBindID[id] = binding.bindingID;
}
*/
}
template<class Archive>
void save(Archive& archive,
TextureBindingComponent const& textureBinding) {
std::vector<TextureBinding> 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));
*/
}
} }

49
DeerLSP/Build.lua Executable file
View File

@ -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"

View File

@ -15,15 +15,15 @@ namespace Deer {
Ref<Texture2D> Icons::info_icon; Ref<Texture2D> Icons::info_icon;
void Icons::setupIcons() { void Icons::setupIcons() {
Icons::scene_icon = Texture2D::create(DataStore::rootPath / "editor/icons/scene.png"); Icons::scene_icon = Texture2D::create(DataStore::rootPath / "Editor/icons/scene.png");
Icons::folder_icon = Texture2D::create(DataStore::rootPath / "editor/icons/folder.png"); Icons::folder_icon = Texture2D::create(DataStore::rootPath / "Editor/icons/folder.png");
Icons::add_icon = Texture2D::create(DataStore::rootPath / "editor/icons/add.png"); Icons::add_icon = Texture2D::create(DataStore::rootPath / "Editor/icons/add.png");
Icons::substract_icon = Texture2D::create(DataStore::rootPath / "editor/icons/substract.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_icon = Texture2D::create(DataStore::rootPath / "Editor/icons/fill.png");
Icons::fill_empty_icon = Texture2D::create(DataStore::rootPath / "editor/icons/fill_empty.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::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::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::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::info_icon = Texture2D::create(DataStore::rootPath / "Editor/icons/info.png");
} }
} }

View File

@ -27,7 +27,7 @@ namespace Deer {
// //
// bool == // bool ==
//} //}
struct EntityStruct : EntityRefStruct { struct EntityStruct : EntityHandleStruct {
EntityStruct(uint16_t entId = 0) { entityId = entId; } EntityStruct(uint16_t entId = 0) { entityId = entId; }
std::string getName(); std::string getName();
@ -39,33 +39,40 @@ namespace Deer {
bool isRoot(); bool isRoot();
void destroy(); void destroy();
EntityRefStruct createChild(std::string&); EntityHandleStruct createChild(std::string&);
void setParent(EntityRefStruct parent); void setParent(EntityHandleStruct parent);
EntityRefStruct getParent(); EntityHandleStruct getParent();
bool isDescendantOf(EntityRefStruct parent); bool isDescendantOf(EntityHandleStruct parent);
bool opEquals(const EntityRefStruct& other); bool opEquals(const EntityHandleStruct& other);
//COMPONENTS //COMPONENTS
EntityRefStruct getMeshComponent(); EntityHandleStruct getMeshComponent();
EntityHandleStruct createMeshComponent();
bool hasMeshComponent(); bool hasMeshComponent();
void removeMeshComponent(); void removeMeshComponent();
EntityRefStruct getShaderComponent(); EntityHandleStruct getShaderComponent();
EntityHandleStruct createShaderComponent();
bool hasShaderComponent(); bool hasShaderComponent();
void removeShaderComponent(); 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 // 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(); int getChildCount();
EntityRefStruct getChild(int); EntityHandleStruct getChild(int);
}; };
struct TransformComponentStruct : EntityRefStruct { struct TransformComponentStruct : EntityHandleStruct {
glm::vec3 getPosition(); glm::vec3 getPosition();
glm::vec3 getScale(); glm::vec3 getScale();
glm::vec3 getRotation(); glm::vec3 getRotation();
@ -75,7 +82,7 @@ namespace Deer {
void setRotation(glm::vec3); void setRotation(glm::vec3);
}; };
struct MeshComponentStruct : EntityRefStruct { struct MeshComponentStruct : EntityHandleStruct {
bool isActive(); bool isActive();
void setActive(bool); void setActive(bool);
@ -88,7 +95,7 @@ namespace Deer {
bool assertMeshComponent(const char* funcName); bool assertMeshComponent(const char* funcName);
}; };
struct ShaderComponentStruct : EntityRefStruct { struct ShaderComponentStruct : EntityHandleStruct {
bool hasShader(); bool hasShader();
void clear(); void clear();
@ -98,7 +105,21 @@ namespace Deer {
bool assertShaderComponent(const char* funcName); 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 constructEntityStruct(int id, void* memory);
void copyEntityStruct(int id, void* memory); void copyEntityStruct(int id, void* memory);

View File

@ -4,16 +4,16 @@
namespace Deer { namespace Deer {
namespace EditorEngine { namespace EditorEngine {
struct EnvironmentStruct : EnvironmentRefStruct { struct EnvironmentStruct : EnvironmentHandleStruct {
void render(EntityRefStruct cameraEntity, FrameBufferRefStruct); void render(EntityHandleStruct cameraEntity, FrameBufferHandleStruct);
EntityRefStruct getRootEntity(); EntityHandleStruct getRootEntity();
EntityRefStruct getEntity(int); EntityHandleStruct getEntity(int);
}; };
EnvironmentRefStruct getMainEnvironment(); EnvironmentHandleStruct getMainEnvironment();
EnvironmentRefStruct createEnvironment(std::string&); EnvironmentHandleStruct createEnvironment(std::string&);
EnvironmentRefStruct getEnvironment(std::string&); EnvironmentHandleStruct getEnvironment(std::string&);
} }
} }

View File

@ -1,10 +1,11 @@
#pragma once #pragma once
#include "DeerStudio/EditorEngine/API/GenericRefStructs.h"
#include <cstdint> #include <cstdint>
#include <string> #include <string>
namespace Deer { namespace Deer {
namespace EditorEngine { namespace EditorEngine {
struct FrameBufferStruct : FrameBufferRefStruct{ struct FrameBufferStruct : FrameBufferHandleStruct{
FrameBufferStruct(uint16_t _id) { frameBufferId = _id; } FrameBufferStruct(uint16_t _id) { frameBufferId = _id; }
int getWidth(); int getWidth();

View File

@ -3,7 +3,7 @@
namespace Deer { namespace Deer {
namespace EditorEngine { namespace EditorEngine {
struct EntityRefStruct { struct EntityHandleStruct {
uint16_t entityId; uint16_t entityId;
uint16_t environmentId; uint16_t environmentId;
@ -11,11 +11,11 @@ namespace Deer {
bool assertEntity(const char* funcName); bool assertEntity(const char* funcName);
}; };
struct EnvironmentRefStruct { struct EnvironmentHandleStruct {
uint16_t environmentId; uint16_t environmentId;
}; };
struct FrameBufferRefStruct { struct FrameBufferHandleStruct {
uint16_t frameBufferId; uint16_t frameBufferId;
}; };
} }

View File

@ -17,6 +17,8 @@ namespace Deer {
// Renders a component node // Renders a component node
bool componentNode(std::string&, CScriptAny*, asIScriptFunction*); 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 // Renders a tree leaf
void treeNode(std::string&, bool); void treeNode(std::string&, bool);
// Renders a tree node with its sub nodes // Renders a tree node with its sub nodes

View File

@ -1,21 +1,26 @@
#include "DeerStudio/EditorEngine/API/Entity.h" #include "DeerStudio/EditorEngine/API/Entity.h"
#include "Deer/Enviroment.h"
#include "DeerStudio/EditorEngine.h"
#include "DeerStudio/EditorEngine/DockPanelObject.h" #include "DeerStudio/EditorEngine/DockPanelObject.h"
#include "DeerStudio/EditorEngine.h"
#include "DeerRender/Components.h"
#include "Deer/Enviroment.h"
#include "Deer/Scene.h" #include "Deer/Scene.h"
#define GET_ENTITY(id) Scene::environment.getEntity(id) #define GET_ENTITY(id) Scene::environment.getEntity(id)
#define GET_MESH_COMPONENT(id) Scene::environment.getEntity(id).getComponent<MeshComponent>() #define GET_MESH_COMPONENT(id) Scene::environment.getEntity(id).getComponent<MeshComponent>()
#define GET_SHADER_COMPONENT(id) Scene::environment.getEntity(id).getComponent<ShaderComponent>() #define GET_SHADER_COMPONENT(id) Scene::environment.getEntity(id).getComponent<ShaderComponent>()
#define GET_CAMERA_COMPONENT(id) Scene::environment.getEntity(id).getComponent<CameraComponent>()
#define ASSERT_ENTITY(func, ret) if (!assertEntity(func)) ret; #define ASSERT_ENTITY(func, ret) if (!assertEntity(func)) ret;
#define ASSERT_MESH_COMPONENT(func, ret) if (!assertMeshComponent(func)) ret; #define ASSERT_MESH_COMPONENT(func, ret) if (!assertMeshComponent(func)) ret;
#define ASSERT_SHADER_COMPONENT(func, ret) if (!assertShaderComponent(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 Deer {
namespace EditorEngine { namespace EditorEngine {
EntityRefStruct getRoot() { EntityHandleStruct getRoot() {
return EntityStruct(0); return EntityStruct(0);
} }
@ -27,7 +32,7 @@ namespace Deer {
return entityId; return entityId;
} }
bool EntityRefStruct::assertEntity(const char* funcName) { bool EntityHandleStruct::assertEntity(const char* funcName) {
if (!Scene::environment.entityExists(entityId)) { if (!Scene::environment.entityExists(entityId)) {
DEER_UI_ENGINE_ERROR("Error, invalid entity calling {0}, entityId : {1}", funcName, entityId); DEER_UI_ENGINE_ERROR("Error, invalid entity calling {0}, entityId : {1}", funcName, entityId);
if (currentDockPanelExecution) if (currentDockPanelExecution)
@ -74,7 +79,7 @@ namespace Deer {
.entityExists(entityId); .entityExists(entityId);
} }
void EntityStruct::setParent(EntityRefStruct parent_struct) { void EntityStruct::setParent(EntityHandleStruct parent_struct) {
ASSERT_ENTITY("setParent()", return); ASSERT_ENTITY("setParent()", return);
Entity& parent = GET_ENTITY(parent_struct.entityId); Entity& parent = GET_ENTITY(parent_struct.entityId);
@ -83,7 +88,7 @@ namespace Deer {
.setParent(parent); .setParent(parent);
} }
EntityRefStruct EntityStruct::getParent() { EntityHandleStruct EntityStruct::getParent() {
ASSERT_ENTITY("getParent()", return *this); ASSERT_ENTITY("getParent()", return *this);
Entity& self = GET_ENTITY(entityId); Entity& self = GET_ENTITY(entityId);
@ -93,7 +98,7 @@ namespace Deer {
return EntityStruct(self.getParentId()); return EntityStruct(self.getParentId());
} }
bool EntityStruct::isDescendantOf(EntityRefStruct parent_struct) { bool EntityStruct::isDescendantOf(EntityHandleStruct parent_struct) {
ASSERT_ENTITY("isDescendantOf()", return false); ASSERT_ENTITY("isDescendantOf()", return false);
Entity& parent = GET_ENTITY(parent_struct.entityId); Entity& parent = GET_ENTITY(parent_struct.entityId);
@ -102,13 +107,13 @@ namespace Deer {
.isDescendantOf(parent); .isDescendantOf(parent);
} }
bool EntityStruct::opEquals(const EntityRefStruct& other) { bool EntityStruct::opEquals(const EntityHandleStruct& other) {
ASSERT_ENTITY("opEquals()", return false); ASSERT_ENTITY("opEquals()", return false);
return entityId == other.entityId; return entityId == other.entityId;
} }
EntityRefStruct EntityStruct::getSelf() { EntityHandleStruct EntityStruct::getSelf() {
ASSERT_ENTITY("getSelf()", return *this); ASSERT_ENTITY("getSelf()", return *this);
return *this; return *this;
@ -177,7 +182,7 @@ namespace Deer {
return true; return true;
} }
EntityRefStruct EntityChildArrayStruct::getChild(int i) { EntityHandleStruct EntityChildArrayStruct::getChild(int i) {
ASSERT_ENTITY("getChild()", return *this); ASSERT_ENTITY("getChild()", return *this);
RelationshipComponent& rc = GET_ENTITY(entityId) RelationshipComponent& rc = GET_ENTITY(entityId)
@ -194,7 +199,7 @@ namespace Deer {
return EntityStruct(rc.getChildrenId(i)); return EntityStruct(rc.getChildrenId(i));
} }
EntityRefStruct EntityStruct::createChild(std::string& name) { EntityHandleStruct EntityStruct::createChild(std::string& name) {
ASSERT_ENTITY("createChild()", return *this); ASSERT_ENTITY("createChild()", return *this);
Entity& me = GET_ENTITY(entityId); Entity& me = GET_ENTITY(entityId);
@ -207,11 +212,29 @@ namespace Deer {
return EntityStruct(newEnt.getId()); return EntityStruct(newEnt.getId());
} }
EntityRefStruct EntityStruct::getMeshComponent() { EntityHandleStruct EntityStruct::getMeshComponent() {
ASSERT_ENTITY("getMeshComponent()", return *this); ASSERT_ENTITY("getMeshComponent()", return *this);
Entity& self = GET_ENTITY(entityId); Entity& self = GET_ENTITY(entityId);
if (!self.hasComponent<MeshComponent>()) {
DEER_CORE_ERROR("Error, entity {0} with id {1} does not have MeshComponent",
GET_ENTITY(entityId).getComponent<TagComponent>().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<MeshComponent>()) { if (!self.hasComponent<MeshComponent>()) {
self.addComponent<MeshComponent>(); self.addComponent<MeshComponent>();
} }
@ -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<CameraComponent>()) {
DEER_CORE_ERROR("Error, entity {0} with id {1} does not have Camera Component",
GET_ENTITY(entityId).getComponent<TagComponent>().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<CameraComponent>()) {
self.addComponent<CameraComponent>();
}
return *this;
}
bool EntityStruct::hasCameraComponent() {
ASSERT_ENTITY("hasCameraComponent()", return false);
Entity& self = GET_ENTITY(entityId);
return self.hasComponent<CameraComponent>();
}
void EntityStruct::removeCameraComponent() {
ASSERT_ENTITY("removeMeshComponent()", return);
Entity& self = GET_ENTITY(entityId);
if (self.hasComponent<CameraComponent>()) {
self.removeComponent<CameraComponent>();
}
}
EntityHandleStruct EntityStruct::getShaderComponent() {
ASSERT_ENTITY("getShaderComponent()", return *this); ASSERT_ENTITY("getShaderComponent()", return *this);
Entity& self = GET_ENTITY(entityId); Entity& self = GET_ENTITY(entityId);
if (!self.hasComponent<ShaderComponent>()) {
DEER_CORE_ERROR("Error, entity {0} with id {1} does not have Shader Component",
GET_ENTITY(entityId).getComponent<TagComponent>().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<ShaderComponent>()) { if (!self.hasComponent<ShaderComponent>()) {
self.addComponent<ShaderComponent>(); self.addComponent<ShaderComponent>();
} }
@ -346,5 +435,71 @@ namespace Deer {
GET_SHADER_COMPONENT(entityId).setShader(shaderId); 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<CameraComponent>()) {
DEER_UI_ENGINE_ERROR("Error, calling CameraComponent.{0} entity {1} with id {2} has no CameraComponent",
funcName,
ent.getComponent<TagComponent>().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;
}
} }
} }

View File

@ -11,28 +11,33 @@ namespace Deer {
void registerTransformComponentFunctions(); void registerTransformComponentFunctions();
void registerMeshComponentFunction(); void registerMeshComponentFunction();
void registerShaderComponentFunctions(); void registerShaderComponentFunctions();
void registerComponentComponentFunctions();
void registerEntityStructs() { void registerEntityStructs() {
AS_CHECK(scriptEngine->RegisterObjectType("Entity", sizeof(EntityRefStruct), AS_CHECK(scriptEngine->RegisterObjectType("Entity", sizeof(EntityHandleStruct),
asOBJ_VALUE | asOBJ_POD | asGetTypeTraits<EntityRefStruct>() | asOBJ_APP_CLASS_ALLINTS)); asOBJ_VALUE | asOBJ_POD | asGetTypeTraits<EntityHandleStruct>() | asOBJ_APP_CLASS_ALLINTS));
AS_CHECK(scriptEngine->RegisterObjectType("EntityChilds", sizeof(EntityRefStruct), AS_CHECK(scriptEngine->RegisterObjectType("EntityChilds", sizeof(EntityHandleStruct),
asOBJ_VALUE | asOBJ_POD | asGetTypeTraits<EntityRefStruct>() | asOBJ_APP_CLASS_ALLINTS)); asOBJ_VALUE | asOBJ_POD | asGetTypeTraits<EntityHandleStruct>() | asOBJ_APP_CLASS_ALLINTS));
AS_CHECK(scriptEngine->RegisterObjectType("TransformComponent", sizeof(EntityRefStruct), AS_CHECK(scriptEngine->RegisterObjectType("TransformComponent", sizeof(EntityHandleStruct),
asOBJ_VALUE | asOBJ_POD | asGetTypeTraits<EntityRefStruct>() | asOBJ_APP_CLASS_ALLINTS)); asOBJ_VALUE | asOBJ_POD | asGetTypeTraits<EntityHandleStruct>() | asOBJ_APP_CLASS_ALLINTS));
AS_CHECK(scriptEngine->RegisterObjectType("MeshComponent", sizeof(EntityRefStruct), AS_CHECK(scriptEngine->RegisterObjectType("MeshComponent", sizeof(EntityHandleStruct),
asOBJ_VALUE | asOBJ_POD | asGetTypeTraits<EntityRefStruct>() | asOBJ_APP_CLASS_ALLINTS)); asOBJ_VALUE | asOBJ_POD | asGetTypeTraits<EntityHandleStruct>() | asOBJ_APP_CLASS_ALLINTS));
AS_CHECK(scriptEngine->RegisterObjectType("ShaderComponent", sizeof(EntityRefStruct), AS_CHECK(scriptEngine->RegisterObjectType("ShaderComponent", sizeof(EntityHandleStruct),
asOBJ_VALUE | asOBJ_POD | asGetTypeTraits<EntityRefStruct>() | asOBJ_APP_CLASS_ALLINTS)); asOBJ_VALUE | asOBJ_POD | asGetTypeTraits<EntityHandleStruct>() | asOBJ_APP_CLASS_ALLINTS));
AS_CHECK(scriptEngine->RegisterObjectType("CameraComponent", sizeof(EntityHandleStruct),
asOBJ_VALUE | asOBJ_POD | asGetTypeTraits<EntityHandleStruct>() | asOBJ_APP_CLASS_ALLINTS));
} }
void registerEntityFunctions() { void registerEntityFunctions() {
registerTransformComponentFunctions(); registerTransformComponentFunctions();
registerMeshComponentFunction(); registerMeshComponentFunction();
registerShaderComponentFunctions(); registerShaderComponentFunctions();
registerComponentComponentFunctions();
// ENTITY // ENTITY
AS_CHECK(scriptEngine->RegisterObjectMethod( AS_CHECK(scriptEngine->RegisterObjectMethod(
@ -126,7 +131,6 @@ namespace Deer {
asCALL_THISCALL asCALL_THISCALL
)); ));
AS_CHECK(scriptEngine->RegisterObjectMethod( AS_CHECK(scriptEngine->RegisterObjectMethod(
"Entity", "Entity",
"MeshComponent getMeshComponent()", "MeshComponent getMeshComponent()",
@ -134,6 +138,13 @@ namespace Deer {
asCALL_THISCALL asCALL_THISCALL
)); ));
AS_CHECK(scriptEngine->RegisterObjectMethod(
"Entity",
"MeshComponent createMeshComponent()",
asMETHOD(EntityStruct, createMeshComponent),
asCALL_THISCALL
));
AS_CHECK(scriptEngine->RegisterObjectMethod( AS_CHECK(scriptEngine->RegisterObjectMethod(
"Entity", "Entity",
"bool hasMeshComponent()", "bool hasMeshComponent()",
@ -176,6 +187,13 @@ namespace Deer {
asCALL_THISCALL asCALL_THISCALL
)); ));
AS_CHECK(scriptEngine->RegisterObjectMethod(
"Entity",
"ShaderComponent createShaderComponent() ",
asMETHOD(EntityStruct, createShaderComponent),
asCALL_THISCALL
));
AS_CHECK(scriptEngine->RegisterObjectMethod( AS_CHECK(scriptEngine->RegisterObjectMethod(
"Entity", "Entity",
"bool hasShaderComponent() ", "bool hasShaderComponent() ",
@ -189,6 +207,34 @@ namespace Deer {
asMETHOD(EntityStruct, removeShaderComponent), asMETHOD(EntityStruct, removeShaderComponent),
asCALL_THISCALL 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() { 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
));
}
} }
} }

View File

@ -0,0 +1,7 @@
#include "DeerStudio/EditorEngine/API/Environment.h"
namespace Deer {
namespace DeerEngine {
}
}

View File

@ -103,6 +103,63 @@ namespace Deer {
return false; 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) { void setupColumns(int i) {
ImGui::Columns(i, nullptr, false); ImGui::Columns(i, nullptr, false);
} }

View File

@ -289,9 +289,13 @@ namespace Deer {
float tmp = value; float tmp = value;
bool value_changed = false; bool value_changed = false;
ImGui::Columns(2, nullptr, false);
ImGui::Text("%s", txt.c_str()); ImGui::Text("%s", txt.c_str());
ImGui::SameLine(); ImGui::SameLine();
ImGui::NextColumn();
if (id == ImGui::GetID(txt.c_str())) if (id == ImGui::GetID(txt.c_str()))
{ {
// — Input mode — // — Input mode —
@ -324,6 +328,8 @@ namespace Deer {
} }
} }
ImGui::Columns();
if (value_changed) if (value_changed)
value = tmp; value = tmp;

View File

@ -99,6 +99,12 @@ namespace Deer {
asCALL_CDECL asCALL_CDECL
)); ));
AS_CHECK(scriptEngine->RegisterGlobalFunction(
"bool componentNode_contextMenu(const string& in, any@+, ReciverFunc@+, ReciverFunc@+)",
asFUNCTION(componentNode_contextMenu),
asCALL_CDECL
));
AS_CHECK(scriptEngine->RegisterGlobalFunction( AS_CHECK(scriptEngine->RegisterGlobalFunction(
"void contextItemPopup(const string& in, any@+, ReciverFunc@+)", "void contextItemPopup(const string& in, any@+, ReciverFunc@+)",
asFUNCTION(contextItemPopup), asFUNCTION(contextItemPopup),

View File

@ -11,7 +11,7 @@ namespace Deer {
ImFontConfig cnfg; ImFontConfig cnfg;
// cnfg.SizePixels = 26 // cnfg.SizePixels = 26
Path rfPath = DataStore::rootPath / "editor/fonts/Roboto-Regular.ttf"; Path rfPath = DataStore::rootPath / "Editor/fonts/Roboto-Regular.ttf";
normalText = normalText =
io.Fonts->AddFontFromFileTTF(rfPath.generic_string().c_str(), 18); io.Fonts->AddFontFromFileTTF(rfPath.generic_string().c_str(), 18);
titleText = titleText =

View File

@ -21,6 +21,10 @@ include "Deer/vendor/imgui/Build.lua"
include "Deer/vendor/angelScript/Build.lua" include "Deer/vendor/angelScript/Build.lua"
group "" group ""
group "scripting"
include "DeerLSP/Build.lua"
group ""
-- group "Runtime" -- group "Runtime"
-- include "DeerRuntime/Build.lua" -- include "DeerRuntime/Build.lua"
-- group "" -- group ""

View File

@ -18,7 +18,7 @@ void addComponentRendering(any@ data) {
menuItemDisabled("Mesh Render Component"); menuItemDisabled("Mesh Render Component");
} else { } else {
if (menuItem("Mesh Render Component")) { if (menuItem("Mesh Render Component")) {
entity.getMeshComponent(); entity.createMeshComponent();
} }
} }
@ -26,7 +26,15 @@ void addComponentRendering(any@ data) {
menuItemDisabled("Shader Render Component"); menuItemDisabled("Shader Render Component");
} else { } else {
if (menuItem("Shader Render Component")) { if (menuItem("Shader Render Component")) {
entity.getShaderComponent(); entity.createShaderComponent();
}
}
if (entity.hasCameraComponent()) {
menuItemDisabled("Camera Component");
} else {
if (menuItem("Camera Component")) {
entity.createCameraComponent();
} }
} }
} }

View File

@ -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();
}
}

View File

@ -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();
}
}

View File

@ -30,12 +30,18 @@ class PropertiesPannel : DockPanel {
componentNode("Transform Component", any(entity), renderTransformComponent); componentNode("Transform Component", any(entity), renderTransformComponent);
if (entity.hasMeshComponent()) { if (entity.hasMeshComponent()) {
componentNode("Mesh Component", any(entity), renderMeshComponent); componentNode_contextMenu("Mesh Component", any(entity), renderMeshComponent, removeMeshComponent);
} }
if (entity.hasShaderComponent()) { 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(); space();
separator(); separator();

View File

@ -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();
}
}

View File

@ -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);
}

View File

Before

Width:  |  Height:  |  Size: 126 B

After

Width:  |  Height:  |  Size: 126 B

View File

Before

Width:  |  Height:  |  Size: 179 B

After

Width:  |  Height:  |  Size: 179 B

View File

Before

Width:  |  Height:  |  Size: 123 B

After

Width:  |  Height:  |  Size: 123 B

View File

Before

Width:  |  Height:  |  Size: 123 B

After

Width:  |  Height:  |  Size: 123 B

View File

Before

Width:  |  Height:  |  Size: 268 B

After

Width:  |  Height:  |  Size: 268 B

View File

Before

Width:  |  Height:  |  Size: 311 B

After

Width:  |  Height:  |  Size: 311 B

View File

Before

Width:  |  Height:  |  Size: 236 B

After

Width:  |  Height:  |  Size: 236 B

View File

Before

Width:  |  Height:  |  Size: 240 B

After

Width:  |  Height:  |  Size: 240 B

View File

Before

Width:  |  Height:  |  Size: 266 B

After

Width:  |  Height:  |  Size: 266 B

View File

Before

Width:  |  Height:  |  Size: 140 B

After

Width:  |  Height:  |  Size: 140 B

View File

Before

Width:  |  Height:  |  Size: 249 B

After

Width:  |  Height:  |  Size: 249 B

View File

Before

Width:  |  Height:  |  Size: 154 B

After

Width:  |  Height:  |  Size: 154 B

View File

Before

Width:  |  Height:  |  Size: 206 B

After

Width:  |  Height:  |  Size: 206 B

View File

Before

Width:  |  Height:  |  Size: 118 B

After

Width:  |  Height:  |  Size: 118 B

View File

Before

Width:  |  Height:  |  Size: 270 B

After

Width:  |  Height:  |  Size: 270 B

View File

Before

Width:  |  Height:  |  Size: 101 B

After

Width:  |  Height:  |  Size: 101 B

View File

@ -8,19 +8,6 @@ class TreePannel : DockPanel {
modalPopup("Rename entity", renameEntity); 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) { void renderNode(any@ data) {
Entity entity; Entity entity;
data.retrieve(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) { void entityContextMenu(any@ data) {
Entity entity; Entity entity;
data.retrieve(entity); data.retrieve(entity);

View File

@ -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);
}

View File

@ -15,8 +15,8 @@ Collapsed=0
DockId=0x00000004,1 DockId=0x00000004,1
[Window][Game Window] [Window][Game Window]
Pos=365,24 Pos=412,24
Size=504,503 Size=457,487
Collapsed=0 Collapsed=0
DockId=0x00000006,0 DockId=0x00000006,0
@ -28,13 +28,13 @@ DockId=0x00000001,0
[Window][Terrain Editor] [Window][Terrain Editor]
Pos=871,24 Pos=871,24
Size=409,503 Size=409,487
Collapsed=0 Collapsed=0
DockId=0x00000004,0 DockId=0x00000004,0
[Window][Viewport] [Window][Viewport]
Pos=365,24 Pos=412,24
Size=504,503 Size=457,487
Collapsed=0 Collapsed=0
DockId=0x00000006,1 DockId=0x00000006,1
@ -57,14 +57,14 @@ Collapsed=0
DockId=0x00000008,1 DockId=0x00000008,1
[Window][MeshExplorer] [Window][MeshExplorer]
Pos=0,529 Pos=0,513
Size=1280,191 Size=1280,207
Collapsed=0 Collapsed=0
DockId=0x00000008,0 DockId=0x00000008,0
[Window][TreePannel] [Window][TreePannel]
Pos=0,24 Pos=0,24
Size=363,503 Size=410,487
Collapsed=0 Collapsed=0
DockId=0x00000005,0 DockId=0x00000005,0
@ -80,7 +80,7 @@ Collapsed=0
[Window][PropertiesPannel] [Window][PropertiesPannel]
Pos=871,24 Pos=871,24
Size=409,503 Size=409,487
Collapsed=0 Collapsed=0
DockId=0x00000004,1 DockId=0x00000004,1
@ -91,19 +91,19 @@ Collapsed=0
DockId=0x00000004,1 DockId=0x00000004,1
[Window][ShaderExplorer] [Window][ShaderExplorer]
Pos=0,529 Pos=0,513
Size=1280,191 Size=1280,207
Collapsed=0 Collapsed=0
DockId=0x00000008,1 DockId=0x00000008,1
[Docking][Data] [Docking][Data]
DockSpace ID=0xA1672E74 Window=0x4647B76E Pos=0,24 Size=1280,696 Split=Y 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=0x00000001 Parent=0x00000007 SizeRef=2560,363 Split=X Selected=0x13926F0B
DockNode ID=0x00000003 Parent=0x00000001 SizeRef=869,338 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=0x00000005 Parent=0x00000003 SizeRef=410,446 Selected=0xE45B9F93
DockNode ID=0x00000006 Parent=0x00000003 SizeRef=504,446 CentralNode=1 Selected=0x13926F0B DockNode ID=0x00000006 Parent=0x00000003 SizeRef=457,446 CentralNode=1 Selected=0x13926F0B
DockNode ID=0x00000004 Parent=0x00000001 SizeRef=409,338 Selected=0x2A2C795E DockNode ID=0x00000004 Parent=0x00000001 SizeRef=409,338 Selected=0x2A2C795E
DockNode ID=0x00000002 Parent=0x00000007 SizeRef=2560,331 Selected=0xCF339702 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