sweeping vfx rewrite
This commit is contained in:
+26
-53
@@ -13,39 +13,29 @@
|
||||
#include "panels/timeline.h"
|
||||
|
||||
ShakeEffect::ShakeEffect(Clip *c) : Effect(c, EFFECT_TYPE_VIDEO, VIDEO_SHAKE_EFFECT), inside(false) {
|
||||
ui_layout->addWidget(new QLabel("Intensity:"), 0, 0);
|
||||
intensity_val = new LabelSlider();
|
||||
intensity_val->set_minimum_value(0);
|
||||
ui_layout->addWidget(intensity_val, 0, 1);
|
||||
EffectRow* intensity_row = add_row("Intensity:");
|
||||
intensity_val = intensity_row->add_field(EFFECT_FIELD_DOUBLE);
|
||||
intensity_val->set_double_minimum_value(0);
|
||||
|
||||
ui_layout->addWidget(new QLabel("Rotation:"), 1, 0);
|
||||
rotation_val = new LabelSlider();
|
||||
rotation_val->set_minimum_value(0);
|
||||
ui_layout->addWidget(rotation_val, 1, 1);
|
||||
EffectRow* rotation_row = add_row("Rotation:");
|
||||
rotation_val = rotation_row->add_field(EFFECT_FIELD_DOUBLE);
|
||||
rotation_val->set_double_minimum_value(0);
|
||||
|
||||
ui_layout->addWidget(new QLabel("Frequency:"), 2, 0);
|
||||
frequency_val = new LabelSlider();
|
||||
frequency_val->set_minimum_value(0);
|
||||
ui_layout->addWidget(frequency_val, 2, 1);
|
||||
EffectRow* frequency_row = add_row("Frequency:");
|
||||
frequency_val = frequency_row->add_field(EFFECT_FIELD_DOUBLE);
|
||||
frequency_val->set_double_minimum_value(0);
|
||||
|
||||
// set defaults
|
||||
intensity_val->set_value(50);
|
||||
rotation_val->set_value(0);
|
||||
frequency_val->set_value(10);
|
||||
intensity_val->set_double_default_value(50);
|
||||
rotation_val->set_double_default_value(0);
|
||||
frequency_val->set_double_default_value(10);
|
||||
|
||||
init();
|
||||
|
||||
connect(intensity_val, SIGNAL(valueChanged()), this, SLOT(field_changed()));
|
||||
connect(rotation_val, SIGNAL(valueChanged()), this, SLOT(field_changed()));
|
||||
connect(frequency_val, SIGNAL(valueChanged()), this, SLOT(field_changed()));
|
||||
connect(intensity_val, SIGNAL(valueChanged()), this, SLOT(init()));
|
||||
connect(rotation_val, SIGNAL(valueChanged()), this, SLOT(init()));
|
||||
connect(frequency_val, SIGNAL(valueChanged()), this, SLOT(init()));
|
||||
refresh();
|
||||
}
|
||||
|
||||
void ShakeEffect::init() {
|
||||
void ShakeEffect::refresh() {
|
||||
if (parent_clip->sequence != NULL) {
|
||||
shake_limit = qRound(parent_clip->sequence->frame_rate / frequency_val->value());
|
||||
shake_limit = qRound(parent_clip->sequence->frame_rate / frequency_val->get_double_value());
|
||||
shake_progress = shake_limit;
|
||||
next_x = 0;
|
||||
next_y = 0;
|
||||
@@ -54,40 +44,22 @@ void ShakeEffect::init() {
|
||||
}
|
||||
|
||||
Effect* ShakeEffect::copy(Clip* c) {
|
||||
ShakeEffect* e = new ShakeEffect(c);
|
||||
/*ShakeEffect* e = new ShakeEffect(c);
|
||||
e->intensity_val->set_value(intensity_val->value());
|
||||
e->rotation_val->set_value(rotation_val->value());
|
||||
e->frequency_val->set_value(frequency_val->value());
|
||||
return e;
|
||||
}
|
||||
|
||||
void ShakeEffect::load(QXmlStreamReader* reader) {
|
||||
const QXmlStreamAttributes& attr = reader->attributes();
|
||||
for (int i=0;i<attr.size();i++) {
|
||||
const QXmlStreamAttribute& a = attr.at(i);
|
||||
if (a.name() == "intensity") {
|
||||
intensity_val->set_value(a.value().toDouble());
|
||||
} else if (a.name() == "rotation") {
|
||||
rotation_val->set_value(a.value().toDouble());
|
||||
} else if (a.name() == "frequency") {
|
||||
frequency_val->set_value(a.value().toDouble());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ShakeEffect::save(QXmlStreamWriter* stream) {
|
||||
stream->writeAttribute("intensity", QString::number(intensity_val->value()));
|
||||
stream->writeAttribute("rotation", QString::number(rotation_val->value()));
|
||||
stream->writeAttribute("frequency", QString::number(frequency_val->value()));
|
||||
e->frequency_val->set_value(frequency_val->value());
|
||||
return e;*/
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void ShakeEffect::process_gl(int*, int*) {
|
||||
if (shake_progress > shake_limit) {
|
||||
if ((int)intensity_val->value() > 0) {
|
||||
double ival = intensity_val->get_double_value();
|
||||
if ((int)ival > 0) {
|
||||
prev_x = next_x;
|
||||
prev_y = next_y;
|
||||
next_x = (qrand() % (int) (intensity_val->value() * 2)) - intensity_val->value();
|
||||
next_y = (qrand() % (int) (intensity_val->value() * 2)) - intensity_val->value();
|
||||
next_x = (qrand() % (int) (ival * 2)) - ival;
|
||||
next_y = (qrand() % (int) (ival * 2)) - ival;
|
||||
|
||||
// find perpendicular slope that passes through (mid_x, mid_y)
|
||||
int mid_x = (prev_x + next_x) / 2;
|
||||
@@ -112,9 +84,10 @@ void ShakeEffect::process_gl(int*, int*) {
|
||||
offset_x = 0;
|
||||
offset_y = 0;
|
||||
}
|
||||
if ((int)rotation_val->value() > 0) {
|
||||
double rot_val = rotation_val->get_double_value();
|
||||
if ((int)rot_val > 0) {
|
||||
prev_rot = next_rot;
|
||||
next_rot = (qrand() % (int) (rotation_val->value() * 2)) - rotation_val->value();
|
||||
next_rot = (qrand() % (int) (rot_val * 2)) - rot_val;
|
||||
} else {
|
||||
prev_rot = 0;
|
||||
next_rot = 0;
|
||||
|
||||
Reference in New Issue
Block a user