Added display of editor camera position #368
|
@ -121,12 +121,22 @@ namespace SHADE
|
|||
|
||||
//auto pos = ImGui::GetCursorPos();
|
||||
//windowCursorPos = {}
|
||||
|
||||
if (beginContentRegionAvailable.x == 0 || beginContentRegionAvailable.y == 0)
|
||||
{
|
||||
beginContentRegionAvailable = windowSize;
|
||||
}
|
||||
gfxSystem->PrepareResize(static_cast<uint32_t>(beginContentRegionAvailable.x), static_cast<uint32_t>(beginContentRegionAvailable.y));
|
||||
|
||||
//beginContentRegionAvailable = CalculateWindowSize(beginContentRegionAvailable);
|
||||
SHVec2 viewportSize = CalculateWindowSize(beginContentRegionAvailable);
|
||||
gfxSystem->PrepareResize(static_cast<uint32_t>(viewportSize.x), static_cast<uint32_t>(viewportSize.y));
|
||||
shouldUpdateCamera = true;
|
||||
//if (aspectRatio != AspectRatio::FREE && (ImGui::IsMouseDown(ImGuiMouseButton_Left) || ImGui::IsMouseReleased(ImGuiMouseButton_Left)))
|
||||
//{
|
||||
// windowSize = CalculateWindowSize(windowSize);
|
||||
// beginContentRegionAvailable = CalculateWindowSize(beginContentRegionAvailable);
|
||||
// ImGui::SetWindowSize(windowName.data(), CalculateWindowSize(windowSize));
|
||||
//}
|
||||
}
|
||||
|
||||
void SHEditorViewport::OnPosChange()
|
||||
|
@ -194,13 +204,73 @@ namespace SHADE
|
|||
ImGui::PopStyleColor();
|
||||
ImGui::EndDisabled();
|
||||
|
||||
//TODO: Shift to constructor
|
||||
auto arRTTRtype = rttr::type::get<SHEditorViewport::AspectRatio>();
|
||||
auto enumAlign = arRTTRtype.get_enumeration();
|
||||
auto names = enumAlign.get_names();
|
||||
std::vector<const char*> arNames;
|
||||
for (auto const& name : names)
|
||||
{
|
||||
arNames.push_back(name.data());
|
||||
}
|
||||
int currentAR = static_cast<int>(aspectRatio);
|
||||
ImGui::SetNextItemWidth(80.0f);
|
||||
if (ImGui::Combo("Aspect Ratio", ¤tAR, arNames.data(), arNames.size()))
|
||||
{
|
||||
aspectRatio = static_cast<AspectRatio>(currentAR);
|
||||
windowSize = CalculateWindowSize(windowSize);
|
||||
ImGui::SetWindowSize(windowSize);
|
||||
//beginContentRegionAvailable = CalculateWindowSize(beginContentRegionAvailable);
|
||||
//OnResize();
|
||||
}
|
||||
|
||||
auto camSystem = SHSystemManager::GetSystem<SHCameraSystem>();
|
||||
auto editorCamera = camSystem->GetEditorCamera();
|
||||
//ImGui::SetNextItemWidth(10.0f);
|
||||
SHEditorWidgets::SliderFloat("CamSpeed", 0.0f, 5.0f, [editorCamera] {return editorCamera->movementSpeed; }, [editorCamera](float const& value) {editorCamera->movementSpeed = value; });
|
||||
SHEditorWidgets::DragVec3("TurnSpeed", { "X", "Y", "Z" }, [editorCamera] {return editorCamera->turnSpeed; }, [editorCamera](SHVec3 const& value) {editorCamera->turnSpeed = value; });
|
||||
|
||||
//if(ImGui::BeginCombo("Aspect Ratio", arNames[(uint8_t)aspectRatio].data()))
|
||||
//{
|
||||
// auto nameIt = names.begin();
|
||||
// auto valueIt = values.end();
|
||||
// while(nameIt != names.end() && valueIt != values.end())
|
||||
// {
|
||||
// if ImGui::Beg
|
||||
// }
|
||||
//}
|
||||
|
||||
ImGui::EndMenuBar();
|
||||
}
|
||||
}
|
||||
|
||||
SHVec2 SHEditorViewport::CalculateWindowSize(SHVec2 const& rhs) noexcept
|
||||
{
|
||||
switch (aspectRatio)
|
||||
{
|
||||
case SHADE::SHEditorViewport::AspectRatio::FREE:
|
||||
return rhs;
|
||||
case SHADE::SHEditorViewport::AspectRatio::AR16_9:
|
||||
return SHVec2(rhs.x, rhs.x * 0.5625f);
|
||||
case SHADE::SHEditorViewport::AspectRatio::AR21_9:
|
||||
return SHVec2(rhs.x, rhs.x * 0.42857f);
|
||||
case SHADE::SHEditorViewport::AspectRatio::AR21_10:
|
||||
return SHVec2(rhs.x, rhs.x * 0.47619f);
|
||||
default:
|
||||
return rhs;
|
||||
}
|
||||
}
|
||||
|
||||
}//namespace SHADE
|
||||
|
||||
RTTR_REGISTRATION
|
||||
{
|
||||
using namespace rttr;
|
||||
using namespace SHADE;
|
||||
registration::enumeration<SHEditorViewport::AspectRatio>("AspectRatio")(
|
||||
value("FREE", SHEditorViewport::AspectRatio::FREE),
|
||||
value("16:9", SHEditorViewport::AspectRatio::AR16_9),
|
||||
value("21:9", SHEditorViewport::AspectRatio::AR21_9),
|
||||
value("21:10", SHEditorViewport::AspectRatio::AR21_10)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -16,7 +16,15 @@ namespace SHADE
|
|||
{
|
||||
class SHEditorViewport final : public SHEditorWindow
|
||||
{
|
||||
|
||||
public:
|
||||
enum class AspectRatio : uint8_t
|
||||
{
|
||||
FREE,
|
||||
AR16_9,
|
||||
AR21_9,
|
||||
AR21_10
|
||||
};
|
||||
SHEditorViewport();
|
||||
void Init() override;
|
||||
void Update() override;
|
||||
|
@ -27,9 +35,12 @@ namespace SHADE
|
|||
void OnPosChange() override;
|
||||
private:
|
||||
void DrawMenuBar() noexcept;
|
||||
SHVec2 beginCursorPos;
|
||||
SHVec2 CalculateWindowSize(SHVec2 const& rhs) noexcept;
|
||||
|
||||
bool shouldUpdateCamera = false;
|
||||
bool shouldUpdateCamArm = false;
|
||||
AspectRatio aspectRatio {AspectRatio::FREE};
|
||||
SHVec2 beginCursorPos;
|
||||
SHVec3 targetPos;
|
||||
};//class SHEditorViewport
|
||||
}//namespace SHADE
|
||||
|
|
Loading…
Reference in New Issue