Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI tab bars #75

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added include/Fonts/Icons/fa-regular-400.ttf
Binary file not shown.
Binary file added include/Fonts/Icons/fa-solid-900.ttf
Binary file not shown.
1,416 changes: 1,416 additions & 0 deletions include/Fonts/Icons/icons_font_awesome_6.h

Large diffs are not rendered by default.

89 changes: 66 additions & 23 deletions include/core/camera.h
Original file line number Diff line number Diff line change
@@ -1,48 +1,81 @@
#pragma once
#include <iostream>
#include <ostream>
#include <glm/glm.hpp>
#include <glm/detail/type_quat.hpp>
#include <glm/gtc/matrix_transform.hpp>

#include "fmt/format.h"

class Camera
{
private:
float fovy;
float aspect;
glm::vec3 center;
glm::vec3 eye;
glm::vec3 up;
float focusDistance;
glm::vec3 Position;
glm::quat Rotation;
glm::vec3 EularRotation;

public:

Camera(const int width, const int height): fovy(45.0f),
aspect(float(width)/ float(height)),
center(glm::vec3(0.0f, 0.0f, 0.0f)),
eye(glm::vec3(0.0f, 0.0f, 4.0f)),
up(glm::vec3(0.0f, 1.0f, 0.0f)) {}
aspect(static_cast<float>(width)/ static_cast<float>(height)),
focusDistance(1.0f),
Position(glm::vec3(0.0f, 0.0f, 4.0f)),
Rotation(glm::quat(1.0f, 0.0f, 0.0f, 0.0f)) {}

Camera(): Camera(1920, 1080){}

inline glm::mat4 GetViewMatrix() const
{
//glm::vec3 viewDir = center - eye;
//up = glm::normalize(glm::cross(up, viewDir));
return glm::lookAt(eye, center, up);
return glm::lookAt(Position, GetCenter(), GetUpVec());
}

inline glm::mat4 GetProjectionMatrix() const
{
return glm::perspective(glm::radians(fovy), aspect, 0.1f, 100.0f);
}

inline glm::vec3 GetEye() const
inline float GetFovy() const
{
return fovy;
}

inline float GetAspect() const
{
return aspect;
}

inline float GetFocusDist() const
{
return focusDistance;
}

inline glm::vec3 GetPosition() const
{
return eye;
return Position;
}

inline glm::vec3 GetCenter(){
return center;
inline glm::vec3 GetEularRotation() const
{
return EularRotation;
}

inline glm::vec3 GetUpVec(){
return up;
inline glm::quat GetRotation() const {
return Rotation;
}

inline glm::vec3 GetCenter() const
{
glm::vec3 t = glm::cross(2.f *glm::vec3(Rotation.x,Rotation.y,Rotation.z), glm::vec3(0,0,focusDistance));
return Position + glm::vec3(0,0,focusDistance) + Rotation.w * t + cross(glm::vec3(Rotation.x,Rotation.y,Rotation.z), t);
}

inline glm::vec3 GetUpVec() const
{
glm::vec3 t = glm::cross(2.f *glm::vec3(Rotation.x,Rotation.y,Rotation.z), glm::vec3(0,1,0));
return glm::vec3(0,1,0) + Rotation.w * t + cross(glm::vec3(Rotation.x,Rotation.y,Rotation.z), t);
}

inline void SetAspect(const int width, const int height)
Expand All @@ -55,16 +88,26 @@ class Camera
fovy = glm::radians(_fovy);
}

inline void SetEye(const glm::vec3 _eye)
inline void SetFocusDist(const float _focusDistance)
{
eye = _eye;
focusDistance = _focusDistance;
}

inline void SetCenter(const glm::vec3 _center){
center = _center;
inline void SetPosition(const glm::vec3 _pos)
{
Position = _pos;
}

inline void SetUpVec(const glm::vec3 _upVect){
up = _upVect;
inline void SetRotation(const glm::vec3& eulerAngles)
{
EularRotation = eulerAngles;
glm::vec3 radianAngles = glm::radians(eulerAngles); // Convert degrees to radians

// Convert Euler angles to quaternion (YXZ Order)
Rotation = glm::quat(glm::vec3(radianAngles.x, radianAngles.y, radianAngles.z));

// Normalize to avoid floating point drift
Rotation = glm::normalize(Rotation);
}
};

};
4 changes: 0 additions & 4 deletions include/core/game_engine.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
#pragma once

#include <vector>
#include <memory>
#include <unordered_map>

#include "game_object.h"
#include "components/material.h"
#include "components/transform.h"
Expand Down
5 changes: 4 additions & 1 deletion include/core/scene.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@ class Scene {
static int randomId;
public:
std::shared_ptr<GameObject> selectedGameObj = nullptr;
bool mOrL; // Model or Light object

std::shared_ptr<Camera> selectedCamera = nullptr;
bool mOrL;

int current_shader = 1;

Scene() = default;
std::vector<std::shared_ptr<GameObject>>& GetModels()
Expand Down
12 changes: 0 additions & 12 deletions include/gui/CameraDebugWindow.h

This file was deleted.

2 changes: 1 addition & 1 deletion include/gui/MenuBar.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@

class MenuBar{
public:
void ShowMenuBar(bool &ShowDetail, bool &ShowView, bool &ShowHierarchy, bool &ShowCameraDebug);
void ShowMenuBar(bool &ShowDetail, bool &ShowView, bool &ShowHierarchy);
};
6 changes: 4 additions & 2 deletions include/gui/Viewport.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#pragma once

#include "imgui.h"
#include <GL/glew.h>
#include <GLFW/glfw3.h>

#include "imgui.h"

class Viewport{
public:
void ShowViewport(ImVec2 window_Size);
void ShowViewport(unsigned int& textureColorbuffer);
};
8 changes: 4 additions & 4 deletions include/gui/gui_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,16 @@
#if defined(IMGUI_IMPL_OPENGL_ES2)
#include <GLES2/gl2.h>
#endif
#include <GLFW/glfw3.h> // Will drag system OpenGL headers
#include "core/game_engine.h"
#include "core/camera.h"

// Window classes
#include "AddObjectWindow.h"
#include "CameraDebugWindow.h"
#include "Details.h"
#include "Viewport.h"
#include "FileHierarchy.h"
#include "MenuBar.h"
#include "secondary_menu_bar.h"

class GuiEngine
{
Expand All @@ -28,6 +27,7 @@ class GuiEngine
GLFWwindow* window;
GameEngine* gameEngine;
ImFont* inter_24;
ImFont* icons;
bool showDetail = true;
bool showHierarchy = true;
bool showCameraWindow = false;
Expand All @@ -41,14 +41,14 @@ class GuiEngine
FileHierarchy fileHierarchy;
Details details;
MenuBar menuBar;
CameraDebugWindow cameraDebugWindow;
AddObjectWindow addObjectWindow;
SecondMenuBar secondMenuBar;

public:
bool showView = true;
GuiEngine() = default;
~GuiEngine() = default;
bool init(GLFWwindow *window , GameEngine *_game_engine);
void run(int width, int height);
void run(unsigned int& texture, unsigned int& rbo);
void cleanup();
};
8 changes: 8 additions & 0 deletions include/gui/secondary_menu_bar.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#pragma once

#include "imgui.h"

class SecondMenuBar{
public:
void ShowSecondaryMenuBar();
};
Loading