editor, gui and sponza update

This commit is contained in:
turanszkij
2020-04-14 21:49:42 +01:00
parent 57d0cea6e5
commit 68147e6203
14 changed files with 342 additions and 20 deletions
+32
View File
@@ -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<SpringWindow>(this);
ikWnd = std::make_unique<IKWindow>(this);
transformWnd = std::make_unique<TransformWindow>(this);
layerWnd = std::make_unique<LayerWindow>(this);
nameWnd = std::make_unique<NameWindow>(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)
{
+4
View File
@@ -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<SpringWindow> springWnd;
std::unique_ptr<IKWindow> ikWnd;
std::unique_ptr<TransformWindow> transformWnd;
std::unique_ptr<LayerWindow> layerWnd;
std::unique_ptr<NameWindow> nameWnd;
Editor* main = nullptr;
+4
View File
@@ -175,11 +175,13 @@
<ClInclude Include="HairParticleWindow.h" />
<ClInclude Include="IKWindow.h" />
<ClInclude Include="json.hpp" />
<ClInclude Include="LayerWindow.h" />
<ClInclude Include="LightWindow.h" />
<ClInclude Include="main.h" />
<ClInclude Include="MaterialWindow.h" />
<ClInclude Include="MeshWindow.h" />
<ClInclude Include="ModelImporter.h" />
<ClInclude Include="NameWindow.h" />
<ClInclude Include="ObjectWindow.h" />
<ClInclude Include="PaintToolWindow.h" />
<ClInclude Include="PostprocessWindow.h" />
@@ -206,12 +208,14 @@
<ClCompile Include="ForceFieldWindow.cpp" />
<ClCompile Include="HairParticleWindow.cpp" />
<ClCompile Include="IKWindow.cpp" />
<ClCompile Include="LayerWindow.cpp" />
<ClCompile Include="LightWindow.cpp" />
<ClCompile Include="main.cpp" />
<ClCompile Include="MaterialWindow.cpp" />
<ClCompile Include="MeshWindow.cpp" />
<ClCompile Include="ModelImporter_GLTF.cpp" />
<ClCompile Include="ModelImporter_OBJ.cpp" />
<ClCompile Include="NameWindow.cpp" />
<ClCompile Include="ObjectWindow.cpp" />
<ClCompile Include="PaintToolWindow.cpp" />
<ClCompile Include="PostprocessWindow.cpp" />
+12
View File
@@ -103,6 +103,12 @@
<ClInclude Include="IKWindow.h">
<Filter>Code</Filter>
</ClInclude>
<ClInclude Include="NameWindow.h">
<Filter>Code</Filter>
</ClInclude>
<ClInclude Include="LayerWindow.h">
<Filter>Code</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="CameraWindow.cpp">
@@ -183,6 +189,12 @@
<ClCompile Include="SpringWindow.cpp">
<Filter>Code</Filter>
</ClCompile>
<ClCompile Include="NameWindow.cpp">
<Filter>Code</Filter>
</ClCompile>
<ClCompile Include="LayerWindow.cpp">
<Filter>Code</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Image Include="small.ico">
+90
View File
@@ -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);
}
}
+29
View File
@@ -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];
};
+70
View File
@@ -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...");
}
}
+29
View File
@@ -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;
};
+56 -4
View File
@@ -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);
+2
View File
@@ -26,6 +26,8 @@ public:
wiButton* createButton;
wiComboBox* parentCombo;
wiTextInputField* txInput;
wiTextInputField* tyInput;
wiTextInputField* tzInput;
+9 -9
View File
@@ -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;
+4 -6
View File
@@ -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;
+1 -1
View File
@@ -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()
Binary file not shown.