From a86f44c718a8fac9c052c651b5e8a0180e8f8291 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BAlio=20Pinto?= Date: Mon, 27 May 2024 17:47:53 +0100 Subject: [PATCH] stuff --- engine/include/frustsum.hpp | 25 +++++++++++++++++++++++++ engine/src/frustsum.cpp | 4 +++- engine/src/main.cpp | 2 +- imgui.ini | 4 ++-- 4 files changed, 31 insertions(+), 4 deletions(-) diff --git a/engine/include/frustsum.hpp b/engine/include/frustsum.hpp index 37b4c13..11ba334 100644 --- a/engine/include/frustsum.hpp +++ b/engine/include/frustsum.hpp @@ -4,6 +4,7 @@ #include #include #include +#include #include "Window.hpp" #include "Camera.hpp" @@ -29,6 +30,19 @@ struct Plane { } + void drawPlane() { + // Draw the plane + glBegin(GL_QUADS); + glNormal3f(normal.x, normal.y, normal.z); + glVertex3f(point.x + 1000, point.y, point.z + 1000); + glVertex3f(point.x + 1000, point.y, point.z - 1000); + glVertex3f(point.x - 1000, point.y, point.z - 1000); + glVertex3f(point.x - 1000, point.y, point.z + 1000); + glEnd(); + } + + + }; struct Frustsum { @@ -61,6 +75,17 @@ struct Frustsum { bottomFace.printPlane(); } + void drawFrustsum() { + if (on) { + nearFace.drawPlane(); + farFace.drawPlane(); + rightFace.drawPlane(); + leftFace.drawPlane(); + topFace.drawPlane(); + bottomFace.drawPlane(); + } + } + }; diff --git a/engine/src/frustsum.cpp b/engine/src/frustsum.cpp index 9b32bae..0a83019 100644 --- a/engine/src/frustsum.cpp +++ b/engine/src/frustsum.cpp @@ -16,7 +16,7 @@ Frustsum::Frustsum(const Camera& cam, float ratio, bool on) { } float aspect = ratio; - glm::vec3 front = glm::normalize(cam.lookAt - cam.position); + glm::vec3 front = cam.forward; float fovRadians = glm::radians(static_cast(cam.fov)); float halfHSide = cam.far * tanf(fovRadians * 0.5f); @@ -51,6 +51,8 @@ Frustsum::Frustsum(const Camera& cam, float ratio, bool on) { leftFace = { leftNormal, leftPoint }; topFace = { topNormal, topPoint }; bottomFace = { bottomNormal, bottomPoint }; + + drawFrustsum(); } diff --git a/engine/src/main.cpp b/engine/src/main.cpp index fecfae8..17b0d0e 100644 --- a/engine/src/main.cpp +++ b/engine/src/main.cpp @@ -229,7 +229,7 @@ void renderScene(void) { lookat.x , lookat.y, lookat.z, camera.up.x, camera.up.y, camera.up.z); - Frustsum frustsum = Frustsum(camera, glutGet(GLUT_WINDOW_WIDTH) / glutGet(GLUT_WINDOW_HEIGHT), culling); + Frustsum frustsum = Frustsum(c.camera, c.window.width / c.window.height, culling); fillMode(); drawAxis(); diff --git a/imgui.ini b/imgui.ini index b89c56b..d760deb 100644 --- a/imgui.ini +++ b/imgui.ini @@ -6,12 +6,12 @@ Collapsed=0 [Window][Infos] Pos=15,18 Size=325,139 -Collapsed=0 +Collapsed=1 [Window][Options] Pos=15,169 Size=312,124 -Collapsed=0 +Collapsed=1 [Window][Models] Pos=17,306