Files
WickedEngine/Editor/WorldWindow.cpp
T
2017-12-20 14:37:28 +01:00

106 lines
3.0 KiB
C++

#include "stdafx.h"
#include "WorldWindow.h"
WorldWindow::WorldWindow(wiGUI* gui) : GUI(gui)
{
assert(GUI && "Invalid GUI!");
float screenW = (float)wiRenderer::GetDevice()->GetScreenWidth();
float screenH = (float)wiRenderer::GetDevice()->GetScreenHeight();
worldWindow = new wiWindow(GUI, "World Window");
worldWindow->SetSize(XMFLOAT2(760, 820));
GUI->AddWidget(worldWindow);
float x = 200;
float y = 20;
float step = 30;
fogStartSlider = new wiSlider(0, 5000, 0, 100000, "Fog Start: ");
fogStartSlider->SetSize(XMFLOAT2(100, 30));
fogStartSlider->SetPos(XMFLOAT2(x, y += step));
fogStartSlider->OnSlide([&](wiEventArgs args) {
wiRenderer::GetScene().worldInfo.fogSEH.x = args.fValue;
});
worldWindow->AddWidget(fogStartSlider);
fogEndSlider = new wiSlider(1, 5000, 1000, 10000, "Fog End: ");
fogEndSlider->SetSize(XMFLOAT2(100, 30));
fogEndSlider->SetPos(XMFLOAT2(x, y += step));
fogEndSlider->OnSlide([&](wiEventArgs args) {
wiRenderer::GetScene().worldInfo.fogSEH.y = args.fValue;
});
worldWindow->AddWidget(fogEndSlider);
fogHeightSlider = new wiSlider(0, 1, 0, 10000, "Fog Height: ");
fogHeightSlider->SetSize(XMFLOAT2(100, 30));
fogHeightSlider->SetPos(XMFLOAT2(x, y += step));
fogHeightSlider->OnSlide([&](wiEventArgs args) {
wiRenderer::GetScene().worldInfo.fogSEH.z = args.fValue;
});
worldWindow->AddWidget(fogHeightSlider);
ambientColorPicker = new wiColorPicker(GUI, "Ambient Color");
ambientColorPicker->SetPos(XMFLOAT2(360, 40));
ambientColorPicker->RemoveWidgets();
ambientColorPicker->SetVisible(false);
ambientColorPicker->SetEnabled(true);
ambientColorPicker->OnColorChanged([&](wiEventArgs args) {
wiRenderer::GetScene().worldInfo.ambient = XMFLOAT3(args.color.x, args.color.y, args.color.z);
});
worldWindow->AddWidget(ambientColorPicker);
horizonColorPicker = new wiColorPicker(GUI, "Horizon Color");
horizonColorPicker->SetPos(XMFLOAT2(360, 300));
horizonColorPicker->RemoveWidgets();
horizonColorPicker->SetVisible(false);
horizonColorPicker->SetEnabled(true);
horizonColorPicker->OnColorChanged([&](wiEventArgs args) {
wiRenderer::GetScene().worldInfo.horizon = XMFLOAT3(args.color.x, args.color.y, args.color.z);
});
worldWindow->AddWidget(horizonColorPicker);
zenithColorPicker = new wiColorPicker(GUI, "Zenith Color");
zenithColorPicker->SetPos(XMFLOAT2(360, 560));
zenithColorPicker->RemoveWidgets();
zenithColorPicker->SetVisible(false);
zenithColorPicker->SetEnabled(true);
zenithColorPicker->OnColorChanged([&](wiEventArgs args) {
wiRenderer::GetScene().worldInfo.zenith = XMFLOAT3(args.color.x, args.color.y, args.color.z);
});
worldWindow->AddWidget(zenithColorPicker);
worldWindow->Translate(XMFLOAT3(30, 30, 0));
worldWindow->SetVisible(false);
}
WorldWindow::~WorldWindow()
{
worldWindow->RemoveWidgets(true);
GUI->RemoveWidget(worldWindow);
SAFE_DELETE(worldWindow);
}
void WorldWindow::UpdateFromRenderer()
{
auto& w = wiRenderer::GetScene().worldInfo;
fogStartSlider->SetValue(w.fogSEH.x);
fogEndSlider->SetValue(w.fogSEH.y);
fogHeightSlider->SetValue(w.fogSEH.z);
}