mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-11 18:34:58 +01:00
Grab nodes in view
This commit is contained in:
@@ -228,6 +228,8 @@ void UserInterface::handleMouse()
|
|||||||
// // drag current
|
// // drag current
|
||||||
// Log::Info("Dragging %d", current->id());
|
// Log::Info("Dragging %d", current->id());
|
||||||
// current->translation_.x += io.MouseDelta.x * 0.1f;
|
// current->translation_.x += io.MouseDelta.x * 0.1f;
|
||||||
|
Mixer::manager().currentView()->grab( glm::vec2(io.MouseClickedPos[ImGuiMouseButton_Left].x, io.MouseClickedPos[ImGuiMouseButton_Left].y), glm::vec2(io.MousePos.x, io.MousePos.y), current);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
21
View.cpp
21
View.cpp
@@ -74,6 +74,27 @@ void MixingView::drag (glm::vec2 from, glm::vec2 to)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MixingView::grab (glm::vec2 from, glm::vec2 to, Node *node)
|
||||||
|
{
|
||||||
|
static glm::vec3 start_translation = glm::vec3(0.f);
|
||||||
|
static glm::vec2 start_position = glm::vec2(0.f);
|
||||||
|
|
||||||
|
if ( start_position != from ) {
|
||||||
|
start_position = from;
|
||||||
|
start_translation = node->translation_;
|
||||||
|
}
|
||||||
|
|
||||||
|
// unproject
|
||||||
|
glm::vec3 gl_Position_from = Rendering::manager().unProject(from, node->transform_);
|
||||||
|
glm::vec3 gl_Position_to = Rendering::manager().unProject(to, node->transform_);
|
||||||
|
|
||||||
|
// compute delta translation
|
||||||
|
node->translation_ = start_translation + gl_Position_to - gl_Position_from;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
RenderView::RenderView() : View(), frame_buffer_(nullptr)
|
RenderView::RenderView() : View(), frame_buffer_(nullptr)
|
||||||
{
|
{
|
||||||
setResolution(1280, 720);
|
setResolution(1280, 720);
|
||||||
|
|||||||
2
View.h
2
View.h
@@ -17,6 +17,7 @@ public:
|
|||||||
virtual void draw () = 0;
|
virtual void draw () = 0;
|
||||||
virtual void zoom (float) {}
|
virtual void zoom (float) {}
|
||||||
virtual void drag (glm::vec2, glm::vec2) {}
|
virtual void drag (glm::vec2, glm::vec2) {}
|
||||||
|
virtual void grab (glm::vec2, glm::vec2, Node*) {}
|
||||||
|
|
||||||
Scene scene;
|
Scene scene;
|
||||||
|
|
||||||
@@ -34,6 +35,7 @@ public:
|
|||||||
void draw () override;
|
void draw () override;
|
||||||
void zoom (float factor);
|
void zoom (float factor);
|
||||||
void drag (glm::vec2 from, glm::vec2 to);
|
void drag (glm::vec2 from, glm::vec2 to);
|
||||||
|
void grab (glm::vec2 from, glm::vec2 to, Node *node);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user