From 6ef5642e63ea89b4245828560e4d149c0518b97e Mon Sep 17 00:00:00 2001 From: brunoherbelin Date: Sun, 13 Sep 2020 10:31:40 +0200 Subject: [PATCH] Added visual indicator of current rotation in geometryview --- CMakeLists.txt | 1 + Decorations.cpp | 1 + Decorations.h | 2 +- View.cpp | 35 +++++++++++++++++++++++++++++------ View.h | 1 + rsc/mesh/icon_clock_hand.ply | 20 ++++++++++++++++++++ 6 files changed, 53 insertions(+), 7 deletions(-) create mode 100644 rsc/mesh/icon_clock_hand.ply diff --git a/CMakeLists.txt b/CMakeLists.txt index fd2b5d4..99a3f0e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -317,6 +317,7 @@ set(VMIX_RSC_FILES ./rsc/mesh/icon_square.ply ./rsc/mesh/icon_cross.ply ./rsc/mesh/icon_clock.ply + ./rsc/mesh/icon_clock_hand.ply ./rsc/mesh/icon_grid.ply ./rsc/mesh/h_line.ply ./rsc/mesh/h_mark.ply diff --git a/Decorations.cpp b/Decorations.cpp index d062f44..db388ed 100644 --- a/Decorations.cpp +++ b/Decorations.cpp @@ -317,6 +317,7 @@ Symbol::Symbol(Type t, glm::vec3 pos) : Node(), type_(t) icons[UNLOCK] = new Mesh("mesh/icon_unlock.ply"); icons[CIRCLE] = new Mesh("mesh/icon_circle.ply"); icons[CLOCK] = new Mesh("mesh/icon_clock.ply"); + icons[CLOCK_H] = new Mesh("mesh/icon_clock_hand.ply"); icons[SQUARE] = new Mesh("mesh/icon_square.ply"); icons[CROSS] = new Mesh("mesh/icon_cross.ply"); icons[GRID] = new Mesh("mesh/icon_grid.ply"); diff --git a/Decorations.h b/Decorations.h index bb1708d..893ec8d 100644 --- a/Decorations.h +++ b/Decorations.h @@ -60,7 +60,7 @@ protected: class Symbol : public Node { public: - typedef enum { CIRCLE_POINT = 0, SQUARE_POINT, IMAGE, VIDEO, SESSION, CLONE, RENDER, DOTS, BUSY, LOCK, UNLOCK, CIRCLE, SQUARE, CLOCK, GRID, CROSS, EMPTY } Type; + typedef enum { CIRCLE_POINT = 0, SQUARE_POINT, IMAGE, VIDEO, SESSION, CLONE, RENDER, DOTS, BUSY, LOCK, UNLOCK, CIRCLE, SQUARE, CLOCK, CLOCK_H, GRID, CROSS, EMPTY } Type; Symbol(Type t = CIRCLE_POINT, glm::vec3 pos = glm::vec3(0.f)); ~Symbol(); diff --git a/View.cpp b/View.cpp index 08e2083..c6e8b52 100644 --- a/View.cpp +++ b/View.cpp @@ -654,6 +654,10 @@ GeometryView::GeometryView() : View(GEOMETRY) scene.fg()->attach(overlay_rotation_clock_); overlay_rotation_clock_->visible_ = false; // circle to show fixed-size ROTATION + overlay_rotation_clock_hand_ = new Symbol(Symbol::CLOCK_H); + overlay_rotation_clock_hand_->scale_ = glm::vec3(0.25f, 0.25f, 1.f); + scene.fg()->attach(overlay_rotation_clock_hand_); + overlay_rotation_clock_hand_->visible_ = false; overlay_rotation_fix_ = new Symbol(Symbol::SQUARE); overlay_rotation_fix_->scale_ = glm::vec3(0.25f, 0.25f, 1.f); scene.fg()->attach(overlay_rotation_fix_); @@ -836,6 +840,13 @@ View::Cursor GeometryView::grab (Source *s, glm::vec2 from, glm::vec2 to, std::p // inform on which corner should be overlayed (opposite) s->handle_[Handles::RESIZE]->overlayActiveCorner(-corner); +// overlay_scaling_grid_->visible_ = false; +// glm::vec4 icon = corner_to_scene_transform * glm::vec4(0.f, 0.f, 0.f, 1.f); +// overlay_scaling_grid_->translation_.x = icon.x; +// overlay_scaling_grid_->translation_.y = icon.y; +// overlay_scaling_grid_->rotation_.z = s->stored_status_->rotation_.z; +// overlay_scaling_grid_->update(0); + // RESIZE CORNER // proportional SCALING with SHIFT if (UserInterface::manager().shiftModifier()) { @@ -974,8 +985,9 @@ View::Cursor GeometryView::grab (Source *s, glm::vec2 from, glm::vec2 to, std::p overlay_scaling_grid_->visible_ = true; overlay_scaling_grid_->copyTransform(overlay_scaling_); } - // show cursor depending on diagonal (corner picked) - ret.type = Cursor_ResizeNWSE; + // show cursor depending on diagonal + corner = glm::sign(sourceNode->scale_); + ret.type = (corner.x * corner.y) > 0.f ? Cursor_ResizeNWSE : Cursor_ResizeNESW; info << "Size " << std::fixed << std::setprecision(3) << sourceNode->scale_.x; info << " x " << sourceNode->scale_.y; } @@ -983,12 +995,13 @@ View::Cursor GeometryView::grab (Source *s, glm::vec2 from, glm::vec2 to, std::p else if ( pick.first == s->handle_[Handles::ROTATE] ) { // ROTATION on CENTER - overlay_rotation_clock_->visible_ = false; - overlay_rotation_fix_->visible_ = true; overlay_rotation_->visible_ = true; overlay_rotation_->translation_.x = s->stored_status_->translation_.x; overlay_rotation_->translation_.y = s->stored_status_->translation_.y; overlay_rotation_->update(0); + overlay_rotation_fix_->visible_ = true; + overlay_rotation_fix_->copyTransform(overlay_rotation_); + overlay_rotation_clock_->visible_ = false; // rotation center to center of source (disregarding scale) glm::mat4 T = glm::translate(glm::identity(), s->stored_status_->translation_); @@ -998,6 +1011,7 @@ View::Cursor GeometryView::grab (Source *s, glm::vec2 from, glm::vec2 to, std::p float angle = glm::orientedAngle( glm::normalize(glm::vec2(source_from)), glm::normalize(glm::vec2(source_to))); // apply rotation on Z axis sourceNode->rotation_ = s->stored_status_->rotation_ + glm::vec3(0.f, 0.f, angle); + // POST-CORRECTION ; discretized rotation with ALT int degrees = int( glm::degrees(sourceNode->rotation_.z) ); if (UserInterface::manager().altModifier()) { @@ -1005,10 +1019,19 @@ View::Cursor GeometryView::grab (Source *s, glm::vec2 from, glm::vec2 to, std::p sourceNode->rotation_.z = glm::radians( float(degrees) ); overlay_rotation_clock_->visible_ = true; overlay_rotation_clock_->copyTransform(overlay_rotation_); + info << "Angle " << degrees << "\u00b0"; // degree symbol } + else + info << "Angle " << std::fixed << std::setprecision(1) << glm::degrees(sourceNode->rotation_.z) << "\u00b0"; // degree symbol + + overlay_rotation_clock_hand_->visible_ = true; + overlay_rotation_clock_hand_->translation_.x = s->stored_status_->translation_.x; + overlay_rotation_clock_hand_->translation_.y = s->stored_status_->translation_.y; + overlay_rotation_clock_hand_->rotation_.z = sourceNode->rotation_.z; + overlay_rotation_clock_hand_->update(0); + // show cursor for rotation ret.type = Cursor_Hand; - info << "Angle " << degrees << "\u00b0"; // degree symbol // + SHIFT = no scaling / NORMAL = with scaling if (!UserInterface::manager().shiftModifier()) { // compute scaling to match cursor @@ -1019,7 +1042,6 @@ View::Cursor GeometryView::grab (Source *s, glm::vec2 from, glm::vec2 to, std::p info << std::endl << " Size " << std::fixed << std::setprecision(3) << sourceNode->scale_.x; info << " x " << sourceNode->scale_.y ; overlay_rotation_fix_->visible_ = false; - overlay_rotation_fix_->copyTransform(overlay_rotation_); } } // picking anywhere but on a handle: user wants to move the source @@ -1073,6 +1095,7 @@ void GeometryView::terminate() overlay_position_->visible_ = false; overlay_position_cross_->visible_ = false; overlay_rotation_clock_->visible_ = false; + overlay_rotation_clock_hand_->visible_ = false; overlay_rotation_fix_->visible_ = false; overlay_rotation_->visible_ = false; overlay_scaling_grid_->visible_ = false; diff --git a/View.h b/View.h index 50b1550..1cf044a 100644 --- a/View.h +++ b/View.h @@ -153,6 +153,7 @@ private: Node *overlay_rotation_; Node *overlay_rotation_fix_; Node *overlay_rotation_clock_; + Node *overlay_rotation_clock_hand_; Node *overlay_scaling_; Node *overlay_scaling_cross_; Node *overlay_scaling_grid_; diff --git a/rsc/mesh/icon_clock_hand.ply b/rsc/mesh/icon_clock_hand.ply new file mode 100644 index 0000000..c8e50e0 --- /dev/null +++ b/rsc/mesh/icon_clock_hand.ply @@ -0,0 +1,20 @@ +ply +format ascii 1.0 +comment Created by Blender 2.90.0 - www.blender.org +element vertex 4 +property float x +property float y +property float z +property uchar red +property uchar green +property uchar blue +property uchar alpha +element face 2 +property list uchar uint vertex_indices +end_header +0.864086 -0.043969 0.000000 255 255 255 255 +1.229462 0.040299 0.000000 255 255 255 255 +0.864086 0.040300 0.000000 255 255 255 255 +1.229462 -0.043970 0.000000 255 255 255 255 +3 0 1 2 +3 0 3 1