mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-14 11:49:59 +01:00
Added overlay of active resize corner in GeometryView, and overlay to
show fixe-size rotation.
This commit is contained in:
@@ -295,6 +295,7 @@ set(VMIX_RSC_FILES
|
|||||||
./rsc/mesh/border_handles_rotation.ply
|
./rsc/mesh/border_handles_rotation.ply
|
||||||
./rsc/mesh/border_handles_scale.ply
|
./rsc/mesh/border_handles_scale.ply
|
||||||
./rsc/mesh/border_handles_overlay.ply
|
./rsc/mesh/border_handles_overlay.ply
|
||||||
|
./rsc/mesh/border_handles_overlay_filled.ply
|
||||||
./rsc/mesh/border_handles_sharp.ply
|
./rsc/mesh/border_handles_sharp.ply
|
||||||
./rsc/mesh/border_large_sharp.ply
|
./rsc/mesh/border_large_sharp.ply
|
||||||
./rsc/mesh/border_vertical_overlay.ply
|
./rsc/mesh/border_vertical_overlay.ply
|
||||||
|
|||||||
@@ -170,6 +170,7 @@ Handles::Handles(Type type) : Node(), type_(type)
|
|||||||
handle_ = handle_corner;
|
handle_ = handle_corner;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
corner_ = glm::vec2(0.f, 0.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
Handles::~Handles()
|
Handles::~Handles()
|
||||||
@@ -184,6 +185,8 @@ void Handles::update( float dt )
|
|||||||
|
|
||||||
void Handles::draw(glm::mat4 modelview, glm::mat4 projection)
|
void Handles::draw(glm::mat4 modelview, glm::mat4 projection)
|
||||||
{
|
{
|
||||||
|
static Mesh *handle_active = new Mesh("mesh/border_handles_overlay_filled.ply");
|
||||||
|
|
||||||
if ( !initialized() ) {
|
if ( !initialized() ) {
|
||||||
if(handle_ && !handle_->initialized())
|
if(handle_ && !handle_->initialized())
|
||||||
handle_->init();
|
handle_->init();
|
||||||
@@ -224,6 +227,12 @@ void Handles::draw(glm::mat4 modelview, glm::mat4 projection)
|
|||||||
vec = modelview * glm::vec4(-1.f, 1.f, 0.f, 1.f);
|
vec = modelview * glm::vec4(-1.f, 1.f, 0.f, 1.f);
|
||||||
ctm = GlmToolkit::transform(vec, rot, glm::vec3(1.f));
|
ctm = GlmToolkit::transform(vec, rot, glm::vec3(1.f));
|
||||||
handle_->draw( ctm, projection );
|
handle_->draw( ctm, projection );
|
||||||
|
|
||||||
|
if ( glm::length(corner_) > 0.f ) {
|
||||||
|
vec = modelview * glm::vec4(corner_.x, corner_.y, 0.f, 1.f);
|
||||||
|
ctm = GlmToolkit::transform(vec, rot, glm::vec3(1.f));
|
||||||
|
handle_active->draw( ctm, projection );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if ( type_ == Handles::RESIZE_H ){
|
else if ( type_ == Handles::RESIZE_H ){
|
||||||
// left and right
|
// left and right
|
||||||
@@ -234,6 +243,12 @@ void Handles::draw(glm::mat4 modelview, glm::mat4 projection)
|
|||||||
vec = modelview * glm::vec4(-1.f, 0.f, 0.f, 1.f);
|
vec = modelview * glm::vec4(-1.f, 0.f, 0.f, 1.f);
|
||||||
ctm = GlmToolkit::transform(vec, rot, glm::vec3(1.f));
|
ctm = GlmToolkit::transform(vec, rot, glm::vec3(1.f));
|
||||||
handle_->draw( ctm, projection );
|
handle_->draw( ctm, projection );
|
||||||
|
|
||||||
|
if ( glm::length(corner_) > 0.f ) {
|
||||||
|
vec = modelview * glm::vec4(corner_.x, corner_.y, 0.f, 1.f);
|
||||||
|
ctm = GlmToolkit::transform(vec, rot, glm::vec3(1.f));
|
||||||
|
handle_active->draw( ctm, projection );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if ( type_ == Handles::RESIZE_V ){
|
else if ( type_ == Handles::RESIZE_V ){
|
||||||
// top and bottom
|
// top and bottom
|
||||||
@@ -244,6 +259,12 @@ void Handles::draw(glm::mat4 modelview, glm::mat4 projection)
|
|||||||
vec = modelview * glm::vec4(0.f, -1.f, 0.f, 1.f);
|
vec = modelview * glm::vec4(0.f, -1.f, 0.f, 1.f);
|
||||||
ctm = GlmToolkit::transform(vec, rot, glm::vec3(1.f));
|
ctm = GlmToolkit::transform(vec, rot, glm::vec3(1.f));
|
||||||
handle_->draw( ctm, projection );
|
handle_->draw( ctm, projection );
|
||||||
|
|
||||||
|
if ( glm::length(corner_) > 0.f ) {
|
||||||
|
vec = modelview * glm::vec4(corner_.x, corner_.y, 0.f, 1.f);
|
||||||
|
ctm = GlmToolkit::transform(vec, rot, glm::vec3(1.f));
|
||||||
|
handle_active->draw( ctm, projection );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if ( type_ == Handles::ROTATE ){
|
else if ( type_ == Handles::ROTATE ){
|
||||||
// one icon in top right corner
|
// one icon in top right corner
|
||||||
@@ -324,28 +345,22 @@ void Symbol::draw(glm::mat4 modelview, glm::mat4 projection)
|
|||||||
// set color
|
// set color
|
||||||
symbol_->shader()->color = color;
|
symbol_->shader()->color = color;
|
||||||
|
|
||||||
// glm::mat4 ctm = modelview * transform_;
|
|
||||||
// // correct for aspect ratio
|
|
||||||
// glm::vec4 vec = ctm * glm::vec4(1.f, 1.0f, 0.f, 0.f);
|
|
||||||
// ctm *= glm::scale(glm::identity<glm::mat4>(), glm::vec3( vec.y / vec.x, 1.f, 1.f));
|
|
||||||
|
|
||||||
// rebuild a matrix with rotation (see handles) and translation from modelview + translation_
|
// rebuild a matrix with rotation (see handles) and translation from modelview + translation_
|
||||||
// and define scale to be 1, 1
|
// and define scale to be 1, 1
|
||||||
|
|
||||||
glm::mat4 ctm;
|
glm::mat4 ctm;
|
||||||
glm::vec3 rot(0.f);
|
glm::vec3 rot(0.f);
|
||||||
glm::vec4 vec = modelview * glm::vec4(1.f, 0.f, 0.f, 0.f);
|
glm::vec4 vec = modelview * glm::vec4(1.f, 0.f, 0.f, 0.f);
|
||||||
rot.z = glm::orientedAngle( glm::vec3(1.f, 0.f, 0.f), glm::normalize(glm::vec3(vec)), glm::vec3(0.f, 0.f, 1.f) );
|
rot.z = glm::orientedAngle( glm::vec3(1.f, 0.f, 0.f), glm::normalize(glm::vec3(vec)), glm::vec3(0.f, 0.f, 1.f) );
|
||||||
|
|
||||||
// extract scaling
|
// extract scaling
|
||||||
ctm = glm::rotate(glm::identity<glm::mat4>(), -rot.z, glm::vec3(0.f, 0.f, 1.f)) * modelview ;
|
ctm = glm::rotate(glm::identity<glm::mat4>(), -rot.z, glm::vec3(0.f, 0.f, 1.f)) * modelview ;
|
||||||
vec = ctm * glm::vec4(1.f, 1.f, 0.f, 0.f);
|
vec = ctm * glm::vec4(1.f, 1.f, 0.f, 0.f);
|
||||||
glm::vec3 sca = glm::vec3(vec.y , vec.y, 1.f) * glm::vec3(scale_.y, scale_.y, 1.f);
|
glm::vec3 sca = glm::vec3(vec.y , vec.y, 1.f) * glm::vec3(scale_.y, scale_.y, 1.f);
|
||||||
|
// extract translation
|
||||||
glm::vec3 tran = glm::vec3(modelview[3][0], modelview[3][1], modelview[3][2]) ;
|
glm::vec3 tran = glm::vec3(modelview[3][0], modelview[3][1], modelview[3][2]) ;
|
||||||
tran += translation_ * glm::vec3(vec);
|
tran += translation_ * glm::vec3(vec);
|
||||||
|
// apply local rotation
|
||||||
rot.z += rotation_.z;
|
rot.z += rotation_.z;
|
||||||
|
// generate matrix
|
||||||
ctm = GlmToolkit::transform(tran, rot, sca);
|
ctm = GlmToolkit::transform(tran, rot, sca);
|
||||||
|
|
||||||
symbol_->draw( ctm, projection);
|
symbol_->draw( ctm, projection);
|
||||||
|
|||||||
@@ -46,10 +46,13 @@ public:
|
|||||||
|
|
||||||
Type type() const { return type_; }
|
Type type() const { return type_; }
|
||||||
Primitive *handle() const { return handle_; }
|
Primitive *handle() const { return handle_; }
|
||||||
|
void overlayActiveCorner(glm::vec2 v) {corner_ = v;}
|
||||||
|
|
||||||
glm::vec4 color;
|
glm::vec4 color;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Primitive *handle_;
|
Primitive *handle_;
|
||||||
|
glm::vec2 corner_;
|
||||||
Type type_;
|
Type type_;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
58
View.cpp
58
View.cpp
@@ -628,7 +628,7 @@ GeometryView::GeometryView() : View(GEOMETRY)
|
|||||||
// User interface foreground
|
// User interface foreground
|
||||||
//
|
//
|
||||||
// 'clock' : tic marks every 10 degrees for ROTATION
|
// 'clock' : tic marks every 10 degrees for ROTATION
|
||||||
// (with opaque background)
|
// with dark background
|
||||||
Group *g = new Group;
|
Group *g = new Group;
|
||||||
Symbol *s = new Symbol(Symbol::CLOCK);
|
Symbol *s = new Symbol(Symbol::CLOCK);
|
||||||
g->attach(s);
|
g->attach(s);
|
||||||
@@ -641,12 +641,18 @@ GeometryView::GeometryView() : View(GEOMETRY)
|
|||||||
overlay_rotation_clock_->scale_ = glm::vec3(0.25f, 0.25f, 1.f);
|
overlay_rotation_clock_->scale_ = glm::vec3(0.25f, 0.25f, 1.f);
|
||||||
scene.fg()->attach(overlay_rotation_clock_);
|
scene.fg()->attach(overlay_rotation_clock_);
|
||||||
overlay_rotation_clock_->visible_ = false;
|
overlay_rotation_clock_->visible_ = false;
|
||||||
|
// circle to show fixed-size ROTATION
|
||||||
|
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_);
|
||||||
|
overlay_rotation_fix_->visible_ = false;
|
||||||
// circle to show the center of ROTATION
|
// circle to show the center of ROTATION
|
||||||
overlay_rotation_ = new Symbol(Symbol::CIRCLE);
|
overlay_rotation_ = new Symbol(Symbol::CIRCLE);
|
||||||
overlay_rotation_->scale_ = glm::vec3(0.25f, 0.25f, 1.f);
|
overlay_rotation_->scale_ = glm::vec3(0.25f, 0.25f, 1.f);
|
||||||
scene.fg()->attach(overlay_rotation_);
|
scene.fg()->attach(overlay_rotation_);
|
||||||
overlay_rotation_->visible_ = false;
|
overlay_rotation_->visible_ = false;
|
||||||
// 'grid' : tic marks every 0.1 step for SCALING
|
// 'grid' : tic marks every 0.1 step for SCALING
|
||||||
|
// with dark background
|
||||||
g = new Group;
|
g = new Group;
|
||||||
s = new Symbol(Symbol::GRID);
|
s = new Symbol(Symbol::GRID);
|
||||||
g->attach(s);
|
g->attach(s);
|
||||||
@@ -814,12 +820,8 @@ View::Cursor GeometryView::grab (Source *s, glm::vec2 from, glm::vec2 to, std::p
|
|||||||
// picking on the resizing handles in the corners
|
// picking on the resizing handles in the corners
|
||||||
if ( pick.first == s->handle_[Handles::RESIZE] ) {
|
if ( pick.first == s->handle_[Handles::RESIZE] ) {
|
||||||
|
|
||||||
// overlay_scaling_->visible_ = true;
|
// inform on which corner should be overlayed (opposite)
|
||||||
// glm::vec4 icon = corner_to_scene_transform * glm::vec4(0.f, 0.f, 0.f, 1.f);
|
s->handle_[Handles::RESIZE]->overlayActiveCorner(-corner);
|
||||||
// overlay_scaling_->translation_.x = icon.x;
|
|
||||||
// overlay_scaling_->translation_.y = icon.y;
|
|
||||||
// overlay_scaling_->rotation_.z = s->stored_status_->rotation_.z;
|
|
||||||
// overlay_scaling_->update(0);
|
|
||||||
|
|
||||||
// RESIZE CORNER
|
// RESIZE CORNER
|
||||||
// proportional SCALING with SHIFT
|
// proportional SCALING with SHIFT
|
||||||
@@ -865,12 +867,8 @@ View::Cursor GeometryView::grab (Source *s, glm::vec2 from, glm::vec2 to, std::p
|
|||||||
// picking on the BORDER RESIZING handles left or right
|
// picking on the BORDER RESIZING handles left or right
|
||||||
else if ( pick.first == s->handle_[Handles::RESIZE_H] ) {
|
else if ( pick.first == s->handle_[Handles::RESIZE_H] ) {
|
||||||
|
|
||||||
// overlay_scaling_->visible_ = true;
|
// inform on which corner should be overlayed (opposite)
|
||||||
// glm::vec4 icon = corner_to_scene_transform * glm::vec4(0.f, 0.f, 0.f, 1.f);
|
s->handle_[Handles::RESIZE_H]->overlayActiveCorner(-corner);
|
||||||
// overlay_scaling_->translation_.x = icon.x;
|
|
||||||
// overlay_scaling_->translation_.y = icon.y;
|
|
||||||
// overlay_scaling_->rotation_.z = s->stored_status_->rotation_.z;
|
|
||||||
// overlay_scaling_->update(0);
|
|
||||||
|
|
||||||
// SHIFT: HORIZONTAL SCALE to restore source aspect ratio
|
// SHIFT: HORIZONTAL SCALE to restore source aspect ratio
|
||||||
if (UserInterface::manager().shiftModifier()) {
|
if (UserInterface::manager().shiftModifier()) {
|
||||||
@@ -904,12 +902,8 @@ View::Cursor GeometryView::grab (Source *s, glm::vec2 from, glm::vec2 to, std::p
|
|||||||
// picking on the BORDER RESIZING handles top or bottom
|
// picking on the BORDER RESIZING handles top or bottom
|
||||||
else if ( pick.first == s->handle_[Handles::RESIZE_V] ) {
|
else if ( pick.first == s->handle_[Handles::RESIZE_V] ) {
|
||||||
|
|
||||||
// overlay_scaling_->visible_ = true;
|
// inform on which corner should be overlayed (opposite)
|
||||||
// glm::vec4 icon = corner_to_scene_transform * glm::vec4(0.f, 0.f, 0.f, 1.f);
|
s->handle_[Handles::RESIZE_V]->overlayActiveCorner(-corner);
|
||||||
// overlay_scaling_->translation_.x = icon.x;
|
|
||||||
// overlay_scaling_->translation_.y = icon.y;
|
|
||||||
// overlay_scaling_->rotation_.z = s->stored_status_->rotation_.z;
|
|
||||||
// overlay_scaling_->update(0);
|
|
||||||
|
|
||||||
// SHIFT: VERTICAL SCALE to restore source aspect ratio
|
// SHIFT: VERTICAL SCALE to restore source aspect ratio
|
||||||
if (UserInterface::manager().shiftModifier()) {
|
if (UserInterface::manager().shiftModifier()) {
|
||||||
@@ -977,6 +971,7 @@ View::Cursor GeometryView::grab (Source *s, glm::vec2 from, glm::vec2 to, std::p
|
|||||||
|
|
||||||
// ROTATION on CENTER
|
// ROTATION on CENTER
|
||||||
overlay_rotation_clock_->visible_ = false;
|
overlay_rotation_clock_->visible_ = false;
|
||||||
|
overlay_rotation_fix_->visible_ = true;
|
||||||
overlay_rotation_->visible_ = true;
|
overlay_rotation_->visible_ = true;
|
||||||
overlay_rotation_->translation_.x = s->stored_status_->translation_.x;
|
overlay_rotation_->translation_.x = s->stored_status_->translation_.x;
|
||||||
overlay_rotation_->translation_.y = s->stored_status_->translation_.y;
|
overlay_rotation_->translation_.y = s->stored_status_->translation_.y;
|
||||||
@@ -1009,7 +1004,9 @@ View::Cursor GeometryView::grab (Source *s, glm::vec2 from, glm::vec2 to, std::p
|
|||||||
// apply center scaling
|
// apply center scaling
|
||||||
sourceNode->scale_ = s->stored_status_->scale_ * source_scaling;
|
sourceNode->scale_ = s->stored_status_->scale_ * source_scaling;
|
||||||
info << std::endl << " Size " << std::fixed << std::setprecision(3) << sourceNode->scale_.x;
|
info << std::endl << " Size " << std::fixed << std::setprecision(3) << sourceNode->scale_.x;
|
||||||
info << " x " << sourceNode->scale_.y ;
|
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
|
// picking anywhere but on a handle: user wants to move the source
|
||||||
@@ -1045,11 +1042,24 @@ View::Cursor GeometryView::grab (Source *s, glm::vec2 from, glm::vec2 to, std::p
|
|||||||
|
|
||||||
void GeometryView::terminate()
|
void GeometryView::terminate()
|
||||||
{
|
{
|
||||||
|
// hide all overlays
|
||||||
overlay_rotation_clock_->visible_ = false;
|
overlay_rotation_clock_->visible_ = false;
|
||||||
overlay_rotation_->visible_ = false;
|
overlay_rotation_fix_->visible_ = false;
|
||||||
overlay_scaling_grid_->visible_ = false;
|
overlay_rotation_->visible_ = false;
|
||||||
overlay_scaling_cross_->visible_ = false;
|
overlay_scaling_grid_->visible_ = false;
|
||||||
overlay_scaling_->visible_ = false;
|
overlay_scaling_cross_->visible_ = false;
|
||||||
|
overlay_scaling_->visible_ = false;
|
||||||
|
|
||||||
|
// cancel of all handles overlays
|
||||||
|
glm::vec2 c(0.f, 0.f);
|
||||||
|
for (auto sit = Mixer::manager().session()->begin();
|
||||||
|
sit != Mixer::manager().session()->end(); sit++){
|
||||||
|
|
||||||
|
(*sit)->handle_[Handles::RESIZE]->overlayActiveCorner(c);
|
||||||
|
(*sit)->handle_[Handles::RESIZE_H]->overlayActiveCorner(c);
|
||||||
|
(*sit)->handle_[Handles::RESIZE_V]->overlayActiveCorner(c);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//View::Cursor GeometryView::over (Source*, glm::vec2, std::pair<Node *, glm::vec2>)
|
//View::Cursor GeometryView::over (Source*, glm::vec2, std::pair<Node *, glm::vec2>)
|
||||||
|
|||||||
1
View.h
1
View.h
@@ -149,6 +149,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Node *overlay_rotation_;
|
Node *overlay_rotation_;
|
||||||
|
Node *overlay_rotation_fix_;
|
||||||
Node *overlay_rotation_clock_;
|
Node *overlay_rotation_clock_;
|
||||||
Node *overlay_scaling_;
|
Node *overlay_scaling_;
|
||||||
Node *overlay_scaling_cross_;
|
Node *overlay_scaling_cross_;
|
||||||
|
|||||||
Reference in New Issue
Block a user