diff --git a/Editor/Editor.cpp b/Editor/Editor.cpp index 79a36eb56..5def632bd 100644 --- a/Editor/Editor.cpp +++ b/Editor/Editor.cpp @@ -20,6 +20,8 @@ #include "SpringWindow.h" #include "IKWindow.h" #include "TransformWindow.h" +#include "LayerWindow.h" +#include "NameWindow.h" #include "ModelImporter.h" #include "Translator.h" @@ -149,6 +151,8 @@ void EditorComponent::ChangeRenderPath(RENDERPATH path) springWnd = std::make_unique(this); ikWnd = std::make_unique(this); transformWnd = std::make_unique(this); + layerWnd = std::make_unique(this); + nameWnd = std::make_unique(this); ResizeBuffers(); } @@ -446,6 +450,28 @@ void EditorComponent::Load() }); GetGUI().AddWidget(transformWnd_Toggle); + wiButton* layerWnd_Toggle = new wiButton("Layer"); + layerWnd_Toggle->SetColor(option_color_idle, wiWidget::IDLE); + layerWnd_Toggle->SetColor(option_color_focus, wiWidget::FOCUS); + layerWnd_Toggle->SetTooltip("Layer Component"); + layerWnd_Toggle->SetPos(XMFLOAT2(x, y += step)); + layerWnd_Toggle->SetSize(option_size); + layerWnd_Toggle->OnClick([=](wiEventArgs args) { + layerWnd->window->SetVisible(!layerWnd->window->IsVisible()); + }); + GetGUI().AddWidget(layerWnd_Toggle); + + wiButton* nameWnd_Toggle = new wiButton("Name"); + nameWnd_Toggle->SetColor(option_color_idle, wiWidget::IDLE); + nameWnd_Toggle->SetColor(option_color_focus, wiWidget::FOCUS); + nameWnd_Toggle->SetTooltip("Name Component"); + nameWnd_Toggle->SetPos(XMFLOAT2(x, y += step)); + nameWnd_Toggle->SetSize(option_size); + nameWnd_Toggle->OnClick([=](wiEventArgs args) { + nameWnd->window->SetVisible(!nameWnd->window->IsVisible()); + }); + GetGUI().AddWidget(nameWnd_Toggle); + @@ -675,6 +701,8 @@ void EditorComponent::Load() springWnd->SetEntity(INVALID_ENTITY); ikWnd->SetEntity(INVALID_ENTITY); transformWnd->SetEntity(INVALID_ENTITY); + layerWnd->SetEntity(INVALID_ENTITY); + nameWnd->SetEntity(INVALID_ENTITY); }); GetGUI().AddWidget(clearButton); @@ -1521,6 +1549,8 @@ void EditorComponent::Update(float dt) springWnd->SetEntity(INVALID_ENTITY); ikWnd->SetEntity(INVALID_ENTITY); transformWnd->SetEntity(INVALID_ENTITY); + layerWnd->SetEntity(INVALID_ENTITY); + nameWnd->SetEntity(INVALID_ENTITY); } else { @@ -1550,6 +1580,8 @@ void EditorComponent::Update(float dt) springWnd->SetEntity(picked.entity); ikWnd->SetEntity(picked.entity); transformWnd->SetEntity(picked.entity); + layerWnd->SetEntity(picked.entity); + nameWnd->SetEntity(picked.entity); if (picked.subsetIndex >= 0) { diff --git a/Editor/Editor.h b/Editor/Editor.h index 27b13904e..2e61aa9f2 100644 --- a/Editor/Editor.h +++ b/Editor/Editor.h @@ -21,6 +21,8 @@ class PaintToolWindow; class SpringWindow; class IKWindow; class TransformWindow; +class LayerWindow; +class NameWindow; class EditorLoadingScreen : public LoadingScreen { @@ -58,6 +60,8 @@ public: std::unique_ptr springWnd; std::unique_ptr ikWnd; std::unique_ptr transformWnd; + std::unique_ptr layerWnd; + std::unique_ptr nameWnd; Editor* main = nullptr; diff --git a/Editor/Editor.vcxproj b/Editor/Editor.vcxproj index 199360831..4b28f7485 100644 --- a/Editor/Editor.vcxproj +++ b/Editor/Editor.vcxproj @@ -175,11 +175,13 @@ + + @@ -206,12 +208,14 @@ + + diff --git a/Editor/Editor.vcxproj.filters b/Editor/Editor.vcxproj.filters index c88a81494..9c1fc2aee 100644 --- a/Editor/Editor.vcxproj.filters +++ b/Editor/Editor.vcxproj.filters @@ -103,6 +103,12 @@ Code + + Code + + + Code + @@ -183,6 +189,12 @@ Code + + Code + + + Code + diff --git a/Editor/LayerWindow.cpp b/Editor/LayerWindow.cpp new file mode 100644 index 000000000..971384453 --- /dev/null +++ b/Editor/LayerWindow.cpp @@ -0,0 +1,90 @@ +#include "stdafx.h" +#include "LayerWindow.h" +#include "Editor.h" + +using namespace wiECS; +using namespace wiScene; + + +LayerWindow::LayerWindow(EditorComponent* editor) : GUI(&editor->GetGUI()) +{ + assert(GUI && "Invalid GUI!"); + + window = new wiWindow(GUI, "Layer Window"); + window->SetSize(XMFLOAT2(410, 160)); + GUI->AddWidget(window); + + float x = 30; + float y = 0; + float step = 25; + float siz = 20; + + for (uint32_t i = 0; i < 32; ++i) + { + layers[i] = new wiCheckBox(""); + layers[i]->SetText(std::to_string(i) + ": "); + layers[i]->SetPos(XMFLOAT2(x + (i % 8) * 50, y + (i / 8 + 1) * step)); + layers[i]->OnClick([=](wiEventArgs args) { + + LayerComponent* layer = wiScene::GetScene().layers.GetComponent(entity); + if (layer == nullptr) + { + layer = &wiScene::GetScene().layers.Create(entity); + } + + if (args.bValue) + { + layer->layerMask |= 1 << i; + } + else + { + layer->layerMask &= ~(1 << i); + } + + }); + window->AddWidget(layers[i]); + } + + window->Translate(XMFLOAT3((float)wiRenderer::GetDevice()->GetScreenWidth() - 450, 300, 0)); + window->SetVisible(false); + + SetEntity(INVALID_ENTITY); +} + + +LayerWindow::~LayerWindow() +{ + window->RemoveWidgets(true); + GUI->RemoveWidget(window); + delete window; +} + +void LayerWindow::SetEntity(Entity entity) +{ + this->entity = entity; + + if (entity != INVALID_ENTITY) + { + window->SetEnabled(true); + + LayerComponent* layer = wiScene::GetScene().layers.GetComponent(entity); + if (layer == nullptr) + { + for (uint32_t i = 0; i < 32; ++i) + { + layers[i]->SetCheck(true); + } + } + else + { + for (uint32_t i = 0; i < 32; ++i) + { + layers[i]->SetCheck(layer->GetLayerMask() & 1 << i); + } + } + } + else + { + window->SetEnabled(false); + } +} diff --git a/Editor/LayerWindow.h b/Editor/LayerWindow.h new file mode 100644 index 000000000..d6731ae1b --- /dev/null +++ b/Editor/LayerWindow.h @@ -0,0 +1,29 @@ +#pragma once + +class wiGUI; +class wiWindow; +class wiLabel; +class wiCheckBox; +class wiSlider; +class wiComboBox; +class wiColorPicker; +class wiTextInputField; + +class EditorComponent; + +class LayerWindow +{ +public: + LayerWindow(EditorComponent* editor); + ~LayerWindow(); + + wiECS::Entity entity; + void SetEntity(wiECS::Entity entity); + + wiGUI* GUI; + + wiWindow* window; + + wiCheckBox* layers[32]; +}; + diff --git a/Editor/NameWindow.cpp b/Editor/NameWindow.cpp new file mode 100644 index 000000000..64beb3214 --- /dev/null +++ b/Editor/NameWindow.cpp @@ -0,0 +1,70 @@ +#include "stdafx.h" +#include "NameWindow.h" +#include "Editor.h" + +using namespace wiECS; +using namespace wiScene; + + +NameWindow::NameWindow(EditorComponent* editor) : GUI(&editor->GetGUI()) +{ + assert(GUI && "Invalid GUI!"); + + window = new wiWindow(GUI, "Name Window"); + window->SetSize(XMFLOAT2(360, 80)); + GUI->AddWidget(window); + + float x = 60; + float y = 0; + float step = 25; + float siz = 280; + float hei = 20; + + nameInput = new wiTextInputField(""); + nameInput->SetDescription("Name: "); + nameInput->SetPos(XMFLOAT2(x, y += step)); + nameInput->SetSize(XMFLOAT2(siz, hei)); + nameInput->OnInputAccepted([&](wiEventArgs args) { + NameComponent* name = wiScene::GetScene().names.GetComponent(entity); + if (name == nullptr) + { + name = &wiScene::GetScene().names.Create(entity); + } + name->name = args.sValue; + }); + window->AddWidget(nameInput); + + window->Translate(XMFLOAT3((float)wiRenderer::GetDevice()->GetScreenWidth() - 450, 200, 0)); + window->SetVisible(false); + + SetEntity(INVALID_ENTITY); +} + + +NameWindow::~NameWindow() +{ + window->RemoveWidgets(true); + GUI->RemoveWidget(window); + delete window; +} + +void NameWindow::SetEntity(Entity entity) +{ + this->entity = entity; + + if (entity != INVALID_ENTITY) + { + window->SetEnabled(true); + + NameComponent* name = wiScene::GetScene().names.GetComponent(entity); + if (name != nullptr) + { + nameInput->SetValue(name->name); + } + } + else + { + window->SetEnabled(false); + nameInput->SetValue("Select entity to modify name..."); + } +} diff --git a/Editor/NameWindow.h b/Editor/NameWindow.h new file mode 100644 index 000000000..96551b69f --- /dev/null +++ b/Editor/NameWindow.h @@ -0,0 +1,29 @@ +#pragma once + +class wiGUI; +class wiWindow; +class wiLabel; +class wiCheckBox; +class wiSlider; +class wiComboBox; +class wiColorPicker; +class wiTextInputField; + +class EditorComponent; + +class NameWindow +{ +public: + NameWindow(EditorComponent* editor); + ~NameWindow(); + + wiECS::Entity entity; + void SetEntity(wiECS::Entity entity); + + wiGUI* GUI; + + wiWindow* window; + + wiTextInputField* nameInput; +}; + diff --git a/Editor/TransformWindow.cpp b/Editor/TransformWindow.cpp index 4501c0c68..af773b737 100644 --- a/Editor/TransformWindow.cpp +++ b/Editor/TransformWindow.cpp @@ -11,7 +11,7 @@ TransformWindow::TransformWindow(EditorComponent* editor) : GUI(&editor->GetGUI( assert(GUI && "Invalid GUI!"); window = new wiWindow(GUI, "Transform Window"); - window->SetSize(XMFLOAT2(460, 150)); + window->SetSize(XMFLOAT2(460, 170)); GUI->AddWidget(window); float x = 100; @@ -33,6 +33,35 @@ TransformWindow::TransformWindow(EditorComponent* editor) : GUI(&editor->GetGUI( }); window->AddWidget(createButton); + parentCombo = new wiComboBox("Parent: "); + parentCombo->SetSize(XMFLOAT2(330, hei)); + parentCombo->SetPos(XMFLOAT2(x, y += step)); + parentCombo->SetEnabled(false); + parentCombo->OnSelect([&](wiEventArgs args) { + Scene& scene = wiScene::GetScene(); + HierarchyComponent* hier = scene.hierarchy.GetComponent(entity); + + if (args.iValue == 0 && hier != nullptr) + { + scene.hierarchy.Remove_KeepSorted(entity); + } + else if(args.iValue != 0) + { + if (hier == nullptr) + { + hier = &scene.hierarchy.Create(entity); + } + hier->parentID = scene.transforms.GetEntity(args.iValue - 1); + if (hier->parentID == entity) + { + scene.hierarchy.Remove_KeepSorted(entity); + } + } + + }); + parentCombo->SetTooltip("Choose a parent entity for the transform"); + window->AddWidget(parentCombo); + txInput = new wiTextInputField(""); txInput->SetValue(0); txInput->SetDescription("Translation X: "); @@ -81,7 +110,7 @@ TransformWindow::TransformWindow(EditorComponent* editor) : GUI(&editor->GetGUI( x = 250; - y = step; + y = step * 2; rxInput = new wiTextInputField(""); @@ -148,7 +177,7 @@ TransformWindow::TransformWindow(EditorComponent* editor) : GUI(&editor->GetGUI( x = 400; - y = step; + y = step * 2; sxInput = new wiTextInputField(""); @@ -214,10 +243,33 @@ void TransformWindow::SetEntity(Entity entity) { this->entity = entity; - const TransformComponent* transform = wiScene::GetScene().transforms.GetComponent(entity); + Scene& scene = wiScene::GetScene(); + const TransformComponent* transform = scene.transforms.GetComponent(entity); if (transform != nullptr) { + parentCombo->ClearItems(); + parentCombo->AddItem("NO PARENT"); + + HierarchyComponent* hier = scene.hierarchy.GetComponent(entity); + for (size_t i = 0; i < scene.transforms.GetCount(); ++i) + { + Entity entity = scene.transforms.GetEntity(i); + std::string str; + const NameComponent* name = scene.names.GetComponent(entity); + if (name != nullptr) + { + str = name->name; + } + str = str + " (" + std::to_string(entity) + ")"; + parentCombo->AddItem(str); + + if (hier != nullptr && hier->parentID == entity) + { + parentCombo->SetSelected((int)i + 1); + } + } + txInput->SetValue(transform->translation_local.x); tyInput->SetValue(transform->translation_local.y); tzInput->SetValue(transform->translation_local.z); diff --git a/Editor/TransformWindow.h b/Editor/TransformWindow.h index 6b5aea7ca..c5f994f30 100644 --- a/Editor/TransformWindow.h +++ b/Editor/TransformWindow.h @@ -26,6 +26,8 @@ public: wiButton* createButton; + wiComboBox* parentCombo; + wiTextInputField* txInput; wiTextInputField* tyInput; wiTextInputField* tzInput; diff --git a/Editor/WeatherWindow.cpp b/Editor/WeatherWindow.cpp index 7d1a97d8d..092ec5a04 100644 --- a/Editor/WeatherWindow.cpp +++ b/Editor/WeatherWindow.cpp @@ -180,9 +180,9 @@ WeatherWindow::WeatherWindow(EditorComponent* editor) : GUI(&editor->GetGUI()) preset1Button->OnClick([=](wiEventArgs args) { auto& weather = GetWeather(); - weather.ambient = XMFLOAT3(0.1f, 0.1f, 0.1f); - weather.horizon = XMFLOAT3(0.3f, 0.3f, 0.4f); - weather.zenith = XMFLOAT3(37.0f / 255.0f, 61.0f / 255.0f, 142.0f / 255.0f); + weather.ambient = XMFLOAT3(33.0f / 255.0f, 47.0f / 255.0f, 127.0f / 255.0f); + weather.horizon = XMFLOAT3(101.0f / 255.0f, 101.0f / 255.0f, 227.0f / 255.0f); + weather.zenith = XMFLOAT3(99.0f / 255.0f, 133.0f / 255.0f, 255.0f / 255.0f); weather.cloudiness = 0.4f; weather.fogStart = 100; weather.fogEnd = 1000; @@ -200,9 +200,9 @@ WeatherWindow::WeatherWindow(EditorComponent* editor) : GUI(&editor->GetGUI()) preset2Button->OnClick([=](wiEventArgs args) { auto& weather = GetWeather(); - weather.ambient = XMFLOAT3(0.02f, 0.02f, 0.02f); - weather.horizon = XMFLOAT3(0.2f, 0.05f, 0.15f); - weather.zenith = XMFLOAT3(0.4f, 0.05f, 0.1f); + weather.ambient = XMFLOAT3(86.0f / 255.0f, 29.0f / 255.0f, 29.0f / 255.0f); + weather.horizon = XMFLOAT3(121.0f / 255.0f, 28.0f / 255.0f, 22.0f / 255.0f); + weather.zenith = XMFLOAT3(146.0f / 255.0f, 51.0f / 255.0f, 51.0f / 255.0f); weather.cloudiness = 0.36f; weather.fogStart = 50; weather.fogEnd = 600; @@ -240,9 +240,9 @@ WeatherWindow::WeatherWindow(EditorComponent* editor) : GUI(&editor->GetGUI()) preset4Button->OnClick([=](wiEventArgs args) { auto& weather = GetWeather(); - weather.ambient = XMFLOAT3(0.01f, 0.01f, 0.02f); - weather.horizon = XMFLOAT3(0.04f, 0.1f, 0.2f); - weather.zenith = XMFLOAT3(0.02f, 0.04f, 0.08f); + weather.ambient = XMFLOAT3(12.0f / 255.0f, 21.0f / 255.0f, 77.0f / 255.0f); + weather.horizon = XMFLOAT3(10.0f / 255.0f, 33.0f / 255.0f, 70.0f / 255.0f); + weather.zenith = XMFLOAT3(4.0f / 255.0f,20.0f / 255.0f, 51.0f / 255.0f); weather.cloudiness = 0.28f; weather.fogStart = 10; weather.fogEnd = 400; diff --git a/WickedEngine/wiGUI.cpp b/WickedEngine/wiGUI.cpp index 41cdfb097..fe5231c34 100644 --- a/WickedEngine/wiGUI.cpp +++ b/WickedEngine/wiGUI.cpp @@ -116,7 +116,7 @@ void wiGUI::Update(float dt) for (auto& widget : priorityChangeQueue) { - if (std::find(widgets.begin(), widgets.end(), widget) != widgets.end()) + if (std::find(widgets.begin(), widgets.end(), widget) != widgets.end()) // only add back to widgets if it's still there! { widgets.remove(widget); widgets.push_front(widget); @@ -191,11 +191,9 @@ wiWidget* wiGUI::GetWidget(const wiHashString& name) void wiGUI::ActivateWidget(wiWidget* widget) { - if (std::find(widgets.begin(), widgets.end(), widget) != widgets.end()) - { - widget->priority_change = false; - priorityChangeQueue.push_back(widget); - } + widget->priority_change = false; + priorityChangeQueue.push_back(widget); + if (activeWidget == nullptr) { activeWidget = widget; diff --git a/WickedEngine/wiVersion.cpp b/WickedEngine/wiVersion.cpp index ce202bb96..5645939a7 100644 --- a/WickedEngine/wiVersion.cpp +++ b/WickedEngine/wiVersion.cpp @@ -9,7 +9,7 @@ namespace wiVersion // minor features, major updates const int minor = 39; // minor bug fixes, alterations, refactors, updates - const int revision = 62; + const int revision = 63; long GetVersion() diff --git a/models/Sponza/sponza.wiscene b/models/Sponza/sponza.wiscene index 107539500..fc1c21f16 100644 Binary files a/models/Sponza/sponza.wiscene and b/models/Sponza/sponza.wiscene differ