Skip to content
This repository was archived by the owner on Jun 11, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
ff283ce
Add picking shader program for object selection
saraazevedolopes May 13, 2025
6eea68a
Integrate picking shader into render pipeline manager
saraazevedolopes May 13, 2025
cd288ad
Add picking draw logic to entities, groups and scene
saraazevedolopes May 13, 2025
6ab2f67
Implement mouse picking and framebuffer setup in SceneWindow
saraazevedolopes May 13, 2025
c0badc3
Add drawRaw method to Model for picking rendering
saraazevedolopes May 13, 2025
4fa7979
Display selected entity ID in UI
saraazevedolopes May 13, 2025
5eb745e
Expose window handle and add support for ImGui integration
saraazevedolopes May 13, 2025
0a774a2
(maybe) fix lint warning
saraazevedolopes May 13, 2025
ad769b2
(maybe p.2) fix lint warning
saraazevedolopes May 13, 2025
f1ae2dd
(maybe p.3) fix lint error
saraazevedolopes May 13, 2025
2d013b8
(maybe p.4) fix lint error
saraazevedolopes May 13, 2025
374c8e8
format fix
saraazevedolopes May 13, 2025
f6923d6
Simplify object picking
voidbert May 14, 2025
9126a62
Add object picking to third person camera
voidbert May 14, 2025
d428f75
Fix override error lint
saraazevedolopes May 14, 2025
b961b1c
Fix useStlAlgorithm error lint
saraazevedolopes May 14, 2025
15395d6
Fix bug when camera is not third person
voidbert May 14, 2025
ab01d23
Add entity name support to picking
saraazevedolopes May 14, 2025
50fd446
Add entity name to menu
saraazevedolopes May 14, 2025
927a029
Cleanup object picking
voidbert May 16, 2025
ee17fff
Merge branch 'main' into OP2
voidbert May 16, 2025
1164d68
Add name generation to Solar System
voidbert May 16, 2025
b9c45b3
Regenerate Solar System
voidbert May 16, 2025
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
36 changes: 36 additions & 0 deletions include/engine/render/Framebuffer.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/// Copyright 2025 Ana Oliveira, Humberto Gomes, Mariana Rocha, Sara Lopes
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.

#include <array>
#include <cstdint>
#include <glad/glad.h>

namespace engine::render {

class Framebuffer {
private:
GLuint fbo, colorTexture, depthRenderBuffer;
int width, height;

public:
Framebuffer(int _width, int _height);
Framebuffer(const Framebuffer &framebuffer) = delete;
Framebuffer(Framebuffer &&framebuffer) = delete;
~Framebuffer();

void use();
std::array<uint8_t, 3> sample(int x, int y);
};

}
7 changes: 7 additions & 0 deletions include/engine/scene/Entity.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class Entity {
render::BoundingSphere boundingSphere;
std::shared_ptr<render::Texture> texture;
Material material;
std::string name;

public:
Entity(const tinyxml2::XMLElement *modelElement,
Expand All @@ -48,6 +49,12 @@ class Entity {
void updateBoundingSphere(const glm::mat4 &worldTransform);
const render::BoundingSphere &getBoundingSphere() const;
const render::NormalsPreview &getNormalsPreview() const;
const std::string &getName() const;

void drawSolidColor(render::RenderPipelineManager &pipelineManager,
const glm::mat4 &fullMatrix,
const glm::vec4 &color,
bool fillPolygons) const;

void draw(render::RenderPipelineManager &pipelineManager,
const glm::mat4 &fullMatrix,
Expand Down
7 changes: 7 additions & 0 deletions include/engine/scene/Group.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include <filesystem>
#include <glm/mat4x4.hpp>
#include <glm/vec4.hpp>
#include <memory>
#include <string>
#include <tinyxml2.h>
Expand Down Expand Up @@ -62,6 +63,12 @@ class Group {
const glm::mat4 &worldtransform,
bool fillPolygons) const;

int drawForPicking(render::RenderPipelineManager &pipelineManager,
const camera::Camera &camera,
const glm::mat4 &worldTransform,
std::unordered_map<int, std::string> &idToName,
int currentId) const;

private:
const render::BoundingSphere &getBoundingSphere() const;
void updateBoundingSphere(const glm::mat4 &worldTransform);
Expand Down
4 changes: 4 additions & 0 deletions include/engine/scene/Scene.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

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

#include "engine/render/Axis.hpp"
Expand Down Expand Up @@ -58,6 +59,9 @@ class Scene {
bool showBoundingSpheres,
bool showAnimationLines,
bool showNormals) const;

void drawForPicking(render::RenderPipelineManager &pipelineManager,
std::unordered_map<int, std::string> &idToName) const;
};

}
4 changes: 4 additions & 0 deletions include/engine/scene/camera/Camera.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <glm/mat4x4.hpp>
#include <glm/vec2.hpp>
#include <glm/vec3.hpp>
#include <unordered_map>

#include "engine/render/BoundingSphere.hpp"
#include "engine/render/RenderPipelineManager.hpp"
Expand Down Expand Up @@ -60,6 +61,9 @@ class Camera {
bool showNormals) const;
virtual int drawShadedParts(render::RenderPipelineManager &pipelineManager,
bool fillPolygons) const;
virtual int drawForPicking(render::RenderPipelineManager &pipelineManager,
std::unordered_map<int, std::string> &idToName,
int currentId) const;

bool isInFrustum(const render::BoundingSphere &sphere) const;

Expand Down
4 changes: 4 additions & 0 deletions include/engine/scene/camera/ThirdPersonCamera.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <glm/vec2.hpp>
#include <glm/vec3.hpp>
#include <memory>
#include <unordered_map>

#include "engine/scene/camera/OrbitalCamera.hpp"
#include "engine/scene/Group.hpp"
Expand Down Expand Up @@ -49,6 +50,9 @@ class ThirdPersonCamera : public OrbitalCamera {
bool showNormals) const override;
virtual int drawShadedParts(render::RenderPipelineManager &pipelineManager,
bool fillPolygons) const override;
virtual int drawForPicking(render::RenderPipelineManager &pipelineManager,
std::unordered_map<int, std::string> &idToName,
int currentId) const override;

protected:
virtual void updateWithMotion() override;
Expand Down
2 changes: 2 additions & 0 deletions include/engine/window/SceneWindow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class SceneWindow : public Window {
scene::camera::CameraController cameraController;

UI ui;
std::string selectedEntity;
bool showUI;

public:
Expand All @@ -41,6 +42,7 @@ class SceneWindow : public Window {
void onRender() override;
void onResize(int _width, int _height) override;
void onKeyEvent(int key, int action) override;
void onMouseButtonEvent(int button, int action) override;
};

}
4 changes: 2 additions & 2 deletions include/engine/window/UI.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ class UI {
showNormals;

public:
UI(Window &window, scene::camera::Camera &_camera, int _entityCount);
UI(const Window &window, scene::camera::Camera &_camera, int _entityCount);
~UI();

bool isCapturingKeyboard() const;
void draw(int renderedEntities);
void draw(int renderedEntities, const std::string &selectedEntity);

bool shouldFillPolygons() const;
bool shouldCullBackFaces() const;
Expand Down
3 changes: 2 additions & 1 deletion include/engine/window/Window.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,14 @@ class Window {

int getWidth() const;
int getHeight() const;
GLFWwindow *getHandle();
GLFWwindow *getHandle() const;

protected:
virtual void onUpdate(float time, float timeElapsed) = 0;
virtual void onRender() = 0;
virtual void onResize(int _width, int _height) = 0;
virtual void onKeyEvent(int key, int action) = 0;
virtual void onMouseButtonEvent(int button, int action) = 0;
};

}
Loading