diff --git a/CMakeLists.txt b/CMakeLists.txt index 81a3d5a..4298a57 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -259,6 +259,7 @@ set(VMIX_RSC_FILES ./rsc/images/transparencygrid.png ./rsc/images/shadow.png ./rsc/images/shadow_dark.png + ./rsc/images/shadow_perspective.png ./rsc/mesh/point.ply ./rsc/mesh/disk.ply ./rsc/mesh/shadow.ply @@ -270,6 +271,8 @@ set(VMIX_RSC_FILES ./rsc/mesh/border_handles_overlay.ply ./rsc/mesh/border_large_sharp.ply ./rsc/mesh/border_vertical_overlay.ply + ./rsc/mesh/perspective_layer.ply + ./rsc/mesh/shadow_perspective.ply ./rsc/mesh/circle.ply ./rsc/mesh/icon_video.ply ./rsc/mesh/icon_image.ply diff --git a/Mesh.cpp b/Mesh.cpp index bdcd3ff..a062426 100644 --- a/Mesh.cpp +++ b/Mesh.cpp @@ -247,7 +247,7 @@ bool parsePLY(string ascii, has_uv = true; break; case 't': - uv.y = parseValue(stringstream); + uv.y = -parseValue(stringstream); has_uv = true; break; case 'r': @@ -403,6 +403,10 @@ Frame::Frame(Type style) : Node() border_ = new Mesh("mesh/border_round.ply"); shadow_ = new Mesh("mesh/shadow.ply", "images/shadow.png"); break; + case ROUND_SHADOW: + border_ = new Mesh("mesh/border_round.ply"); + shadow_ = new Mesh("mesh/shadow_perspective.ply", "images/shadow_perspective.png"); + break; } } @@ -471,7 +475,7 @@ Handles::Handles(Type type) : Node(), type_(type) handle_ = new LineSquare(color, 2); handle_->scale_ = glm::vec3( 0.05f, 0.05f, 1.f); } -// handle_ = new Mesh("mesh/border_handles_overlay.ply"); + } Handles::~Handles() diff --git a/Mesh.h b/Mesh.h index 0afc8f4..ef394e7 100644 --- a/Mesh.h +++ b/Mesh.h @@ -38,7 +38,7 @@ class Frame : public Node { public: - typedef enum { ROUND_THIN = 0, ROUND_LARGE, SHARP_THIN, SHARP_LARGE } Type; + typedef enum { ROUND_THIN = 0, ROUND_LARGE, SHARP_THIN, SHARP_LARGE, ROUND_SHADOW } Type; Frame(Type style); ~Frame(); diff --git a/Source.cpp b/Source.cpp index 8302768..0802d11 100644 --- a/Source.cpp +++ b/Source.cpp @@ -50,7 +50,7 @@ Source::Source(const std::string &name) : name_(name), initialized_(false) // default mixing nodes groups_[View::LAYER] = new Group; - frame = new Frame(Frame::ROUND_THIN); + frame = new Frame(Frame::ROUND_SHADOW); frame->translation_.z = 0.1; frame->color = glm::vec4( COLOR_DEFAULT_SOURCE, 0.9f); groups_[View::LAYER]->attach(frame); @@ -259,6 +259,10 @@ void MediaSource::init() node != groups_[View::GEOMETRY]->end(); node++) { (*node)->scale_.x = mediaplayer_->aspectRatio(); } + for (NodeSet::iterator node = groups_[View::LAYER]->begin(); + node != groups_[View::LAYER]->end(); node++) { + (*node)->scale_.x = mediaplayer_->aspectRatio(); + } // done init once and for all initialized_ = true; diff --git a/UserInterfaceManager.cpp b/UserInterfaceManager.cpp index 1341fc8..8973b3e 100644 --- a/UserInterfaceManager.cpp +++ b/UserInterfaceManager.cpp @@ -253,6 +253,8 @@ void UserInterface::handleKeyboard() Mixer::manager().setCurrentView(View::MIXING); else if (ImGui::IsKeyPressed( GLFW_KEY_F2 )) Mixer::manager().setCurrentView(View::GEOMETRY); + else if (ImGui::IsKeyPressed( GLFW_KEY_F3 )) + Mixer::manager().setCurrentView(View::LAYER); else if (ImGui::IsKeyPressed( GLFW_KEY_F11 )) Rendering::manager().ToggleFullscreen(); else if (ImGui::IsKeyPressed( GLFW_KEY_ESCAPE )){ diff --git a/View.cpp b/View.cpp index 01e51ea..4e728fe 100644 --- a/View.cpp +++ b/View.cpp @@ -44,6 +44,24 @@ void View::update(float dt) scene.update( dt ); } +void View::drag (glm::vec2 from, glm::vec2 to) +{ + 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 = scene.root()->translation_; + } + + // unproject + glm::vec3 gl_Position_from = Rendering::manager().unProject(from); + glm::vec3 gl_Position_to = Rendering::manager().unProject(to); + + // compute delta translation + scene.root()->translation_ = start_translation + gl_Position_to - gl_Position_from; +} + MixingView::MixingView() : View(MIXING) { // read default settings @@ -88,24 +106,6 @@ void MixingView::zoom( float factor ) scene.root()->scale_.y = z; } -void MixingView::drag (glm::vec2 from, glm::vec2 to) -{ - 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 = scene.root()->translation_; - } - - // unproject - glm::vec3 gl_Position_from = Rendering::manager().unProject(from); - glm::vec3 gl_Position_to = Rendering::manager().unProject(to); - - // compute delta translation - scene.root()->translation_ = start_translation + gl_Position_to - gl_Position_from; -} - void MixingView::grab (glm::vec2 from, glm::vec2 to, Source *s, std::pair) { @@ -264,25 +264,6 @@ void GeometryView::zoom( float factor ) scene.root()->scale_.y = z; } -void GeometryView::drag (glm::vec2 from, glm::vec2 to) -{ - 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 = scene.root()->translation_; - } - - // unproject - glm::vec3 gl_Position_from = Rendering::manager().unProject(from); - glm::vec3 gl_Position_to = Rendering::manager().unProject(to); - - // compute delta translation - scene.root()->translation_ = start_translation + gl_Position_to - gl_Position_from; -} - - void GeometryView::grab (glm::vec2 from, glm::vec2 to, Source *s, std::pair pick) { // work on the given source @@ -349,7 +330,7 @@ void GeometryView::grab (glm::vec2 from, glm::vec2 to, Source *s, std::pairattach(rect); + Mesh *persp = new Mesh("mesh/perspective_layer.ply"); + persp->translation_.z = -0.1f; + scene.bg()->attach(persp); + Frame *border = new Frame(Frame::SHARP_THIN); border->color = glm::vec4( 0.8f, 0.f, 0.8f, 1.f ); scene.bg()->attach(border); + } LayerView::~LayerView() @@ -377,6 +363,15 @@ LayerView::~LayerView() void LayerView::draw () { + // update rendering of render frame + FrameBuffer *output = Mixer::manager().session()->frame(); + if (output) + aspect_ratio = output->aspectRatio(); + + for (NodeSet::iterator node = scene.bg()->begin(); node != scene.bg()->end(); node++) { + (*node)->scale_.x = aspect_ratio; + } + // draw scene of this view scene.root()->draw(glm::identity(), Rendering::manager().Projection()); @@ -390,13 +385,33 @@ void LayerView::zoom (float factor) scene.root()->scale_.y = z; } -void LayerView::drag (glm::vec2 from, glm::vec2 to) -{ - -} void LayerView::grab (glm::vec2 from, glm::vec2 to, Source *s, std::pair pick) { + if (!s) + return; + + Group *sourceNode = s->group(View::LAYER); + + 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 = sourceNode->translation_; + } + + // unproject + glm::vec3 gl_Position_from = Rendering::manager().unProject(from, scene.root()->transform_); + glm::vec3 gl_Position_to = Rendering::manager().unProject(to, scene.root()->transform_); + + // compute delta translation + sourceNode->translation_ = start_translation + gl_Position_to - gl_Position_from; + + // diagonal movement only + sourceNode->translation_.x = CLAMP( sourceNode->translation_.x, -10.f, 0.f); + sourceNode->translation_.y = sourceNode->translation_.x / aspect_ratio; + } diff --git a/View.h b/View.h index 2ea0184..e03f98d 100644 --- a/View.h +++ b/View.h @@ -19,7 +19,7 @@ public: virtual void update (float dt); virtual void draw () = 0; 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, Source*, std::pair) {} virtual void restoreSettings(); @@ -40,7 +40,6 @@ public: void draw () override; void zoom (float factor) override; - void drag (glm::vec2 from, glm::vec2 to) override; void grab (glm::vec2 from, glm::vec2 to, Source *s, std::pair) override; private: @@ -72,7 +71,6 @@ public: void draw () override; void zoom (float factor) override; - void drag (glm::vec2 from, glm::vec2 to) override; void grab (glm::vec2 from, glm::vec2 to, Source *s, std::pair pick) override; private: @@ -87,11 +85,10 @@ public: void draw () override; void zoom (float factor) override; - void drag (glm::vec2 from, glm::vec2 to) override; void grab (glm::vec2 from, glm::vec2 to, Source *s, std::pair pick) override; private: - + float aspect_ratio; }; diff --git a/rsc/mesh/shadow.ply b/rsc/mesh/shadow.ply index 0006997..fe10302 100644 --- a/rsc/mesh/shadow.ply +++ b/rsc/mesh/shadow.ply @@ -14,14 +14,14 @@ property uchar alpha element face 8 property list uchar uint vertex_indices end_header -1.000000 -1.000000 0.000000 0.202616 0.797384 255 255 255 255 --1.300000 -1.300000 0.000000 1.000000 1.000000 255 255 255 65 -1.300000 -1.300000 0.000000 0.000000 1.000000 255 255 255 65 --1.000000 -1.000000 0.000000 0.797384 0.797384 255 255 255 255 --1.300000 1.300000 0.000000 1.000000 0.000000 255 255 255 65 -1.000000 1.000000 0.000000 0.202616 0.202616 255 255 255 255 -1.300000 1.300000 0.000000 0.000000 0.000000 255 255 255 65 --1.000000 1.000000 0.000000 0.797384 0.202616 255 255 255 255 +1.000000 -1.000000 0.000000 0.827672 0.172328 255 255 255 255 +-1.300000 -1.300000 0.000000 -0.002507 -0.002507 255 255 255 0 +1.300000 -1.300000 0.000000 1.002507 -0.002507 255 255 255 0 +-1.000000 -1.000000 0.000000 0.172328 0.172328 255 255 255 255 +-1.300000 1.300000 0.000000 -0.002507 1.002507 255 255 255 0 +1.000000 1.000000 0.000000 0.827672 0.827672 255 255 255 255 +1.300000 1.300000 0.000000 1.002507 1.002507 255 255 255 0 +-1.000000 1.000000 0.000000 0.172328 0.827672 255 255 255 255 3 0 1 2 3 3 4 1 3 5 2 6