improved corner pin
This commit is contained in:
+1
-4
@@ -20,6 +20,7 @@
|
||||
#include "debug.h"
|
||||
#include "io/path.h"
|
||||
#include "mainwindow.h"
|
||||
#include "io/math.h"
|
||||
|
||||
#include "effects/internal/transformeffect.h"
|
||||
#include "effects/internal/texteffect.h"
|
||||
@@ -228,10 +229,6 @@ void EffectInit::run() {
|
||||
dout << "[INFO] Finished initializing effects";
|
||||
}
|
||||
|
||||
double double_lerp(double a, double b, double t) {
|
||||
return ((1.0 - t) * a) + (t * b);
|
||||
}
|
||||
|
||||
Effect::Effect(Clip* c, const EffectMeta *em) :
|
||||
parent_clip(c),
|
||||
meta(em),
|
||||
|
||||
@@ -84,6 +84,8 @@ extern QMutex effects_loaded;
|
||||
#define TRAN_TYPE_CLOSEWLINK 4
|
||||
|
||||
struct GLTextureCoords {
|
||||
int grid_size;
|
||||
|
||||
int vertexTopLeftX;
|
||||
int vertexTopLeftY;
|
||||
int vertexTopRightX;
|
||||
|
||||
@@ -5,19 +5,27 @@ CornerPinEffect::CornerPinEffect(Clip *c, const EffectMeta *em) : Effect(c, em)
|
||||
|
||||
EffectRow* top_left = add_row("Top Left:");
|
||||
top_left_x = top_left->add_field(EFFECT_FIELD_DOUBLE);
|
||||
top_left_x->id = "topleftx";
|
||||
top_left_y = top_left->add_field(EFFECT_FIELD_DOUBLE);
|
||||
top_left_y->id = "toplefty";
|
||||
|
||||
EffectRow* top_right = add_row("Top Right:");
|
||||
top_right_x = top_right->add_field(EFFECT_FIELD_DOUBLE);
|
||||
top_right_x->id = "toprightx";
|
||||
top_right_y = top_right->add_field(EFFECT_FIELD_DOUBLE);
|
||||
top_right_y->id = "toprighty";
|
||||
|
||||
EffectRow* bottom_left = add_row("Bottom Left:");
|
||||
bottom_left_x = bottom_left->add_field(EFFECT_FIELD_DOUBLE);
|
||||
bottom_left_x->id = "bottomleftx";
|
||||
bottom_left_y = bottom_left->add_field(EFFECT_FIELD_DOUBLE);
|
||||
bottom_left_y->id = "bottomlefty";
|
||||
|
||||
EffectRow* bottom_right = add_row("Bottom Right:");
|
||||
bottom_right_x = bottom_right->add_field(EFFECT_FIELD_DOUBLE);
|
||||
bottom_right_x->id = "bottomrightx";
|
||||
bottom_right_y = bottom_right->add_field(EFFECT_FIELD_DOUBLE);
|
||||
bottom_right_y->id = "bottomrighty";
|
||||
|
||||
connect(top_left_x, SIGNAL(changed()), this, SLOT(field_changed()));
|
||||
connect(top_left_y, SIGNAL(changed()), this, SLOT(field_changed()));
|
||||
@@ -30,6 +38,8 @@ CornerPinEffect::CornerPinEffect(Clip *c, const EffectMeta *em) : Effect(c, em)
|
||||
}
|
||||
|
||||
void CornerPinEffect::process_coords(double timecode, GLTextureCoords &coords) {
|
||||
coords.grid_size += 4;
|
||||
|
||||
coords.vertexTopLeftX += top_left_x->get_double_value(timecode);
|
||||
coords.vertexTopLeftY += top_left_y->get_double_value(timecode);
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
#include "math.h"
|
||||
|
||||
int lerp(int a, int b, double t) {
|
||||
return ((1.0 - t) * a) + (t * b);
|
||||
}
|
||||
|
||||
double double_lerp(double a, double b, double t) {
|
||||
return ((1.0 - t) * a) + (t * b);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
#ifndef MATH_H
|
||||
#define MATH_H
|
||||
|
||||
int lerp(int a, int b, double t);
|
||||
double double_lerp(double a, double b, double t);
|
||||
|
||||
#endif // MATH_H
|
||||
@@ -83,7 +83,8 @@ SOURCES += \
|
||||
effects/internal/shakeeffect.cpp \
|
||||
effects/internal/exponentialfadetransition.cpp \
|
||||
effects/internal/logarithmicfadetransition.cpp \
|
||||
effects/internal/cornerpineffect.cpp
|
||||
effects/internal/cornerpineffect.cpp \
|
||||
io/math.cpp
|
||||
|
||||
HEADERS += \
|
||||
mainwindow.h \
|
||||
@@ -147,7 +148,8 @@ HEADERS += \
|
||||
effects/internal/crossdissolvetransition.h \
|
||||
effects/internal/exponentialfadetransition.h \
|
||||
effects/internal/logarithmicfadetransition.h \
|
||||
effects/internal/cornerpineffect.h
|
||||
effects/internal/cornerpineffect.h \
|
||||
io/math.h
|
||||
|
||||
FORMS += \
|
||||
mainwindow.ui \
|
||||
|
||||
@@ -352,10 +352,6 @@ void Timeline::delete_selection(QVector<Selection>& selections, bool ripple_dele
|
||||
}
|
||||
}
|
||||
|
||||
int lerp(int a, int b, double t) {
|
||||
return ((1.0 - t) * a) + (t * b);
|
||||
}
|
||||
|
||||
void Timeline::set_zoom_value(double v) {
|
||||
zoom = v;
|
||||
ui->headers->update_zoom(zoom);
|
||||
|
||||
@@ -28,7 +28,6 @@ struct Clip;
|
||||
struct Media;
|
||||
struct MediaStream;
|
||||
|
||||
int lerp(int a, int b, double t);
|
||||
long refactor_frame_number(long framenumber, double source_frame_rate, double target_frame_rate);
|
||||
int getScreenPointFromFrame(double zoom, long frame);
|
||||
long getFrameFromScreenPoint(double zoom, int x);
|
||||
|
||||
+45
-8
@@ -13,6 +13,7 @@
|
||||
#include "playback/cacher.h"
|
||||
#include "io/config.h"
|
||||
#include "debug.h"
|
||||
#include "io/math.h"
|
||||
|
||||
#include <QPainter>
|
||||
#include <QAudioOutput>
|
||||
@@ -376,6 +377,7 @@ GLuint ViewerWidget::compose_sequence(QVector<Clip*>& nests, bool render_audio)
|
||||
fbo_switcher = !fbo_switcher;
|
||||
|
||||
GLTextureCoords coords;
|
||||
coords.grid_size = 1;
|
||||
coords.vertexTopLeftX = coords.vertexBottomLeftX = -video_width/2;
|
||||
coords.vertexTopLeftY = coords.vertexTopRightY = -video_height/2;
|
||||
coords.vertexTopRightX = coords.vertexBottomRightX = video_width/2;
|
||||
@@ -434,14 +436,49 @@ GLuint ViewerWidget::compose_sequence(QVector<Clip*>& nests, bool render_audio)
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(coords.textureTopLeftX, coords.textureTopLeftY); // top left
|
||||
glVertex2f(coords.vertexTopLeftX, coords.vertexTopLeftY); // top left
|
||||
glTexCoord2f(coords.textureTopRightX, coords.textureTopRightY); // top right
|
||||
glVertex2f(coords.vertexTopRightX, coords.vertexTopRightY); // top right
|
||||
glTexCoord2f(coords.textureBottomRightX, coords.textureBottomRightY); // bottom right
|
||||
glVertex2f(coords.vertexBottomRightX, coords.vertexBottomRightY); // bottom right
|
||||
glTexCoord2f(coords.textureBottomLeftX, coords.textureBottomLeftY); // bottom left
|
||||
glVertex2f(coords.vertexBottomLeftX, coords.vertexBottomLeftY); // bottom left
|
||||
|
||||
if (coords.grid_size <= 1) {
|
||||
glTexCoord2f(coords.textureTopLeftX, coords.textureTopLeftY); // top left
|
||||
glVertex2f(coords.vertexTopLeftX, coords.vertexTopLeftY); // top left
|
||||
glTexCoord2f(coords.textureTopRightX, coords.textureTopRightY); // top right
|
||||
glVertex2f(coords.vertexTopRightX, coords.vertexTopRightY); // top right
|
||||
glTexCoord2f(coords.textureBottomRightX, coords.textureBottomRightY); // bottom right
|
||||
glVertex2f(coords.vertexBottomRightX, coords.vertexBottomRightY); // bottom right
|
||||
glTexCoord2f(coords.textureBottomLeftX, coords.textureBottomLeftY); // bottom left
|
||||
glVertex2f(coords.vertexBottomLeftX, coords.vertexBottomLeftY); // bottom left
|
||||
} else {
|
||||
double rows = coords.grid_size;
|
||||
double cols = coords.grid_size;
|
||||
|
||||
for (double i=0;i<rows;i++) {
|
||||
double row_prog = i/rows;
|
||||
double next_row_prog = (i+1)/rows;
|
||||
for (double j=0;j<cols;j++) {
|
||||
double col_prog = j/cols;
|
||||
double next_col_prog = (j+1)/cols;
|
||||
|
||||
double vertexTLX = double_lerp(coords.vertexTopLeftX, coords.vertexBottomLeftX, row_prog);
|
||||
double vertexTRX = double_lerp(coords.vertexTopRightX, coords.vertexBottomRightX, row_prog);
|
||||
double vertexBLX = double_lerp(coords.vertexTopLeftX, coords.vertexBottomLeftX, next_row_prog);
|
||||
double vertexBRX = double_lerp(coords.vertexTopRightX, coords.vertexBottomRightX, next_row_prog);
|
||||
|
||||
double vertexTLY = double_lerp(coords.vertexTopLeftY, coords.vertexTopRightY, col_prog);
|
||||
double vertexTRY = double_lerp(coords.vertexTopLeftY, coords.vertexTopRightY, next_col_prog);
|
||||
double vertexBLY = double_lerp(coords.vertexBottomLeftY, coords.vertexBottomRightY, col_prog);
|
||||
double vertexBRY = double_lerp(coords.vertexBottomLeftY, coords.vertexBottomRightY, next_col_prog);
|
||||
|
||||
glTexCoord2f(double_lerp(coords.textureTopLeftX, coords.textureTopRightX, col_prog), double_lerp(coords.textureTopLeftY, coords.textureBottomLeftY, row_prog)); // top left
|
||||
glVertex2f(double_lerp(vertexTLX, vertexTRX, col_prog), double_lerp(vertexTLY, vertexBLY, row_prog)); // top left
|
||||
glTexCoord2f(double_lerp(coords.textureTopLeftX, coords.textureTopRightX, next_col_prog), double_lerp(coords.textureTopRightY, coords.textureBottomRightY, row_prog)); // top right
|
||||
glVertex2f(double_lerp(vertexTLX, vertexTRX, next_col_prog), double_lerp(vertexTRY, vertexBRY, row_prog)); // top right
|
||||
glTexCoord2f(double_lerp(coords.textureBottomLeftX, coords.textureBottomRightX, next_col_prog), double_lerp(coords.textureTopRightY, coords.textureBottomRightY, next_row_prog)); // bottom right
|
||||
glVertex2f(double_lerp(vertexBLX, vertexBRX, next_col_prog), double_lerp(vertexTRY, vertexBRY, next_row_prog)); // bottom right
|
||||
glTexCoord2f(double_lerp(coords.textureBottomLeftX, coords.textureBottomRightX, col_prog), double_lerp(coords.textureTopLeftY, coords.textureBottomLeftY, next_row_prog)); // bottom left
|
||||
glVertex2f(double_lerp(vertexBLX, vertexBRX, col_prog), double_lerp(vertexTLY, vertexBLY, next_row_prog)); // bottom left
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
glEnd();
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
Reference in New Issue
Block a user