Radium Engine  1.5.20
Loading...
Searching...
No Matches
Gizmo.hpp
1#pragma once
2
3#include <vector>
4
5#include <Core/Types.hpp>
6#include <Core/Utils/Color.hpp>
7#include <Core/Utils/Index.hpp>
8
9#include <Core/Asset/Camera.hpp>
10#include <Engine/Data/RenderParameters.hpp>
11#include <Engine/RadiumEngine.hpp>
12#include <Engine/Rendering/RenderObject.hpp>
13#include <Engine/Scene/CameraComponent.hpp>
14
15namespace Ra {
16namespace Engine {
17
18namespace Data {
19class PlainMaterial;
20} // namespace Data
21
22namespace Scene {
23class Component;
24} // namespace Scene
25
26namespace Rendering {
27class RenderTechnique;
28class RenderObject;
29} // namespace Rendering
30} // namespace Engine
31
32namespace Gui {
41class Gizmo
42{
43 public:
44 enum Mode {
45 LOCAL,
46 GLOBAL,
47 };
48
49 public:
51 const Core::Transform& worldTo,
52 const Core::Transform& t,
53 Mode mode );
54
55 virtual ~Gizmo();
56
57 // shows or hides the gizmos drawables.
58 void show( bool on );
59
61 virtual void
62 updateTransform( Mode mode, const Core::Transform& worldTo, const Core::Transform& t ) = 0;
63
65 virtual void selectConstraint( int drawableIndex ) = 0;
66
68 virtual bool isSelected() = 0;
69
72 virtual void setInitialState( const Core::Asset::Camera& cam,
73 const Core::Vector2& initialXY ) = 0;
74
77 virtual Core::Transform mouseMove( const Core::Asset::Camera& cam,
78 const Core::Vector2& nextXY,
79 bool stepped = false,
80 bool whole = false ) = 0;
81
82 protected:
84 static bool findPointOnAxis( const Core::Asset::Camera& cam,
85 const Core::Vector3& origin,
86 const Core::Vector3& axis,
87 const Core::Vector2& pix,
88 Core::Vector3& pointOut,
89 std::vector<Scalar>& hits );
90
92 static bool findPointOnPlane( const Core::Asset::Camera& cam,
93 const Core::Vector3& origin,
94 const Core::Vector3& axis,
95 const Core::Vector2& pix,
96 Core::Vector3& pointOut,
97 std::vector<Scalar>& hits );
98
100 inline const std::vector<Engine::Rendering::RenderObject*>& ros() const { return m_ros; }
101
104
112
118
119 protected:
120 Core::Transform m_worldTo;
121 Core::Transform m_transform;
123 Mode m_mode;
124
135 {
136 public:
138 explicit UiSelectionControler(
140 const Core::Utils::Color& selectedColor = Core::Utils::Color::Yellow() );
141 UiSelectionControler() = delete;
143 ~UiSelectionControler() override = default;
145 void updateGL() override;
147 void toggleState();
149 void setState();
151 void clearState();
152
153 private:
157 Core::Utils::Color m_selectedColor;
159 bool m_selected { false };
160 };
161
164
165 private:
167};
168} // namespace Gui
169} // namespace Ra
Camera class storing the Camera frame and the projection properties The view direction is -z in camer...
Definition Camera.hpp:16
Shader program parameter provider.
A component is an element that can be updated by a system. It is also linked to some other components...
Definition Component.hpp:31
void setState()
Set the state of the controler to true.
Definition Gizmo.cpp:121
void toggleState()
Swap the state of the controler.
Definition Gizmo.cpp:117
void clearState()
Set the state of the controler to false.
Definition Gizmo.cpp:125
void updateGL() override
Inherited.
Definition Gizmo.cpp:110
static std::array< std::shared_ptr< Ra::Engine::Data::PlainMaterial >, 3 > s_material
Definition Gizmo.hpp:117
Mode m_mode
local or global.
Definition Gizmo.hpp:123
virtual void updateTransform(Mode mode, const Core::Transform &worldTo, const Core::Transform &t)=0
Called every time the underlying transform may have changed.
static bool findPointOnAxis(const Core::Asset::Camera &cam, const Core::Vector3 &origin, const Core::Vector3 &axis, const Core::Vector2 &pix, Core::Vector3 &pointOut, std::vector< Scalar > &hits)
Find a mouse-designed point on a 3D axis.
Definition Gizmo.cpp:51
const std::vector< Engine::Rendering::RenderObject * > & ros() const
read access to the gizmo render objects id
Definition Gizmo.hpp:100
Core::Transform m_worldTo
World to local space where the transform lives.
Definition Gizmo.hpp:120
static bool findPointOnPlane(const Core::Asset::Camera &cam, const Core::Vector3 &origin, const Core::Vector3 &axis, const Core::Vector2 &pix, Core::Vector3 &pointOut, std::vector< Scalar > &hits)
Find a mouse-designed point on a 3D plane.
Definition Gizmo.cpp:70
static std::shared_ptr< Engine::Rendering::RenderTechnique > makeRenderTechnique(int color)
Definition Gizmo.cpp:88
virtual void selectConstraint(int drawableIndex)=0
Called when one of the drawables of the gizmo has been selected.
Core::Transform m_transform
Transform to be edited.
Definition Gizmo.hpp:121
void addRenderObject(Engine::Rendering::RenderObject *ro)
add a render object to display the Gizmo
Definition Gizmo.cpp:83
virtual void setInitialState(const Core::Asset::Camera &cam, const Core::Vector2 &initialXY)=0
virtual bool isSelected()=0
return the selection state of the gizmo: true if the gizmo is selected, false if not.
Gizmo::UiSelectionControler * getControler(int ro)
Returns the controler (ShaderParametersProvider) associated to the given gizmo component.
Definition Gizmo.cpp:97
virtual Core::Transform mouseMove(const Core::Asset::Camera &cam, const Core::Vector2 &nextXY, bool stepped=false, bool whole=false)=0
Engine::Scene::Component * m_comp
Engine Ui component.
Definition Gizmo.hpp:122
hepler function to manage enum as underlying types in VariableSet
Definition Cage.cpp:3