Changes
This commit is contained in:
parent
3e222b09be
commit
1af4547c97
@ -231,7 +231,11 @@ namespace Deer {
|
|||||||
TransformComponent& transformComponent = getContextEntityComponent<TransformComponent>(handle);
|
TransformComponent& transformComponent = getContextEntityComponent<TransformComponent>(handle);
|
||||||
return transformComponent.scale;
|
return transformComponent.scale;
|
||||||
}
|
}
|
||||||
glm::vec3 Scripting::transform_getRotation(EntityHandle& handle) {
|
glm::quat Scripting::transform_getRotation(EntityHandle& handle) {
|
||||||
|
TransformComponent& transformComponent = getContextEntityComponent<TransformComponent>(handle);
|
||||||
|
return transformComponent.rotation;
|
||||||
|
}
|
||||||
|
glm::vec3 Scripting::transform_getEuler(EntityHandle& handle) {
|
||||||
TransformComponent& transformComponent = getContextEntityComponent<TransformComponent>(handle);
|
TransformComponent& transformComponent = getContextEntityComponent<TransformComponent>(handle);
|
||||||
return transformComponent.getEulerAngles();
|
return transformComponent.getEulerAngles();
|
||||||
}
|
}
|
||||||
@ -244,7 +248,11 @@ namespace Deer {
|
|||||||
TransformComponent& transformComponent = getContextEntityComponent<TransformComponent>(handle);
|
TransformComponent& transformComponent = getContextEntityComponent<TransformComponent>(handle);
|
||||||
transformComponent.scale = scale;
|
transformComponent.scale = scale;
|
||||||
}
|
}
|
||||||
void Scripting::transform_setRotation(glm::vec3 rotation, EntityHandle& handle) {
|
void Scripting::transform_setRotation(glm::quat rotation, EntityHandle& handle) {
|
||||||
|
TransformComponent& transformComponent = getContextEntityComponent<TransformComponent>(handle);
|
||||||
|
transformComponent.rotation = rotation;
|
||||||
|
}
|
||||||
|
void Scripting::transform_setEuler(glm::vec3 rotation, EntityHandle& handle) {
|
||||||
TransformComponent& transformComponent = getContextEntityComponent<TransformComponent>(handle);
|
TransformComponent& transformComponent = getContextEntityComponent<TransformComponent>(handle);
|
||||||
transformComponent.setEulerAngles(rotation);
|
transformComponent.setEulerAngles(rotation);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -54,10 +54,12 @@ namespace Deer {
|
|||||||
// SPECIFIC TRANSFORM SECTION
|
// SPECIFIC TRANSFORM SECTION
|
||||||
glm::vec3 transform_getPosition(EntityHandle&);
|
glm::vec3 transform_getPosition(EntityHandle&);
|
||||||
glm::vec3 transform_getScale(EntityHandle&);
|
glm::vec3 transform_getScale(EntityHandle&);
|
||||||
glm::vec3 transform_getRotation(EntityHandle&);
|
glm::quat transform_getRotation(EntityHandle&);
|
||||||
|
glm::vec3 transform_getEuler(EntityHandle&);
|
||||||
void transform_setPosition(glm::vec3, EntityHandle&);
|
void transform_setPosition(glm::vec3, EntityHandle&);
|
||||||
void transform_setScale(glm::vec3, EntityHandle&);
|
void transform_setScale(glm::vec3, EntityHandle&);
|
||||||
void transform_setRotation(glm::vec3, EntityHandle&);
|
void transform_setRotation(glm::quat, EntityHandle&);
|
||||||
|
void transform_setEuler(glm::vec3, EntityHandle&);
|
||||||
|
|
||||||
void constructEntityStruct(void* memory);
|
void constructEntityStruct(void* memory);
|
||||||
void destructEntityStruct(void* memory);
|
void destructEntityStruct(void* memory);
|
||||||
|
|||||||
@ -19,6 +19,28 @@ namespace Deer {
|
|||||||
return glm::vec3(matrix[3][0], matrix[3][1], matrix[3][2]);
|
return glm::vec3(matrix[3][0], matrix[3][1], matrix[3][2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glm::quat mat4_getRotation(glm::mat4& m) {
|
||||||
|
glm::vec3 scale = mat4_getScale(m);
|
||||||
|
|
||||||
|
// Avoid division by zero
|
||||||
|
glm::mat3 rotationMatrix;
|
||||||
|
rotationMatrix[0] = glm::vec3(m[0]) / scale.x;
|
||||||
|
rotationMatrix[1] = glm::vec3(m[1]) / scale.y;
|
||||||
|
rotationMatrix[2] = glm::vec3(m[2]) / scale.z;
|
||||||
|
|
||||||
|
return glm::quat_cast(rotationMatrix);
|
||||||
|
}
|
||||||
|
|
||||||
|
glm::vec3 mat4_getScale(glm::mat4& m) {
|
||||||
|
glm::vec3 scale;
|
||||||
|
|
||||||
|
scale.x = glm::length(glm::vec3(m[0]));
|
||||||
|
scale.y = glm::length(glm::vec3(m[1]));
|
||||||
|
scale.z = glm::length(glm::vec3(m[2]));
|
||||||
|
|
||||||
|
return scale;
|
||||||
|
}
|
||||||
|
|
||||||
void vec3_constructor_params(float x, float y, float z, void* mem) {
|
void vec3_constructor_params(float x, float y, float z, void* mem) {
|
||||||
new (mem) glm::vec3(x, y, z);
|
new (mem) glm::vec3(x, y, z);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,6 +13,8 @@ namespace Deer {
|
|||||||
void mat4_constructor(void*);
|
void mat4_constructor(void*);
|
||||||
glm::mat4 mat4_getRelativeMatrix(glm::mat4&, glm::mat4&);
|
glm::mat4 mat4_getRelativeMatrix(glm::mat4&, glm::mat4&);
|
||||||
glm::vec3 mat4_getPosition(glm::mat4&);
|
glm::vec3 mat4_getPosition(glm::mat4&);
|
||||||
|
glm::quat mat4_getRotation(glm::mat4&);
|
||||||
|
glm::vec3 mat4_getScale(glm::mat4&);
|
||||||
|
|
||||||
glm::vec3 vec3_add(glm::vec3&, glm::vec3&);
|
glm::vec3 vec3_add(glm::vec3&, glm::vec3&);
|
||||||
glm::vec3 vec3_sub(const glm::vec3&, glm::vec3&);
|
glm::vec3 vec3_sub(const glm::vec3&, glm::vec3&);
|
||||||
|
|||||||
@ -45,10 +45,12 @@ namespace Deer {
|
|||||||
|
|
||||||
REGISTER_EXT_OBJECT_METHOD(scriptEngine, "TransformComponent", "vec3 get_position() const property", transform_getPosition);
|
REGISTER_EXT_OBJECT_METHOD(scriptEngine, "TransformComponent", "vec3 get_position() const property", transform_getPosition);
|
||||||
REGISTER_EXT_OBJECT_METHOD(scriptEngine, "TransformComponent", "vec3 get_scale() const property", transform_getScale);
|
REGISTER_EXT_OBJECT_METHOD(scriptEngine, "TransformComponent", "vec3 get_scale() const property", transform_getScale);
|
||||||
REGISTER_EXT_OBJECT_METHOD(scriptEngine, "TransformComponent", "vec3 get_rotation() const property", transform_getRotation);
|
REGISTER_EXT_OBJECT_METHOD(scriptEngine, "TransformComponent", "quat get_rotation() const property", transform_getRotation);
|
||||||
|
REGISTER_EXT_OBJECT_METHOD(scriptEngine, "TransformComponent", "vec3 getEuler() const", transform_getEuler);
|
||||||
REGISTER_EXT_OBJECT_METHOD(scriptEngine, "TransformComponent", "void set_position(const vec3) property", transform_setPosition);
|
REGISTER_EXT_OBJECT_METHOD(scriptEngine, "TransformComponent", "void set_position(const vec3) property", transform_setPosition);
|
||||||
REGISTER_EXT_OBJECT_METHOD(scriptEngine, "TransformComponent", "void set_scale(const vec3) property", transform_setScale);
|
REGISTER_EXT_OBJECT_METHOD(scriptEngine, "TransformComponent", "void set_scale(const vec3) property", transform_setScale);
|
||||||
REGISTER_EXT_OBJECT_METHOD(scriptEngine, "TransformComponent", "void set_rotation(const vec3) property", transform_setRotation);
|
REGISTER_EXT_OBJECT_METHOD(scriptEngine, "TransformComponent", "void set_rotation(const quat) property", transform_setRotation);
|
||||||
|
REGISTER_EXT_OBJECT_METHOD(scriptEngine, "TransformComponent", "void setEuler(const vec3)", transform_setEuler);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scripting::registerEntityStructs() {
|
void Scripting::registerEntityStructs() {
|
||||||
|
|||||||
@ -63,6 +63,8 @@ namespace Deer {
|
|||||||
|
|
||||||
REGISTER_EXT_OBJECT_METHOD(scriptEngine, "mat4", "mat4 getRelativeMatrix(mat4&in) const", mat4_getRelativeMatrix);
|
REGISTER_EXT_OBJECT_METHOD(scriptEngine, "mat4", "mat4 getRelativeMatrix(mat4&in) const", mat4_getRelativeMatrix);
|
||||||
REGISTER_EXT_OBJECT_METHOD(scriptEngine, "mat4", "vec3 getPosition() const", mat4_getPosition);
|
REGISTER_EXT_OBJECT_METHOD(scriptEngine, "mat4", "vec3 getPosition() const", mat4_getPosition);
|
||||||
|
REGISTER_EXT_OBJECT_METHOD(scriptEngine, "mat4", "quat getRotation() const", mat4_getRotation);
|
||||||
|
REGISTER_EXT_OBJECT_METHOD(scriptEngine, "mat4", "vec3 getScale() const", mat4_getScale);
|
||||||
|
|
||||||
REGISTER_EXT_OBJECT_METHOD(scriptEngine, "Transform", "vec3 relative(vec3)", transform_relative);
|
REGISTER_EXT_OBJECT_METHOD(scriptEngine, "Transform", "vec3 relative(vec3)", transform_relative);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,6 +24,7 @@ namespace Deer {
|
|||||||
REGISTER_GLOBAL_FUNC(scriptEngine, "bool button(const string& in text)", Scripting::button);
|
REGISTER_GLOBAL_FUNC(scriptEngine, "bool button(const string& in text)", Scripting::button);
|
||||||
REGISTER_GLOBAL_FUNC(scriptEngine, "bool buttonCenter(const string& in text)", Scripting::buttonCenter);
|
REGISTER_GLOBAL_FUNC(scriptEngine, "bool buttonCenter(const string& in text)", Scripting::buttonCenter);
|
||||||
REGISTER_GLOBAL_FUNC(scriptEngine, "bool buttonEnd(const string& in text)", Scripting::buttonEnd);
|
REGISTER_GLOBAL_FUNC(scriptEngine, "bool buttonEnd(const string& in text)", Scripting::buttonEnd);
|
||||||
|
REGISTER_GLOBAL_FUNC(scriptEngine, "bool buttonExpanded(const string& in text)", Scripting::buttonExpanded);
|
||||||
|
|
||||||
REGISTER_GLOBAL_FUNC(scriptEngine, "bool cartIconButton(const string& in label, Texture texture, int iconSize, int width)", Scripting::cartIconButton);
|
REGISTER_GLOBAL_FUNC(scriptEngine, "bool cartIconButton(const string& in label, Texture texture, int iconSize, int width)", Scripting::cartIconButton);
|
||||||
REGISTER_GLOBAL_FUNC(scriptEngine, "bool cartIconButton(const string& in label, FrameBuffer frameBuffer, int iconSize, int width)", Scripting::cartIconButton_frameBuffer);
|
REGISTER_GLOBAL_FUNC(scriptEngine, "bool cartIconButton(const string& in label, FrameBuffer frameBuffer, int iconSize, int width)", Scripting::cartIconButton_frameBuffer);
|
||||||
|
|||||||
@ -93,6 +93,16 @@ namespace Deer {
|
|||||||
return ImGui::Button(txt.c_str());
|
return ImGui::Button(txt.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool buttonExpanded(std::string& txt) {
|
||||||
|
float sizeX;
|
||||||
|
if (ImGui::GetColumnsCount() > 1)
|
||||||
|
sizeX = ImGui::GetColumnWidth(-1);
|
||||||
|
else
|
||||||
|
sizeX = ImGui::GetContentRegionAvail().x;
|
||||||
|
|
||||||
|
return ImGui::Button(txt.c_str(), ImVec2(sizeX, 0));
|
||||||
|
}
|
||||||
|
|
||||||
void setCursorElementRight(std::string& txt, bool has_padding) {
|
void setCursorElementRight(std::string& txt, bool has_padding) {
|
||||||
float sizeX;
|
float sizeX;
|
||||||
if (ImGui::GetColumnsCount() > 1)
|
if (ImGui::GetColumnsCount() > 1)
|
||||||
@ -312,10 +322,8 @@ namespace Deer {
|
|||||||
ImGuizmo::SetRect(window_pos.x, window_pos.y, window_size.x, window_size.y);
|
ImGuizmo::SetRect(window_pos.x, window_pos.y, window_size.x, window_size.y);
|
||||||
|
|
||||||
glm::mat4 cameraProjection = camera.camera.getMatrix();
|
glm::mat4 cameraProjection = camera.camera.getMatrix();
|
||||||
cameraProjection[2][2] *= -1.0f;
|
|
||||||
cameraProjection[2][3] *= -1.0f;
|
|
||||||
|
|
||||||
glm::mat4 cameraView = glm::inverse(camera.transform.getMatrix());
|
glm::mat4 cameraView = glm::inverse(glm::scale(camera.transform.getMatrix(), glm::vec3(1, 1, -1)));
|
||||||
outMatrix = objMatrix;
|
outMatrix = objMatrix;
|
||||||
|
|
||||||
ImGuizmo::MODE mode = local ? ImGuizmo::MODE::LOCAL : ImGuizmo::MODE::WORLD;
|
ImGuizmo::MODE mode = local ? ImGuizmo::MODE::LOCAL : ImGuizmo::MODE::WORLD;
|
||||||
@ -333,10 +341,7 @@ namespace Deer {
|
|||||||
ImGuizmo::SetRect(window_pos.x, window_pos.y, window_size.x, window_size.y);
|
ImGuizmo::SetRect(window_pos.x, window_pos.y, window_size.x, window_size.y);
|
||||||
|
|
||||||
glm::mat4 cameraProjection = camera.camera.getMatrix();
|
glm::mat4 cameraProjection = camera.camera.getMatrix();
|
||||||
cameraProjection[2][2] *= -1.0f;
|
glm::mat4 cameraView = glm::inverse(glm::scale(camera.transform.getMatrix(), glm::vec3(1, 1, -1)));
|
||||||
cameraProjection[2][3] *= -1.0f;
|
|
||||||
|
|
||||||
glm::mat4 cameraView = glm::inverse(camera.transform.getMatrix());
|
|
||||||
outMatrix = objMatrix;
|
outMatrix = objMatrix;
|
||||||
|
|
||||||
ImGuizmo::MODE mode = local ? ImGuizmo::MODE::LOCAL : ImGuizmo::MODE::WORLD;
|
ImGuizmo::MODE mode = local ? ImGuizmo::MODE::LOCAL : ImGuizmo::MODE::WORLD;
|
||||||
@ -354,10 +359,7 @@ namespace Deer {
|
|||||||
ImGuizmo::SetRect(window_pos.x, window_pos.y, window_size.x, window_size.y);
|
ImGuizmo::SetRect(window_pos.x, window_pos.y, window_size.x, window_size.y);
|
||||||
|
|
||||||
glm::mat4 cameraProjection = camera.camera.getMatrix();
|
glm::mat4 cameraProjection = camera.camera.getMatrix();
|
||||||
cameraProjection[2][2] *= -1.0f;
|
glm::mat4 cameraView = glm::inverse(glm::scale(camera.transform.getMatrix(), glm::vec3(1, 1, -1)));
|
||||||
cameraProjection[2][3] *= -1.0f;
|
|
||||||
|
|
||||||
glm::mat4 cameraView = glm::inverse(camera.transform.getMatrix());
|
|
||||||
outMatrix = objMatrix;
|
outMatrix = objMatrix;
|
||||||
|
|
||||||
ImGuizmo::MODE mode = local ? ImGuizmo::MODE::LOCAL : ImGuizmo::MODE::WORLD;
|
ImGuizmo::MODE mode = local ? ImGuizmo::MODE::LOCAL : ImGuizmo::MODE::WORLD;
|
||||||
@ -760,7 +762,7 @@ namespace Deer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void drawCombo(std::string& name, std::string& selectedValue, asIScriptFunction* function) {
|
void drawCombo(std::string& name, std::string& selectedValue, asIScriptFunction* function) {
|
||||||
if (ImGui::BeginCombo(name.c_str(), selectedValue.c_str(), ImGuiComboFlags_WidthFitPreview)) {
|
if (ImGui::BeginCombo(name.c_str(), selectedValue.c_str())) {
|
||||||
|
|
||||||
asIScriptContext* scriptContext = asGetActiveContext();
|
asIScriptContext* scriptContext = asGetActiveContext();
|
||||||
if (scriptContext->PushState() == asSUCCESS) {
|
if (scriptContext->PushState() == asSUCCESS) {
|
||||||
|
|||||||
@ -31,6 +31,7 @@ namespace Deer {
|
|||||||
bool button(std::string&);
|
bool button(std::string&);
|
||||||
bool buttonCenter(std::string&);
|
bool buttonCenter(std::string&);
|
||||||
bool buttonEnd(std::string&);
|
bool buttonEnd(std::string&);
|
||||||
|
bool buttonExpanded(std::string&);
|
||||||
|
|
||||||
bool cartIconButton(const std::string& label, Resource<Texture> icon, int iconSize, int width);
|
bool cartIconButton(const std::string& label, Resource<Texture> icon, int iconSize, int width);
|
||||||
bool cartIconButton_frameBuffer(const std::string& label, Resource<FrameBuffer> frameBuffer, int iconSize, int width);
|
bool cartIconButton_frameBuffer(const std::string& label, Resource<FrameBuffer> frameBuffer, int iconSize, int width);
|
||||||
|
|||||||
@ -111,6 +111,8 @@ namespace Deer {
|
|||||||
}
|
}
|
||||||
ImGui::PopStyleVar();
|
ImGui::PopStyleVar();
|
||||||
|
|
||||||
|
ImGui::ShowDemoWindow();
|
||||||
|
|
||||||
if (world.getExecutionState() == Deer::WorldState::Executing)
|
if (world.getExecutionState() == Deer::WorldState::Executing)
|
||||||
StudioPanel::render();
|
StudioPanel::render();
|
||||||
|
|
||||||
|
|||||||
@ -15,7 +15,7 @@ namespace Deer {
|
|||||||
Path faNPath = "Editor/fonts/FontAwesome-Normal.otf";
|
Path faNPath = "Editor/fonts/FontAwesome-Normal.otf";
|
||||||
ImFontConfig cnfg;
|
ImFontConfig cnfg;
|
||||||
// cnfg.SizePixels = 26
|
// cnfg.SizePixels = 26
|
||||||
normalText = io.Fonts->AddFontFromFileTTF(rfPath.generic_string().c_str(), 18);
|
normalText = io.Fonts->AddFontFromFileTTF(rfPath.generic_string().c_str(), 20);
|
||||||
|
|
||||||
ImFontConfig config;
|
ImFontConfig config;
|
||||||
config.MergeMode = true;
|
config.MergeMode = true;
|
||||||
|
|||||||
@ -1,5 +1,14 @@
|
|||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
|
|
||||||
|
struct ImVec3 {
|
||||||
|
float x, y, z;
|
||||||
|
ImVec3(float _x = 0.0f, float _y = 0.0f, float _z = 0.0f) {
|
||||||
|
x = _x;
|
||||||
|
y = _y;
|
||||||
|
z = _z;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
void SetupImGuiStyle() {
|
void SetupImGuiStyle() {
|
||||||
// Rest style by AaronBeardless from ImThemes
|
// Rest style by AaronBeardless from ImThemes
|
||||||
ImGuiStyle& style = ImGui::GetStyle();
|
ImGuiStyle& style = ImGui::GetStyle();
|
||||||
@ -58,4 +67,60 @@ void SetupImGuiStyle() {
|
|||||||
// --- Text ---
|
// --- Text ---
|
||||||
c[ImGuiCol_Text] = ImVec4(0.88f, 0.88f, 0.88f, 1.00f);
|
c[ImGuiCol_Text] = ImVec4(0.88f, 0.88f, 0.88f, 1.00f);
|
||||||
c[ImGuiCol_TextDisabled] = ImVec4(0.52f, 0.52f, 0.52f, 1.00f);
|
c[ImGuiCol_TextDisabled] = ImVec4(0.52f, 0.52f, 0.52f, 1.00f);
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
ImGui::GetStyle().FrameRounding = 4.0f;
|
||||||
|
ImGui::GetStyle().GrabRounding = 4.0f;
|
||||||
|
|
||||||
|
ImVec4* colors = ImGui::GetStyle().Colors;
|
||||||
|
colors[ImGuiCol_Text] = ImVec4(0.95f, 0.96f, 0.98f, 1.00f);
|
||||||
|
colors[ImGuiCol_TextDisabled] = ImVec4(0.36f, 0.42f, 0.47f, 1.00f);
|
||||||
|
colors[ImGuiCol_WindowBg] = ImVec4(0.11f, 0.15f, 0.17f, 1.00f);
|
||||||
|
colors[ImGuiCol_ChildBg] = ImVec4(0.15f, 0.18f, 0.22f, 1.00f);
|
||||||
|
colors[ImGuiCol_PopupBg] = ImVec4(0.08f, 0.08f, 0.08f, 0.94f);
|
||||||
|
colors[ImGuiCol_Border] = ImVec4(0.08f, 0.10f, 0.12f, 1.00f);
|
||||||
|
colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
|
||||||
|
colors[ImGuiCol_FrameBg] = ImVec4(0.20f, 0.25f, 0.29f, 1.00f);
|
||||||
|
colors[ImGuiCol_FrameBgHovered] = ImVec4(0.12f, 0.20f, 0.28f, 1.00f);
|
||||||
|
colors[ImGuiCol_FrameBgActive] = ImVec4(0.09f, 0.12f, 0.14f, 1.00f);
|
||||||
|
colors[ImGuiCol_TitleBg] = ImVec4(0.09f, 0.12f, 0.14f, 0.65f);
|
||||||
|
colors[ImGuiCol_TitleBgActive] = ImVec4(0.08f, 0.10f, 0.12f, 1.00f);
|
||||||
|
colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.00f, 0.00f, 0.00f, 0.51f);
|
||||||
|
colors[ImGuiCol_MenuBarBg] = ImVec4(0.15f, 0.18f, 0.22f, 1.00f);
|
||||||
|
colors[ImGuiCol_ScrollbarBg] = ImVec4(0.02f, 0.02f, 0.02f, 0.39f);
|
||||||
|
colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.20f, 0.25f, 0.29f, 1.00f);
|
||||||
|
colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.18f, 0.22f, 0.25f, 1.00f);
|
||||||
|
colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.09f, 0.21f, 0.31f, 1.00f);
|
||||||
|
colors[ImGuiCol_CheckMark] = ImVec4(0.28f, 0.56f, 1.00f, 1.00f);
|
||||||
|
colors[ImGuiCol_SliderGrab] = ImVec4(0.28f, 0.56f, 1.00f, 1.00f);
|
||||||
|
colors[ImGuiCol_SliderGrabActive] = ImVec4(0.37f, 0.61f, 1.00f, 1.00f);
|
||||||
|
colors[ImGuiCol_Button] = ImVec4(0.20f, 0.25f, 0.29f, 1.00f);
|
||||||
|
colors[ImGuiCol_ButtonHovered] = ImVec4(0.28f, 0.56f, 1.00f, 1.00f);
|
||||||
|
colors[ImGuiCol_ButtonActive] = ImVec4(0.06f, 0.53f, 0.98f, 1.00f);
|
||||||
|
colors[ImGuiCol_Header] = ImVec4(0.20f, 0.25f, 0.29f, 0.55f);
|
||||||
|
colors[ImGuiCol_HeaderHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.80f);
|
||||||
|
colors[ImGuiCol_HeaderActive] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
|
||||||
|
colors[ImGuiCol_Separator] = ImVec4(0.20f, 0.25f, 0.29f, 1.00f);
|
||||||
|
colors[ImGuiCol_SeparatorHovered] = ImVec4(0.10f, 0.40f, 0.75f, 0.78f);
|
||||||
|
colors[ImGuiCol_SeparatorActive] = ImVec4(0.10f, 0.40f, 0.75f, 1.00f);
|
||||||
|
colors[ImGuiCol_ResizeGrip] = ImVec4(0.26f, 0.59f, 0.98f, 0.25f);
|
||||||
|
colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.67f);
|
||||||
|
colors[ImGuiCol_ResizeGripActive] = ImVec4(0.26f, 0.59f, 0.98f, 0.95f);
|
||||||
|
colors[ImGuiCol_Tab] = ImVec4(0.11f, 0.15f, 0.17f, 1.00f);
|
||||||
|
colors[ImGuiCol_TabHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.80f);
|
||||||
|
colors[ImGuiCol_TabActive] = ImVec4(0.20f, 0.25f, 0.29f, 1.00f);
|
||||||
|
colors[ImGuiCol_TabUnfocused] = ImVec4(0.11f, 0.15f, 0.17f, 1.00f);
|
||||||
|
colors[ImGuiCol_TabUnfocusedActive] = ImVec4(0.11f, 0.15f, 0.17f, 1.00f);
|
||||||
|
colors[ImGuiCol_PlotLines] = ImVec4(0.61f, 0.61f, 0.61f, 1.00f);
|
||||||
|
colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f);
|
||||||
|
colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
|
||||||
|
colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.60f, 0.00f, 1.00f);
|
||||||
|
colors[ImGuiCol_TextSelectedBg] = ImVec4(0.26f, 0.59f, 0.98f, 0.35f);
|
||||||
|
colors[ImGuiCol_DragDropTarget] = ImVec4(1.00f, 1.00f, 0.00f, 0.90f);
|
||||||
|
colors[ImGuiCol_NavHighlight] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
|
||||||
|
colors[ImGuiCol_NavWindowingHighlight] = ImVec4(1.00f, 1.00f, 1.00f, 0.70f);
|
||||||
|
colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.20f);
|
||||||
|
colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.35f);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
@ -6,9 +6,6 @@ class AddComponentRender {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void addComponentPopup() {
|
void addComponentPopup() {
|
||||||
ImGui::textCenter("Add Component");
|
|
||||||
ImGui::separator();
|
|
||||||
|
|
||||||
ImGui::subMenu(
|
ImGui::subMenu(
|
||||||
"Rendering",
|
"Rendering",
|
||||||
SimpleFunction(this.addComponentRendering)
|
SimpleFunction(this.addComponentRendering)
|
||||||
@ -11,40 +11,51 @@ class MeshComponentRender {
|
|||||||
if (!entity.hasComponent<MeshComponent>())
|
if (!entity.hasComponent<MeshComponent>())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ImGui::title("Mesh Component");
|
ImGui::columns(2);
|
||||||
ImGui::sameline();
|
|
||||||
|
|
||||||
if (ImGui::buttonEnd("Clear")) {
|
|
||||||
meshComponent.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui::space(10, 10);
|
|
||||||
ImGui::text("Mesh ");
|
ImGui::text("Mesh ");
|
||||||
ImGui::sameline();
|
|
||||||
|
ImGui::nextColumn();
|
||||||
|
|
||||||
if (meshComponent.hasMesh) {
|
if (meshComponent.hasMesh) {
|
||||||
ImGui::textColor(0.6, 1, 0.7,meshComponent.meshResource.name);
|
ImGui::buttonExpanded(meshComponent.meshResource.name);
|
||||||
} else {
|
} else {
|
||||||
ImGui::text("Empty");
|
ImGui::buttonExpanded("");
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::dragDropTarget("MESH", ReciverFunction(this.setMesh));
|
ImGui::dragDropTarget("MESH", ReciverFunction(this.setMesh));
|
||||||
|
|
||||||
|
ImGui::space(0, 1);
|
||||||
|
ImGui::nextColumn();
|
||||||
|
|
||||||
ImGui::text("Shader ");
|
ImGui::text("Shader ");
|
||||||
ImGui::sameline();
|
|
||||||
|
ImGui::nextColumn();
|
||||||
|
|
||||||
if (meshComponent.hasShader) {
|
if (meshComponent.hasShader) {
|
||||||
ImGui::textColor(0.6, 1, 0.7,meshComponent.shader.name);
|
ImGui::buttonExpanded(meshComponent.shader.name);
|
||||||
} else {
|
} else {
|
||||||
ImGui::text("Empty");
|
ImGui::buttonExpanded("");
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::dragDropTarget("SHADER", ReciverFunction(this.setShader));
|
ImGui::dragDropTarget("SHADER", ReciverFunction(this.setShader));
|
||||||
|
|
||||||
|
ImGui::space(0, 1);
|
||||||
|
ImGui::nextColumn();
|
||||||
|
|
||||||
ImGui::text("Texture ");
|
ImGui::text("Texture ");
|
||||||
ImGui::sameline();
|
|
||||||
|
ImGui::nextColumn();
|
||||||
|
|
||||||
if (meshComponent.hasTexture) {
|
if (meshComponent.hasTexture) {
|
||||||
ImGui::textColor(0.6, 1, 0.7,meshComponent.texture.name);
|
ImGui::buttonExpanded(meshComponent.texture.name);
|
||||||
} else {
|
} else {
|
||||||
ImGui::text("Empty");
|
ImGui::buttonExpanded("");
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::dragDropTarget("TEXTURE", ReciverFunction(this.setTexture));
|
ImGui::dragDropTarget("TEXTURE", ReciverFunction(this.setTexture));
|
||||||
|
|
||||||
|
ImGui::endColumns();
|
||||||
|
|
||||||
// Mesh icon
|
// Mesh icon
|
||||||
/*
|
/*
|
||||||
if (meshComponent.hasMesh) {
|
if (meshComponent.hasMesh) {
|
||||||
@ -77,9 +88,14 @@ class MeshComponentRender {
|
|||||||
meshComponent.texture = texture;
|
meshComponent.texture = texture;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void remove() {
|
void remove() {
|
||||||
if (ImGui::menuItem("Remove")) {
|
if (ImGui::menuItem("Remove")) {
|
||||||
entity.removeComponent<MeshComponent>();
|
entity.removeComponent<MeshComponent>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ImGui::menuItem("Clear")) {
|
||||||
|
meshComponent.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
class PropertiesPanel : Panel {
|
class Properties : Panel {
|
||||||
void onImGui() {
|
void onImGui() {
|
||||||
Entity entity = ActiveEntity::getActiveEntity();
|
Entity entity = ActiveEntity::getActiveEntity();
|
||||||
|
|
||||||
@ -10,14 +10,16 @@ class TransformPropertiesRender {
|
|||||||
void render() {
|
void render() {
|
||||||
vec3 position = transform.position;
|
vec3 position = transform.position;
|
||||||
vec3 scale = transform.scale;
|
vec3 scale = transform.scale;
|
||||||
vec3 rotation = transform.rotation;
|
vec3 rotation = transform.getEuler();
|
||||||
|
|
||||||
position = ImGui::magicSlider3("Position", position, 0.1f);
|
position = ImGui::magicSlider3("Position", position, 0.1f);
|
||||||
|
ImGui::space(0, 1);
|
||||||
scale = ImGui::magicSlider3("Scale", scale, 0.1f);
|
scale = ImGui::magicSlider3("Scale", scale, 0.1f);
|
||||||
|
ImGui::space(0, 1);
|
||||||
rotation = ImGui::magicSlider3("Rotation", rotation, 0.1f);
|
rotation = ImGui::magicSlider3("Rotation", rotation, 0.1f);
|
||||||
|
|
||||||
transform.set_position(position);
|
transform.set_position(position);
|
||||||
transform.set_scale(scale);
|
transform.set_scale(scale);
|
||||||
transform.set_rotation(rotation);
|
transform.setEuler(rotation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -174,7 +174,7 @@ class ResourceExplorer : Panel {
|
|||||||
void onImGui() {
|
void onImGui() {
|
||||||
|
|
||||||
fase += 0.3;
|
fase += 0.3;
|
||||||
ImGui::automaticColumns(size * 1.5);
|
ImGui::automaticColumns(size + 64);
|
||||||
|
|
||||||
string temp_path = currentPath;
|
string temp_path = currentPath;
|
||||||
|
|
||||||
|
|||||||
@ -112,7 +112,7 @@ class EntityNodeUI {
|
|||||||
void renderContextMenu() {
|
void renderContextMenu() {
|
||||||
if (entity.isRoot) {
|
if (entity.isRoot) {
|
||||||
if (ImGui::menuItem("New Entity")) {
|
if (ImGui::menuItem("New Entity")) {
|
||||||
entity.createChild("node");
|
entity.createChild("Entity");
|
||||||
rootPanel.onInit();
|
rootPanel.onInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,7 +120,7 @@ class EntityNodeUI {
|
|||||||
ImGui::subMenu("3d Object", SimpleFunction(this.render3dObjectMenu));
|
ImGui::subMenu("3d Object", SimpleFunction(this.render3dObjectMenu));
|
||||||
} else {
|
} else {
|
||||||
if (ImGui::menuItem("Add child")) {
|
if (ImGui::menuItem("Add child")) {
|
||||||
entity.createChild("node");
|
entity.createChild("Entity");
|
||||||
rootPanel.onInit();
|
rootPanel.onInit();
|
||||||
}
|
}
|
||||||
if (ImGui::menuItem("Rename")) {
|
if (ImGui::menuItem("Rename")) {
|
||||||
@ -141,7 +141,7 @@ class EntityNodeUI {
|
|||||||
|
|
||||||
void render3dObjectMenu() {
|
void render3dObjectMenu() {
|
||||||
if (ImGui::menuItem("Cube")) {
|
if (ImGui::menuItem("Cube")) {
|
||||||
Entity child = entity.createChild("node");
|
Entity child = entity.createChild("Cube");
|
||||||
MeshComponent childMesh = child.addComponent<MeshComponent>();
|
MeshComponent childMesh = child.addComponent<MeshComponent>();
|
||||||
childMesh.meshResource = Builtin::cube();
|
childMesh.meshResource = Builtin::cube();
|
||||||
childMesh.shader = Builtin::simpleShader();
|
childMesh.shader = Builtin::simpleShader();
|
||||||
@ -150,7 +150,7 @@ class EntityNodeUI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ImGui::menuItem("Sphere")) {
|
if (ImGui::menuItem("Sphere")) {
|
||||||
Entity child = entity.createChild("node");
|
Entity child = entity.createChild("Sphere");
|
||||||
MeshComponent childMesh = child.addComponent<MeshComponent>();
|
MeshComponent childMesh = child.addComponent<MeshComponent>();
|
||||||
childMesh.meshResource = Builtin::sphere();
|
childMesh.meshResource = Builtin::sphere();
|
||||||
childMesh.shader = Builtin::simpleShader();
|
childMesh.shader = Builtin::simpleShader();
|
||||||
|
|||||||
@ -9,6 +9,8 @@ class Viewport : Panel {
|
|||||||
float deltaAcomulated = 0;
|
float deltaAcomulated = 0;
|
||||||
float latestFrameRate;
|
float latestFrameRate;
|
||||||
|
|
||||||
|
int editMode = 0;
|
||||||
|
|
||||||
void onImGui() {
|
void onImGui() {
|
||||||
if (!frameBuffer.isValid())
|
if (!frameBuffer.isValid())
|
||||||
return;
|
return;
|
||||||
@ -33,7 +35,7 @@ class Viewport : Panel {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
frameBuffer.resize(x, y);
|
frameBuffer.resize(x, y);
|
||||||
frameBuffer.clearRGBA(200, 230, 250, 255);
|
frameBuffer.clearRGBA(20, 23, 25, 255);
|
||||||
|
|
||||||
sceneCamera.camera.aspect = float(x) / y;
|
sceneCamera.camera.aspect = float(x) / y;
|
||||||
World::render(frameBuffer, sceneCamera);
|
World::render(frameBuffer, sceneCamera);
|
||||||
@ -43,12 +45,26 @@ class Viewport : Panel {
|
|||||||
if(ActiveEntity::entity != World::getRoot()) {
|
if(ActiveEntity::entity != World::getRoot()) {
|
||||||
mat4 entityTransform = ActiveEntity::entity.getWorldMatrix();
|
mat4 entityTransform = ActiveEntity::entity.getWorldMatrix();
|
||||||
|
|
||||||
if (ImGui::manipulationTransform(sceneCamera, entityTransform, entityTransform, false)) {
|
if (editMode == 0 && ImGui::manipulationTransform(sceneCamera, entityTransform, entityTransform, false)) {
|
||||||
mat4 parentTransform = ActiveEntity::entity.parent.getWorldMatrix();
|
mat4 parentTransform = ActiveEntity::entity.parent.getWorldMatrix();
|
||||||
|
|
||||||
mat4 relativeMatrix = entityTransform.getRelativeMatrix(parentTransform);
|
mat4 relativeMatrix = entityTransform.getRelativeMatrix(parentTransform);
|
||||||
ActiveEntity::entity.getComponent<TransformComponent>().position = relativeMatrix.getPosition();
|
ActiveEntity::entity.getComponent<TransformComponent>().position = relativeMatrix.getPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (editMode == 1 && ImGui::manipulationRotation(sceneCamera, entityTransform, entityTransform, false)) {
|
||||||
|
mat4 parentTransform = ActiveEntity::entity.parent.getWorldMatrix();
|
||||||
|
|
||||||
|
mat4 relativeMatrix = entityTransform.getRelativeMatrix(parentTransform);
|
||||||
|
ActiveEntity::entity.getComponent<TransformComponent>().rotation = relativeMatrix.getRotation();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (editMode == 2 && ImGui::manipulationScale(sceneCamera, entityTransform, entityTransform, false)) {
|
||||||
|
mat4 parentTransform = ActiveEntity::entity.parent.getWorldMatrix();
|
||||||
|
|
||||||
|
mat4 relativeMatrix = entityTransform.getRelativeMatrix(parentTransform);
|
||||||
|
ActiveEntity::entity.getComponent<TransformComponent>().scale = relativeMatrix.getScale();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ImGui::isPanelActive())
|
if (!ImGui::isPanelActive())
|
||||||
@ -107,16 +123,28 @@ class Viewport : Panel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void onMenuBar() {
|
void onMenuBar() {
|
||||||
if (ImGui::menuItem("Start")) {
|
/*
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ImGui::menuItem("Viewport")) {
|
if (ImGui::menuItem("Viewport")) {
|
||||||
ImGui::openPopup("ViewportCameraProps", any());
|
ImGui::openPopup("ViewportCameraProps", any());
|
||||||
}
|
}*/
|
||||||
|
|
||||||
ImGui::simplePopup("ViewportCameraProps", SimpleFunction(this.viewportCameraProps));
|
ImGui::simplePopup("ViewportCameraProps", SimpleFunction(this.viewportCameraProps));
|
||||||
ImGui::textColor(0, 0.5f, 0,"" + latestFrameRate);
|
ImGui::textColor(0, 0.5f, 0,"" + int(latestFrameRate));
|
||||||
|
|
||||||
|
ImGui::drawComboEnd("##EditMode", "Translate", SimpleFunction(this.transformCombo));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void transformCombo () {
|
||||||
|
if (ImGui::drawComboItem("Translate", editMode == 0)) {
|
||||||
|
editMode = 0;
|
||||||
|
}
|
||||||
|
if (ImGui::drawComboItem("Rotate", editMode == 1)) {
|
||||||
|
editMode = 1;
|
||||||
|
}
|
||||||
|
if (ImGui::drawComboItem("Scale", editMode == 2)) {
|
||||||
|
editMode = 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void viewportCameraProps() {
|
void viewportCameraProps() {
|
||||||
|
|||||||
60
imgui.ini
60
imgui.ini
@ -1,6 +1,6 @@
|
|||||||
[Window][DockSpace Demo]
|
[Window][DockSpace Demo]
|
||||||
Pos=0,0
|
Pos=0,0
|
||||||
Size=1920,1011
|
Size=2560,1371
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
|
|
||||||
[Window][Debug##Default]
|
[Window][Debug##Default]
|
||||||
@ -12,17 +12,17 @@ Collapsed=0
|
|||||||
Pos=401,26
|
Pos=401,26
|
||||||
Size=940,653
|
Size=940,653
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000008,0
|
DockId=0x00000009,0
|
||||||
|
|
||||||
[Window][PropertiesPanel]
|
[Window][PropertiesPanel]
|
||||||
Pos=1347,26
|
Pos=1987,26
|
||||||
Size=573,654
|
Size=573,1014
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000006,0
|
DockId=0x00000006,0
|
||||||
|
|
||||||
[Window][ResourceExplorer]
|
[Window][ResourceExplorer]
|
||||||
Pos=0,682
|
Pos=0,1022
|
||||||
Size=1920,329
|
Size=2560,349
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000004,0
|
DockId=0x00000004,0
|
||||||
|
|
||||||
@ -39,25 +39,45 @@ Collapsed=0
|
|||||||
DockId=0x00000006,1
|
DockId=0x00000006,1
|
||||||
|
|
||||||
[Window][EntityTree]
|
[Window][EntityTree]
|
||||||
Pos=0,26
|
Pos=0,28
|
||||||
Size=406,654
|
Size=423,992
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000007,0
|
DockId=0x00000007,0
|
||||||
|
|
||||||
[Window][Viewport]
|
[Window][Viewport]
|
||||||
Pos=408,26
|
Pos=425,28
|
||||||
Size=937,654
|
Size=1513,992
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000008,0
|
DockId=0x00000009,0
|
||||||
|
|
||||||
|
[Window][Properties]
|
||||||
|
Pos=1940,28
|
||||||
|
Size=620,992
|
||||||
|
Collapsed=0
|
||||||
|
DockId=0x0000000A,0
|
||||||
|
|
||||||
|
[Window][Dear ImGui Demo]
|
||||||
|
Pos=425,28
|
||||||
|
Size=1513,992
|
||||||
|
Collapsed=0
|
||||||
|
DockId=0x00000009,1
|
||||||
|
|
||||||
|
[Window][Dear ImGui Style Editor]
|
||||||
|
Pos=425,28
|
||||||
|
Size=1513,992
|
||||||
|
Collapsed=0
|
||||||
|
DockId=0x00000009,2
|
||||||
|
|
||||||
[Docking][Data]
|
[Docking][Data]
|
||||||
DockSpace ID=0x0AC2E849 Window=0xD0388BC8 Pos=0,26 Size=1920,985 Split=Y
|
DockSpace ID=0x0AC2E849 Window=0xD0388BC8 Pos=0,28 Size=2560,1343 Split=Y
|
||||||
DockNode ID=0x00000003 Parent=0x0AC2E849 SizeRef=1920,654 Split=X
|
DockNode ID=0x00000003 Parent=0x0AC2E849 SizeRef=1920,662 Split=X
|
||||||
DockNode ID=0x00000001 Parent=0x00000003 SizeRef=399,985 Selected=0x16E3C1E7
|
DockNode ID=0x00000001 Parent=0x00000003 SizeRef=399,985 Selected=0x16E3C1E7
|
||||||
DockNode ID=0x00000002 Parent=0x00000003 SizeRef=1519,985 Split=X
|
DockNode ID=0x00000002 Parent=0x00000003 SizeRef=1519,985 Split=X
|
||||||
DockNode ID=0x00000005 Parent=0x00000002 SizeRef=1345,493 Split=X Selected=0xC450F867
|
DockNode ID=0x00000005 Parent=0x00000002 SizeRef=1345,493 Split=X Selected=0xC450F867
|
||||||
DockNode ID=0x00000007 Parent=0x00000005 SizeRef=406,653 Selected=0xA1816002
|
DockNode ID=0x00000007 Parent=0x00000005 SizeRef=423,653 Selected=0xA1816002
|
||||||
DockNode ID=0x00000008 Parent=0x00000005 SizeRef=937,653 CentralNode=1 Selected=0xC450F867
|
DockNode ID=0x00000008 Parent=0x00000005 SizeRef=2135,653 Split=X Selected=0xC450F867
|
||||||
DockNode ID=0x00000006 Parent=0x00000002 SizeRef=573,493 Selected=0x9876A79B
|
DockNode ID=0x00000009 Parent=0x00000008 SizeRef=1513,1014 CentralNode=1 Selected=0xC450F867
|
||||||
DockNode ID=0x00000004 Parent=0x0AC2E849 SizeRef=1920,329 Selected=0x018A0F9B
|
DockNode ID=0x0000000A Parent=0x00000008 SizeRef=620,1014 Selected=0x8C72BEA8
|
||||||
|
DockNode ID=0x00000006 Parent=0x00000002 SizeRef=573,493 Selected=0x9876A79B
|
||||||
|
DockNode ID=0x00000004 Parent=0x0AC2E849 SizeRef=1920,349 Selected=0x018A0F9B
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user