Temporary remove not yet supported transformations from 3D gizmos
This commit is contained in:
parent
4479c5444a
commit
a97df55592
@ -1140,6 +1140,9 @@ bool GLCanvas3D::Gizmos::init(GLCanvas3D& parent)
|
||||
if (!gizmo->init())
|
||||
return false;
|
||||
|
||||
// temporary disable z grabber
|
||||
gizmo->disable_grabber(2);
|
||||
|
||||
m_gizmos.insert(GizmosMap::value_type(Move, gizmo));
|
||||
|
||||
gizmo = new GLGizmoScale3D(parent);
|
||||
@ -1149,6 +1152,16 @@ bool GLCanvas3D::Gizmos::init(GLCanvas3D& parent)
|
||||
if (!gizmo->init())
|
||||
return false;
|
||||
|
||||
// temporary disable x grabbers
|
||||
gizmo->disable_grabber(0);
|
||||
gizmo->disable_grabber(1);
|
||||
// temporary disable y grabbers
|
||||
gizmo->disable_grabber(2);
|
||||
gizmo->disable_grabber(3);
|
||||
// temporary disable z grabbers
|
||||
gizmo->disable_grabber(4);
|
||||
gizmo->disable_grabber(5);
|
||||
|
||||
m_gizmos.insert(GizmosMap::value_type(Scale, gizmo));
|
||||
|
||||
gizmo = new GLGizmoRotate3D(parent);
|
||||
@ -1164,6 +1177,10 @@ bool GLCanvas3D::Gizmos::init(GLCanvas3D& parent)
|
||||
return false;
|
||||
}
|
||||
|
||||
// temporary disable x and y grabbers
|
||||
gizmo->disable_grabber(0);
|
||||
gizmo->disable_grabber(1);
|
||||
|
||||
m_gizmos.insert(GizmosMap::value_type(Rotate, gizmo));
|
||||
|
||||
gizmo = new GLGizmoFlatten(parent);
|
||||
|
@ -110,6 +110,7 @@ GLGizmoBase::Grabber::Grabber()
|
||||
: center(Vec3d::Zero())
|
||||
, angles(Vec3d::Zero())
|
||||
, dragging(false)
|
||||
, enabled(true)
|
||||
{
|
||||
color[0] = 1.0f;
|
||||
color[1] = 1.0f;
|
||||
@ -234,6 +235,22 @@ void GLGizmoBase::set_highlight_color(const float* color)
|
||||
::memcpy((void*)m_highlight_color, (const void*)color, 3 * sizeof(float));
|
||||
}
|
||||
|
||||
void GLGizmoBase::enable_grabber(unsigned int id)
|
||||
{
|
||||
if ((0 <= id) && (id < (unsigned int)m_grabbers.size()))
|
||||
m_grabbers[id].enabled = true;
|
||||
|
||||
on_enable_grabber(id);
|
||||
}
|
||||
|
||||
void GLGizmoBase::disable_grabber(unsigned int id)
|
||||
{
|
||||
if ((0 <= id) && (id < (unsigned int)m_grabbers.size()))
|
||||
m_grabbers[id].enabled = false;
|
||||
|
||||
on_disable_grabber(id);
|
||||
}
|
||||
|
||||
void GLGizmoBase::start_dragging(const BoundingBoxf3& box)
|
||||
{
|
||||
m_dragging = true;
|
||||
@ -278,6 +295,7 @@ void GLGizmoBase::render_grabbers() const
|
||||
{
|
||||
for (int i = 0; i < (int)m_grabbers.size(); ++i)
|
||||
{
|
||||
if (m_grabbers[i].enabled)
|
||||
m_grabbers[i].render(m_hover_id == i);
|
||||
}
|
||||
}
|
||||
@ -285,6 +303,8 @@ void GLGizmoBase::render_grabbers() const
|
||||
void GLGizmoBase::render_grabbers_for_picking() const
|
||||
{
|
||||
for (unsigned int i = 0; i < (unsigned int)m_grabbers.size(); ++i)
|
||||
{
|
||||
if (m_grabbers[i].enabled)
|
||||
{
|
||||
m_grabbers[i].color[0] = 1.0f;
|
||||
m_grabbers[i].color[1] = 1.0f;
|
||||
@ -292,6 +312,7 @@ void GLGizmoBase::render_grabbers_for_picking() const
|
||||
m_grabbers[i].render_for_picking();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GLGizmoBase::set_tooltip(const std::string& tooltip) const
|
||||
{
|
||||
@ -386,6 +407,9 @@ void GLGizmoRotate::on_update(const Linef3& mouse_ray)
|
||||
|
||||
void GLGizmoRotate::on_render(const BoundingBoxf3& box) const
|
||||
{
|
||||
if (!m_grabbers[0].enabled)
|
||||
return;
|
||||
|
||||
if (m_dragging)
|
||||
set_tooltip(format(m_angle * 180.0f / (float)PI, 4));
|
||||
else
|
||||
@ -789,12 +813,21 @@ void GLGizmoScale3D::on_render(const BoundingBoxf3& box) const
|
||||
::glColor3fv(m_base_color);
|
||||
render_box(m_box);
|
||||
// draw connections
|
||||
if (m_grabbers[0].enabled && m_grabbers[1].enabled)
|
||||
{
|
||||
::glColor3fv(m_grabbers[0].color);
|
||||
render_grabbers_connection(0, 1);
|
||||
}
|
||||
if (m_grabbers[2].enabled && m_grabbers[3].enabled)
|
||||
{
|
||||
::glColor3fv(m_grabbers[2].color);
|
||||
render_grabbers_connection(2, 3);
|
||||
}
|
||||
if (m_grabbers[4].enabled && m_grabbers[5].enabled)
|
||||
{
|
||||
::glColor3fv(m_grabbers[4].color);
|
||||
render_grabbers_connection(4, 5);
|
||||
}
|
||||
// draw grabbers
|
||||
render_grabbers();
|
||||
}
|
||||
@ -1073,6 +1106,8 @@ void GLGizmoMove3D::on_render(const BoundingBoxf3& box) const
|
||||
{
|
||||
// draw axes
|
||||
for (unsigned int i = 0; i < 3; ++i)
|
||||
{
|
||||
if (m_grabbers[i].enabled)
|
||||
{
|
||||
::glColor3fv(AXES_COLOR[i]);
|
||||
::glBegin(GL_LINES);
|
||||
@ -1080,6 +1115,7 @@ void GLGizmoMove3D::on_render(const BoundingBoxf3& box) const
|
||||
::glVertex3f((GLfloat)m_grabbers[i].center(0), (GLfloat)m_grabbers[i].center(1), (GLfloat)m_grabbers[i].center(2));
|
||||
::glEnd();
|
||||
}
|
||||
}
|
||||
|
||||
// draw grabbers
|
||||
render_grabbers();
|
||||
|
@ -28,6 +28,7 @@ protected:
|
||||
Vec3d center;
|
||||
Vec3d angles;
|
||||
float color[3];
|
||||
bool enabled;
|
||||
bool dragging;
|
||||
|
||||
Grabber();
|
||||
@ -83,6 +84,9 @@ public:
|
||||
|
||||
void set_highlight_color(const float* color);
|
||||
|
||||
void enable_grabber(unsigned int id);
|
||||
void disable_grabber(unsigned int id);
|
||||
|
||||
void start_dragging(const BoundingBoxf3& box);
|
||||
void stop_dragging();
|
||||
bool is_dragging() const { return m_dragging; }
|
||||
@ -96,6 +100,8 @@ protected:
|
||||
virtual bool on_init() = 0;
|
||||
virtual void on_set_state() {}
|
||||
virtual void on_set_hover_id() {}
|
||||
virtual void on_enable_grabber(unsigned int id) {}
|
||||
virtual void on_disable_grabber(unsigned int id) {}
|
||||
virtual void on_start_dragging(const BoundingBoxf3& box) {}
|
||||
virtual void on_stop_dragging() {}
|
||||
virtual void on_update(const Linef3& mouse_ray) = 0;
|
||||
@ -196,6 +202,16 @@ protected:
|
||||
m_gizmos[i].set_hover_id((m_hover_id == i) ? 0 : -1);
|
||||
}
|
||||
}
|
||||
virtual void on_enable_grabber(unsigned int id)
|
||||
{
|
||||
if ((0 <= id) && (id < 3))
|
||||
m_gizmos[id].enable_grabber(0);
|
||||
}
|
||||
virtual void on_disable_grabber(unsigned int id)
|
||||
{
|
||||
if ((0 <= id) && (id < 3))
|
||||
m_gizmos[id].disable_grabber(0);
|
||||
}
|
||||
virtual void on_start_dragging(const BoundingBoxf3& box);
|
||||
virtual void on_stop_dragging();
|
||||
virtual void on_update(const Linef3& mouse_ray)
|
||||
|
Loading…
Reference in New Issue
Block a user