Improving the editor, ImGuizmo is now rendering guizmo's
- Added Guzimo's to the sceneview - Added new menu to the menubar - Improved multiple widgets (ImGui windows) - Added a new RuntimeControl widget (ImGui window) - New Screenshots
This commit is contained in:
@ -5,7 +5,7 @@
|
||||
class EditorWindow {
|
||||
|
||||
public:
|
||||
EditorWindow(const std::string& name ) { ImGui::Begin(name.c_str()); }
|
||||
EditorWindow(const std::string& name, ImGuiWindowFlags_ flags = ImGuiWindowFlags_None ) { ImGui::Begin(name.c_str(), false ,flags); }
|
||||
|
||||
|
||||
|
||||
|
@ -22,6 +22,7 @@ public:
|
||||
ImGui_ImplGlfw_InitForOpenGL(window.GetGLFWHandle(), true);
|
||||
ImGui_ImplOpenGL3_Init("#version 450");
|
||||
|
||||
ImGuizmo::SetImGuiContext(ImGui::GetCurrentContext());
|
||||
ImGuizmo::SetOrthographic(true);
|
||||
|
||||
}
|
||||
|
@ -138,6 +138,33 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void DebugMenu()
|
||||
{
|
||||
if (ImGui::BeginMenu("Debug")) {
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
}
|
||||
|
||||
void SelectMenu() {
|
||||
if (ImGui::BeginMenu("Select")) {
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
}
|
||||
|
||||
void WindowMenu() {
|
||||
if (ImGui::BeginMenu("Window")) {
|
||||
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
}
|
||||
|
||||
void Help() {
|
||||
if (ImGui::BeginMenu("Help")) {
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
~MainMenuBar() { ImGui::EndMainMenuBar(); }
|
||||
private:
|
||||
char* path = nullptr;
|
||||
|
@ -17,6 +17,11 @@
|
||||
typedef void ( *voidFunction ) (void);
|
||||
using namespace YoggieEngine;
|
||||
|
||||
auto matrix = glm::mat4(1.0f);
|
||||
auto worldOrigin = glm::mat4(1.0f);
|
||||
auto projection = glm::perspective(45.0f, 0.89f, 0.001f, 1.0f);
|
||||
auto view = glm::mat4(1.0f);
|
||||
|
||||
inline void ComponentView(const std::string& componentName, voidFunction func)
|
||||
{
|
||||
ImGuiWindowFlags_ window_flags = ImGuiWindowFlags_None;
|
||||
@ -123,28 +128,108 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class Viewport : EditorWindow {
|
||||
public:
|
||||
Viewport (Framebuffer& fb) : EditorWindow("SceneView") {
|
||||
ImGui::Image(
|
||||
Viewport (Framebuffer& fb, Camera cam ) : EditorWindow("SceneView")
|
||||
{
|
||||
ImVec2 WinPos = ImGui::GetWindowPos();
|
||||
ImVec2 ContentRegionMin = ImGui::GetWindowContentRegionMin();
|
||||
ImVec2 ContentRegionMax = ImGui::GetWindowContentRegionMax();
|
||||
ImVec2 ScreenSpaceMin = { ContentRegionMin.x + WinPos.x, ContentRegionMin.y + WinPos.y };
|
||||
ImVec2 ScreenSpaceMax = { ContentRegionMax.x + WinPos.x,ContentRegionMax.y + WinPos.y };
|
||||
|
||||
|
||||
ImGui::Image(
|
||||
(void*)(intptr_t)fb.GetColourAttachment(),
|
||||
ImVec2{ (float)ImGui::GetWindowWidth(),(float)ImGui::GetWindowHeight() }
|
||||
);
|
||||
|
||||
//ImGuizmo::SetDrawlist();
|
||||
//ImGuizmo::SetRect(ImGui::GetWindowPos().x, ImGui::GetWindowPos().y, ImGui::GetWindowWidth(), ImGui::GetWindowHeight());
|
||||
//ImGuizmo::Enable(true);
|
||||
//ImGuizmo::Manipulate(glm::value_ptr(view), glm::value_ptr(projection), ImGuizmo::TRANSLATE, ImGuizmo::WORLD, glm::value_ptr(trans));
|
||||
|
||||
ImGuizmo::Enable(true);
|
||||
ImGuizmo::SetRect(ScreenSpaceMin.x, ScreenSpaceMin.y,ContentRegionMax.x, ContentRegionMax.y);
|
||||
|
||||
ImGuizmo::ViewManipulate(glm::value_ptr(cam.ViewMatrix), 1, { ScreenSpaceMin.x,ScreenSpaceMin.y }, { 90,90 }, 0x22CCCCCC);
|
||||
ImGuizmo::DrawGrid(glm::value_ptr(cam.ViewMatrix), glm::value_ptr(cam.ProjectionMatrix), glm::value_ptr(worldOrigin), 100.0f);
|
||||
|
||||
// Matrix is the model matrix we would want to manipulate
|
||||
ImGuizmo::Manipulate(glm::value_ptr(cam.ViewMatrix), glm::value_ptr(cam.ProjectionMatrix), ImGuizmo::TRANSLATE, ImGuizmo::WORLD, glm::value_ptr(matrix));
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
int selectedGfxAPI = 0;
|
||||
int selectedPhysicsEngine = 0;
|
||||
glm::vec3 Gravity = glm::vec3(0.0f, -9.81f, 0.0f);
|
||||
bool ShowAdvancedOptions = false;
|
||||
bool DebugEngine = false;
|
||||
class Settings : EditorWindow {
|
||||
public:
|
||||
Settings() : EditorWindow("Settings") {
|
||||
ImGui::LabelText("##title-settings", "Fine grain control over your engine... ");
|
||||
Settings() : EditorWindow("Settings")
|
||||
{
|
||||
ImGui::LabelText("##title-settings", "Fine grain control over the engine!");
|
||||
|
||||
if (ImGui::BeginCombo("Graphics API", GraphicsAPI[selectedGfxAPI])) {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
bool isSelected = i == selectedGfxAPI;
|
||||
if (ImGui::Selectable(GraphicsAPI[i], isSelected)) {
|
||||
selectedGfxAPI = i;
|
||||
}
|
||||
|
||||
if(isSelected)
|
||||
ImGui::SetItemDefaultFocus();
|
||||
}
|
||||
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
|
||||
ImGui::NewLine();
|
||||
|
||||
if (ImGui::BeginCombo("Physics Engine", PhysicsEngine[selectedPhysicsEngine])) {
|
||||
for (int i = 0; i < 2; i++) {
|
||||
bool isSelected = i == selectedPhysicsEngine;
|
||||
if (ImGui::Selectable(PhysicsEngine[i], isSelected)) {
|
||||
selectedGfxAPI = i;
|
||||
}
|
||||
|
||||
if (isSelected)
|
||||
ImGui::SetItemDefaultFocus();
|
||||
}
|
||||
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
|
||||
ImGui::InputFloat3("Gravity", glm::value_ptr(Gravity));
|
||||
|
||||
ImGui::NewLine();
|
||||
if (ImGui::Button("Show Advanced options ")) {
|
||||
ShowAdvancedOptions = !ShowAdvancedOptions;
|
||||
}
|
||||
|
||||
if (ShowAdvancedOptions)
|
||||
{
|
||||
ImGui::Checkbox("Debug Engine", &DebugEngine);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
|
||||
const char* PhysicsEngine[2] = {
|
||||
"PhysX",
|
||||
"Jolt Physics"
|
||||
};
|
||||
|
||||
const char* GraphicsAPI[3] = {
|
||||
"OpenGL",
|
||||
"Vulkan",
|
||||
"Metal (Apple)"
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
class ProjectInfo : EditorWindow {
|
||||
@ -183,6 +268,9 @@ public:
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0.f, 0.f, 0.f, 0.f));
|
||||
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(1.f, 1.f, 1.f, 0.2f));
|
||||
|
||||
Texture folderIcon = Texture("rsc/folderIcon.png");
|
||||
Texture assetIcon = Texture("rsc/assetIcon.png");
|
||||
|
||||
|
||||
int row = 0;
|
||||
int column = 0;
|
||||
@ -197,14 +285,14 @@ public:
|
||||
|
||||
if (asset.isFolder) {
|
||||
ImGui::ImageButton(
|
||||
(ImTextureID)(Texture("rsc/folderIcon.png")).GetID(),
|
||||
(ImTextureID)folderIcon.GetID(),
|
||||
ImVec2{ (float)iconSize,(float)iconSize });
|
||||
ImGui::Text(asset.GetName(), row);
|
||||
|
||||
}
|
||||
else {
|
||||
ImGui::ImageButton(
|
||||
(ImTextureID)(Texture("rsc/assetIcon.png")).GetID(),
|
||||
(ImTextureID)assetIcon.GetID(),
|
||||
ImVec2{ (float)iconSize, (float)iconSize });
|
||||
ImGui::Text(asset.GetName(), row);
|
||||
|
||||
@ -217,12 +305,58 @@ public:
|
||||
|
||||
ImGui::PopStyleColor(3);
|
||||
ImGui::EndTable();
|
||||
const GLuint textures[2]{ assetIcon.GetID(), folderIcon.GetID() };
|
||||
glDeleteTextures(2, textures );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
private:
|
||||
static Texture folderIcon;
|
||||
static Texture AssetIcon;
|
||||
int iconSize = 60;
|
||||
};
|
||||
|
||||
#define RuntimeControlWindowFlags (ImGuiWindowFlags_)(ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse)
|
||||
|
||||
struct ButtonInfo {
|
||||
const char* Name;
|
||||
ImVec4 Color;
|
||||
};
|
||||
|
||||
|
||||
class RuntimeControls : EditorWindow {
|
||||
public:
|
||||
RuntimeControls() : EditorWindow("RuntimeControls", RuntimeControlWindowFlags) {
|
||||
|
||||
ImGui::SameLine((ImGui::GetWindowContentRegionMax().x / 2) - ( numButtons * buttonSize.x ));
|
||||
for (int i = 0; i < numButtons; i++) {
|
||||
ImVec4 color = button[i].Color;
|
||||
ImGui::PushStyleColor(ImGuiCol_Button, color);
|
||||
const float strengthIncrease = 1.5f;
|
||||
ImGui::PushStyleColor(
|
||||
ImGuiCol_ButtonHovered,
|
||||
ImVec4{
|
||||
color.x * strengthIncrease,
|
||||
color.y * strengthIncrease,
|
||||
color.z * strengthIncrease,
|
||||
color.w
|
||||
}
|
||||
);
|
||||
if (ImGui::Button(button[i].Name, buttonSize)) {
|
||||
|
||||
}
|
||||
ImGui::PopStyleColor();
|
||||
ImGui::PopStyleColor();
|
||||
ImGui::SameLine();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
ImVec2 buttonSize = ImVec2{ 90 ,25 };
|
||||
unsigned int numButtons = 2;
|
||||
ButtonInfo button[2] = {
|
||||
{"Play" , ImVec4{ 0.001 * 12 , 0.001 * 201 , 0.001* 69, 1.0f}},
|
||||
{"Simulate", ImVec4{ 0.001 * 14, 0.001 * 157, 0.001 * 201, 1.0f}}
|
||||
};
|
||||
|
||||
};
|
Reference in New Issue
Block a user