Physics Simulation & Visualization Tool 0.1
A C++ physics simulation engine with real-time 3D visualization
Loading...
Searching...
No Matches
Gizmo.h
Go to the documentation of this file.
1
6#pragma once
9#include "IHandle.h"
10
11#include "../core/IPickable.h"
12
13class SceneManager;
14class SceneObject;
15class Scene;
16
21enum class GizmoType {
23 ROTATE,
24 SCALE
25};
26
62class Gizmo : public ICustomDrawable, public IPickable{
63public:
73 Gizmo(GizmoType type, SceneManager* sceneManager, SceneObject* target);
74
78 ~Gizmo();
79
80 // ==================== ICustomDrawable ====================
91 void draw() const override;
92
97 uint32_t getObjectID() const override;
98
103 Mesh* getMesh() const override { return handleMesh; }
104
109 Shader* getShader() const override;
110
111 // ==================== IPickable ====================
123 std::optional<float> intersectsRay(const Math::Ray& ray) const override;
124
135 void handleClick(const Math::Ray& ray, float distance) override;
136
142 void setHovered(bool hovered) override;
143
148 bool getHovered() const override;
149
150 // ==================== Gizmo-Specific API ====================
156 void handleRelease();
157
165 void handleDrag(const Math::Ray& ray);
166
171 SceneObject* getTarget() const { return target; }
172
177 IHandle* getActiveHandle() const { return activeHandle; }
178
183 bool getIsDragging() const { return isDragging; }
184
185private:
186 Scene* ownerScene;
187 SceneObject* target;
188 std::vector<std::unique_ptr<IHandle>> handles;
189
190 mutable IHandle* hoveredHandle = nullptr;
191 IHandle* activeHandle = nullptr;
192
193 Shader* shader;
194 Mesh* handleMesh = nullptr;
195
196 uint32_t objectID;
197 bool isDragging = false;
198 bool isHovered = false;
199};
GizmoType
Types of transformation gizmos.
Definition Gizmo.h:21
Interface for interactive manipulation handles on gizmos.
Interactive 3D manipulation widget for transforming scene objects.
Definition Gizmo.h:62
void handleClick(const Math::Ray &ray, float distance) override
Handles mouse click on a gizmo handle.
Definition Gizmo.cpp:92
~Gizmo()
Destructor - frees object IDs and cleans up handles.
Definition Gizmo.cpp:41
bool getHovered() const override
Gets the gizmo's hover state.
Definition Gizmo.cpp:122
SceneObject * getTarget() const
Gets the object this gizmo is manipulating.
Definition Gizmo.h:171
uint32_t getObjectID() const override
Gets the gizmo's unique identifier.
Definition Gizmo.cpp:126
std::optional< float > intersectsRay(const Math::Ray &ray) const override
Tests if a ray intersects any of the gizmo's handles.
Definition Gizmo.cpp:68
void handleDrag(const Math::Ray &ray)
Updates the active handle during a drag operation.
Definition Gizmo.cpp:106
Mesh * getMesh() const override
Gets the shared mesh used for all handles.
Definition Gizmo.h:103
void draw() const override
Renders all handles with custom depth-test-disabled rendering.
Definition Gizmo.cpp:46
void handleRelease()
Handles mouse release - deactivates the active handle.
Definition Gizmo.cpp:101
void setHovered(bool hovered) override
Sets the gizmo's hover state.
Definition Gizmo.cpp:118
bool getIsDragging() const
Checks if a drag operation is in progress.
Definition Gizmo.h:183
Shader * getShader() const override
Gets the shader used for gizmo rendering.
Definition Gizmo.cpp:114
IHandle * getActiveHandle() const
Gets the currently active (being dragged) handle.
Definition Gizmo.h:177
Interface for objects with specialized rendering requirements.
Definition IDrawable.h:181
Abstract interface for gizmo manipulation handles.
Definition IHandle.h:47
Abstract interface for objects that can be selected and interacted with using the mouse.
Definition IPickable.h:28
GPU mesh representation with support for instanced rendering.
Definition Mesh.h:58
Definition Scene.h:11
Definition Shader.h:6
Represents a ray in 3D space.
Definition Ray.h:11