timenode: implemented timenode to allow values to be connected to time

This commit is contained in:
itsmattkc
2020-04-03 23:27:38 +11:00
parent 378c354277
commit 3dd91a1429
7 changed files with 97 additions and 0 deletions
+3
View File
@@ -8,6 +8,7 @@
#include "distort/transform/transform.h"
#include "input/media/video/video.h"
#include "input/media/audio/audio.h"
#include "input/time/timeinput.h"
#include "math/math.h"
#include "output/track/track.h"
#include "output/viewer/viewer.h"
@@ -138,6 +139,8 @@ Node *NodeFactory::CreateInternal(const NodeFactory::InternalID &id)
return new PanNode();
case kMath:
return new MathNode();
case kTime:
return new TimeInput();
case kInternalNodeCount:
break;
+1
View File
@@ -20,6 +20,7 @@ public:
kAudioVolume,
kAudioPanning,
kMath,
kTime,
// Count value
kInternalNodeCount
+1
View File
@@ -15,6 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
add_subdirectory(media)
add_subdirectory(time)
set(OLIVE_SOURCES
${OLIVE_SOURCES}
+22
View File
@@ -0,0 +1,22 @@
# 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/input/time/timeinput.h
node/input/time/timeinput.cpp
PARENT_SCOPE
)
+41
View File
@@ -0,0 +1,41 @@
#include "timeinput.h"
TimeInput::TimeInput()
{
}
Node *TimeInput::copy() const
{
return new TimeInput();
}
QString TimeInput::Name() const
{
return tr("Time");
}
QString TimeInput::id() const
{
return QStringLiteral("org.olivevideoeditor.Olive.videoinput");
}
QString TimeInput::Category() const
{
return tr("Input");
}
QString TimeInput::Description() const
{
return tr("Generates the time (in seconds) at this frame");
}
NodeValueTable TimeInput::Value(const NodeValueDatabase &value) const
{
NodeValueTable table = value.Merge();
table.Push(NodeParam::kFloat,
value[QStringLiteral("global")].Get(NodeParam::kFloat, QStringLiteral("time_in")),
QStringLiteral("time"));
return table;
}
+23
View File
@@ -0,0 +1,23 @@
#ifndef TIMEINPUT_H
#define TIMEINPUT_H
#include "node/node.h"
class TimeInput : public Node
{
Q_OBJECT
public:
TimeInput();
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 NodeValueTable Value(const NodeValueDatabase& value) const override;
};
#endif // TIMEINPUT_H
+6
View File
@@ -29,6 +29,12 @@ NodeValueDatabase NodeTraverser::GenerateDatabase(const Node* node, const TimeRa
}
}
// Insert global variables
NodeValueTable global;
global.Push(NodeParam::kFloat, range.in().toDouble(), QStringLiteral("time_in"));
global.Push(NodeParam::kFloat, range.out().toDouble(), QStringLiteral("time_out"));
database.Insert(QStringLiteral("global"), global);
return database;
}