-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGUIHelpers.cpp
More file actions
73 lines (65 loc) · 2.54 KB
/
GUIHelpers.cpp
File metadata and controls
73 lines (65 loc) · 2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#pragma once
#include "template.h"
#include "GUIHelpers.h"
#include "ImGuizmo.h"
float GUIHelpers::m_view[16];
float GUIHelpers::m_proj[16];
void GUIHelpers::NewPlainWindow(std::string name, float2 pos, float2 size, std::function<void()> render, float alpha, int id)
{
ImGui::PushID(id);
ImGui::SetNextWindowPos(ImVec2(pos.x, pos.y), ImGuiCond_Always);
ImGui::SetNextWindowSize(ImVec2(size.x, size.y), ImGuiCond_Always);
ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoDecoration |
ImGuiWindowFlags_NoNav |
ImGuiWindowFlags_NoSavedSettings;
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0.9f, 0.9f, 0.9f, alpha));
ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0.9f, 0.9f, 0.9f, 0.0f));
if (ImGui::Begin(UNIQ_IMGUI_LABEL(name, id), nullptr, window_flags))
{
ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32_BLACK);
render();
ImGui::PopStyleColor();
}
ImGui::End();
ImGui::PopID();
ImGui::PopStyleColor();
ImGui::PopStyleColor();
}
void GUIHelpers::NewNormalWindow(std::string name, float2 pos, float2 size, std::function<void()> render, int id)
{
ImGui::PushID(id);
ImGui::SetNextWindowPos(ImVec2(pos.x, pos.y), ImGuiCond_FirstUseEver);
ImGui::SetNextWindowSize(ImVec2(size.x, size.y), ImGuiCond_FirstUseEver);
if (ImGui::Begin(UNIQ_IMGUI_LABEL(name, id), nullptr))
{
render();
}
ImGui::End();
ImGui::PopID();
}
void GUIHelpers::DrawWireSphere(float3 pos, float radius, float3 color, float alpha, float thickness, int segments)
{
mat4 result = mat4::Identity();
result = mat4::Scale(radius) * result;
result = mat4::Translate(pos) * result;
ImGuizmo::DrawWireSphere(m_view, m_proj, result.Transposed().cell, float4(color, alpha), thickness, segments);
}
void GUIHelpers::DrawWireCube(float3 center, float3 size, float3 color, float alpha, float thickness)
{
mat4 result = mat4::Identity();
result = mat4::Scale(size) * result;
result = mat4::Translate(center) * result;
ImGuizmo::DrawWireCube(m_view, m_proj, result.Transposed().cell, float4(color, alpha), thickness);
}
void GUIHelpers::DrawLine(float3 start, float3 end, float3 color, float alpha, float thickness)
{
ImGuizmo::DrawLine(m_view, m_proj, start, end, float4(color, alpha), thickness);
}
void GUIHelpers::DrawWireCube(float3 center, float3 size, float3 forward, float3 up, float3 color, float alpha, float thickness)
{
mat4 result = mat4::Identity();
result = mat4::Scale(size) * result;
result = mat4::FromBasis(forward, up) * result;
result = mat4::Translate(center) * result;
ImGuizmo::DrawWireCube(m_view, m_proj, result.Transposed().cell, float4(color, alpha), thickness);
}