From 660b1d75477dbd82e689bbe97fb6e5ad9789a860 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Mon, 12 Nov 2018 10:02:00 +1100 Subject: [PATCH] added corner pin effect --- effects/internal/cornerpineffect.cpp | 39 ++++++++++++++++++++++++++++ effects/internal/cornerpineffect.h | 22 ++++++++++++++++ olive.pro | 6 +++-- 3 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 effects/internal/cornerpineffect.cpp create mode 100644 effects/internal/cornerpineffect.h diff --git a/effects/internal/cornerpineffect.cpp b/effects/internal/cornerpineffect.cpp new file mode 100644 index 000000000..6c87fb0a8 --- /dev/null +++ b/effects/internal/cornerpineffect.cpp @@ -0,0 +1,39 @@ +#include "cornerpineffect.h" + +CornerPinEffect::CornerPinEffect(Clip *c, const EffectMeta *em) : Effect(c, em) { + enable_coords = true; + + EffectRow* top_left = add_row("Top Left:"); + top_left_x = top_left->add_field(EFFECT_FIELD_DOUBLE); + top_left_y = top_left->add_field(EFFECT_FIELD_DOUBLE); + + EffectRow* top_right = add_row("Top Right:"); + top_right_x = top_right->add_field(EFFECT_FIELD_DOUBLE); + top_right_y = top_right->add_field(EFFECT_FIELD_DOUBLE); + + EffectRow* bottom_left = add_row("Bottom Left:"); + bottom_left_x = bottom_left->add_field(EFFECT_FIELD_DOUBLE); + bottom_left_y = bottom_left->add_field(EFFECT_FIELD_DOUBLE); + + EffectRow* bottom_right = add_row("Bottom Right:"); + bottom_right_x = bottom_right->add_field(EFFECT_FIELD_DOUBLE); + bottom_right_y = bottom_right->add_field(EFFECT_FIELD_DOUBLE); + + connect(intensity_val, SIGNAL(changed()), this, SLOT(field_changed())); + connect(rotation_val, SIGNAL(changed()), this, SLOT(field_changed())); + connect(frequency_val, SIGNAL(changed()), this, SLOT(field_changed())); +} + +void CornerPinEffect::process_coords(double timecode, GLTextureCoords &coords) { + coords.vertexTopLeftX += top_left_x->get_double_value(timecode); + coords.vertexTopLeftY += top_left_y->get_double_value(timecode); + + coords.vertexTopRightX += top_right_x->get_double_value(timecode); + coords.vertexTopRightY += top_right_y->get_double_value(timecode); + + coords.vertexBottomLeftX += bottom_left_x->get_double_value(timecode); + coords.vertexBottomLeftY += bottom_left_y->get_double_value(timecode); + + coords.vertexBottomRightX += bottom_right_x->get_double_value(timecode); + coords.vertexBottomRightY += bottom_right_y->get_double_value(timecode); +} diff --git a/effects/internal/cornerpineffect.h b/effects/internal/cornerpineffect.h new file mode 100644 index 000000000..3e1bb0401 --- /dev/null +++ b/effects/internal/cornerpineffect.h @@ -0,0 +1,22 @@ +#ifndef CORNERPINEFFECT_H +#define CORNERPINEFFECT_H + +#include "../effect.h" + +class CornerPinEffect : public Effect { + Q_OBJECT +public: + CornerPinEffect(Clip* c, const EffectMeta* em); + void process_coords(double timecode, GLTextureCoords& coords); +private: + EffectField* top_left_x; + EffectField* top_left_y; + EffectField* top_right_x; + EffectField* top_right_y; + EffectField* bottom_left_x; + EffectField* bottom_left_y; + EffectField* bottom_right_x; + EffectField* bottom_right_y; +}; + +#endif // CORNERPINEFFECT_H diff --git a/olive.pro b/olive.pro index 52886806d..c548f9532 100644 --- a/olive.pro +++ b/olive.pro @@ -82,7 +82,8 @@ SOURCES += \ effects/internal/crossdissolvetransition.cpp \ effects/internal/shakeeffect.cpp \ effects/internal/exponentialfadetransition.cpp \ - effects/internal/logarithmicfadetransition.cpp + effects/internal/logarithmicfadetransition.cpp \ + effects/internal/cornerpineffect.cpp HEADERS += \ mainwindow.h \ @@ -145,7 +146,8 @@ HEADERS += \ effects/internal/linearfadetransition.h \ effects/internal/crossdissolvetransition.h \ effects/internal/exponentialfadetransition.h \ - effects/internal/logarithmicfadetransition.h + effects/internal/logarithmicfadetransition.h \ + effects/internal/cornerpineffect.h FORMS += \ mainwindow.ui \