nodes: moved matrix input on "video input" elsewhere
Rather than plugging a matrix into the video input node, the matrix is now multiplied by the video input using a math node. This is probably more sensible from a user perspective. This also means the renderer is tolerant of texture sizes that are not equal to the sequence size, however most nodes will downsample the texture to the sequence size (and if not, it will be downsampled once it is cached). Textures will still *always* be in reference space and the sequence's format. This seems like the best compromise between backend and frontend congruity.
This commit is contained in:
@@ -1,22 +0,0 @@
|
||||
# Olive - Non-Linear Video Editor
|
||||
# Copyright (C) 2019 Olive Team
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
set(OLIVE_SOURCES
|
||||
${OLIVE_SOURCES}
|
||||
node/distort/transform/transform.h
|
||||
node/distort/transform/transform.cpp
|
||||
PARENT_SCOPE
|
||||
)
|
||||
@@ -1,118 +0,0 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#include "transform.h"
|
||||
|
||||
#include <QMatrix4x4>
|
||||
#include <QVector2D>
|
||||
|
||||
OLIVE_NAMESPACE_ENTER
|
||||
|
||||
TransformDistort::TransformDistort()
|
||||
{
|
||||
position_input_ = new NodeInput("pos_in", NodeParam::kVec2);
|
||||
AddInput(position_input_);
|
||||
|
||||
rotation_input_ = new NodeInput("rot_in", NodeParam::kFloat);
|
||||
AddInput(rotation_input_);
|
||||
|
||||
scale_input_ = new NodeInput("scale_in", NodeParam::kVec2, QVector2D(1.0f, 1.0f));
|
||||
scale_input_->set_property("min", QVector2D(0, 0));
|
||||
scale_input_->set_property("view", "percent");
|
||||
scale_input_->set_property("disabley", true);
|
||||
AddInput(scale_input_);
|
||||
|
||||
uniform_scale_input_ = new NodeInput("uniform_scale_in", NodeParam::kBoolean, true);
|
||||
uniform_scale_input_->set_is_keyframable(false);
|
||||
uniform_scale_input_->SetConnectable(false);
|
||||
connect(uniform_scale_input_, &NodeInput::ValueChanged, this, &TransformDistort::UniformScaleChanged);
|
||||
AddInput(uniform_scale_input_);
|
||||
|
||||
anchor_input_ = new NodeInput("anchor_in", NodeParam::kVec2);
|
||||
AddInput(anchor_input_);
|
||||
}
|
||||
|
||||
Node *TransformDistort::copy() const
|
||||
{
|
||||
return new TransformDistort();
|
||||
}
|
||||
|
||||
QString TransformDistort::Name() const
|
||||
{
|
||||
return tr("Transform");
|
||||
}
|
||||
|
||||
QString TransformDistort::id() const
|
||||
{
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.transform");
|
||||
}
|
||||
|
||||
QString TransformDistort::Category() const
|
||||
{
|
||||
return tr("Distort");
|
||||
}
|
||||
|
||||
QString TransformDistort::Description() const
|
||||
{
|
||||
return tr("Apply transformations to position, rotation, and scale.");
|
||||
}
|
||||
|
||||
void TransformDistort::Retranslate()
|
||||
{
|
||||
position_input_->set_name(tr("Position"));
|
||||
rotation_input_->set_name(tr("Rotation"));
|
||||
scale_input_->set_name(tr("Scale"));
|
||||
uniform_scale_input_->set_name(tr("Uniform Scale"));
|
||||
anchor_input_->set_name(tr("Anchor Point"));
|
||||
}
|
||||
|
||||
NodeValueTable TransformDistort::Value(NodeValueDatabase &value) const
|
||||
{
|
||||
QMatrix4x4 mat;
|
||||
|
||||
// Position translate
|
||||
QVector2D pos = value[position_input_].Get(NodeParam::kVec2).value<QVector2D>();
|
||||
mat.translate(pos);
|
||||
|
||||
// Rotation
|
||||
mat.rotate(value[rotation_input_].Get(NodeParam::kFloat).toFloat(), 0, 0, 1);
|
||||
|
||||
// Scale and Uniform Scale
|
||||
QVector2D scale = value[scale_input_].Get(NodeParam::kVec2).value<QVector2D>();
|
||||
if (value[uniform_scale_input_].Get(NodeParam::kBoolean).toBool()) {
|
||||
scale.setY(scale.x());
|
||||
}
|
||||
mat.scale(scale);
|
||||
|
||||
// Anchor Point
|
||||
mat.translate(-value[anchor_input_].Get(NodeParam::kVec2).value<QVector2D>());
|
||||
|
||||
// Push matrix output
|
||||
NodeValueTable output;
|
||||
output.Push(NodeParam::kMatrix, mat);
|
||||
return output;
|
||||
}
|
||||
|
||||
void TransformDistort::UniformScaleChanged()
|
||||
{
|
||||
scale_input_->set_property("disabley", uniform_scale_input_->get_standard_value().toBool());
|
||||
}
|
||||
|
||||
OLIVE_NAMESPACE_EXIT
|
||||
@@ -1,63 +0,0 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef TRANSFORMDISTORT_H
|
||||
#define TRANSFORMDISTORT_H
|
||||
|
||||
#include "node/node.h"
|
||||
|
||||
OLIVE_NAMESPACE_ENTER
|
||||
|
||||
class TransformDistort : public Node
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
TransformDistort();
|
||||
|
||||
virtual Node* copy() const override;
|
||||
|
||||
virtual QString Name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QString Category() const override;
|
||||
virtual QString Description() const override;
|
||||
|
||||
virtual void Retranslate() override;
|
||||
|
||||
virtual NodeValueTable Value(NodeValueDatabase& value) const override;
|
||||
|
||||
private:
|
||||
NodeInput* position_input_;
|
||||
|
||||
NodeInput* rotation_input_;
|
||||
|
||||
NodeInput* scale_input_;
|
||||
|
||||
NodeInput* uniform_scale_input_;
|
||||
|
||||
NodeInput* anchor_input_;
|
||||
|
||||
private slots:
|
||||
void UniformScaleChanged();
|
||||
|
||||
};
|
||||
|
||||
OLIVE_NAMESPACE_EXIT
|
||||
|
||||
#endif // TRANSFORMDISTORT_H
|
||||
Reference in New Issue
Block a user