began draft of internal node rendering structure

This commit is contained in:
itsmattkc
2019-07-10 23:06:09 -04:00
parent f38e6b876d
commit d76691a9ef
38 changed files with 1617 additions and 14 deletions
+7 -2
View File
@@ -14,16 +14,21 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
add_subdirectory(generator)
add_subdirectory(output)
set(OLIVE_SOURCES
${OLIVE_SOURCES}
node/edge.h
node/edge.cpp
node/node.h
node/node.cpp
node/graph.h
node/graph.cpp
node/input.h
node/input.cpp
node/keyframe.h
node/keyframe.cpp
node/node.h
node/node.cpp
node/output.h
node/output.cpp
node/param.h
+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/>.
add_subdirectory(solid)
set(OLIVE_SOURCES
${OLIVE_SOURCES}
PARENT_SCOPE
)
+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/generator/solid/solid.h
node/generator/solid/solid.cpp
PARENT_SCOPE
)
+14
View File
@@ -0,0 +1,14 @@
#include "solid.h"
SolidGenerator::SolidGenerator(QObject *parent) :
Node(parent)
{
}
void SolidGenerator::Process(const rational &time)
{
Q_UNUSED(time)
}
+17
View File
@@ -0,0 +1,17 @@
#ifndef SOLIDGENERATOR_H
#define SOLIDGENERATOR_H
#include "node/node.h"
class SolidGenerator : public Node
{
public:
SolidGenerator(QObject* parent = nullptr);
virtual void Process(const rational &time) override;
private:
NodeOutput* texture_output_;
};
#endif // SOLIDGENERATOR_H
+42
View File
@@ -20,10 +20,14 @@
#include "input.h"
#include "output.h"
NodeInput::NodeInput(Node* parent) :
NodeParam(parent),
can_accept_multiple_inputs_(false)
{
// Have at least one keyframe/value active at any time
keyframes_.append(NodeKeyframe());
}
NodeParam::Type NodeInput::type()
@@ -50,3 +54,41 @@ void NodeInput::set_can_accept_multiple_inputs(bool b)
{
can_accept_multiple_inputs_ = b;
}
QVariant NodeInput::get_value(const rational &time)
{
/// Determine if this input has any connections to it
switch (edges_.size()) {
/// No connections - use the internal value
case 0:
// FIXME: Re-implement keyframing
return keyframes_.first().value();
/// One connection - use the output of the connected Node
case 1:
return edges_.first()->output()->get_value(time);
/// Multiple connections - rare, return a list of the outputs of the connected Nodes
default:
{
QList<QVariant> values;
for (int i=0;i<edges_.size();i++) {
values.append(edges_.at(i)->output()->get_value(time));
}
return values;
}
}
}
bool NodeInput::keyframing()
{
return keyframing_;
}
void NodeInput::set_keyframing(bool k)
{
keyframing_ = k;
}
+10
View File
@@ -21,6 +21,7 @@
#ifndef NODEINPUT_H
#define NODEINPUT_H
#include "keyframe.h"
#include "param.h"
class NodeInput : public NodeParam
@@ -37,9 +38,18 @@ public:
bool can_accept_multiple_inputs();
void set_can_accept_multiple_inputs(bool b);
QVariant get_value(const rational &time);
bool keyframing();
void set_keyframing(bool k);
private:
QList<DataType> inputs_;
QList<NodeKeyframe> keyframes_;
bool keyframing_;
bool can_accept_multiple_inputs_;
};
+59
View File
@@ -0,0 +1,59 @@
/***
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 "keyframe.h"
NodeKeyframe::NodeKeyframe() :
time_(0),
value_(0),
type_(kLinear)
{
}
const rational &NodeKeyframe::time()
{
return time_;
}
void NodeKeyframe::set_time(const rational &time)
{
time_ = time;
}
const QVariant &NodeKeyframe::value()
{
return value_;
}
void NodeKeyframe::set_value(const QVariant &value)
{
value_ = value;
}
const NodeKeyframe::Type &NodeKeyframe::type()
{
return type_;
}
void NodeKeyframe::set_type(const NodeKeyframe::Type &type)
{
type_ = type;
}
+57
View File
@@ -0,0 +1,57 @@
/***
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 NODEKEYFRAME_H
#define NODEKEYFRAME_H
#include <QVariant>
#include "rational.h"
class NodeKeyframe
{
public:
enum Type {
kLinear,
kHold,
kBezier
};
NodeKeyframe();
const rational& time();
void set_time(const rational& time);
const QVariant& value();
void set_value(const QVariant &value);
const Type& type();
void set_type(const Type& type);
private:
rational time_;
QVariant value_;
Type type_;
};
#endif // NODEKEYFRAME_H
+3
View File
@@ -24,11 +24,14 @@
#include <QObject>
#include "node/param.h"
#include "rational.h"
class Node : public QObject
{
public:
Node(QObject* parent = nullptr);
virtual void Process(const rational& time) = 0;
};
#endif // NODE_H
+16
View File
@@ -20,6 +20,8 @@
#include "output.h"
#include "node/node.h"
NodeOutput::NodeOutput(Node *parent) :
NodeParam(parent)
{
@@ -40,3 +42,17 @@ void NodeOutput::set_data_type(const NodeParam::DataType &type)
{
data_type_ = type;
}
const QVariant &NodeOutput::get_value(const rational& time)
{
// Node::Process() should put the correct value in this output
parent()->Process(time);
// The value should be have been set by this point
return value_;
}
void NodeOutput::set_value(const QVariant &value)
{
value_ = value;
}
+5
View File
@@ -33,8 +33,13 @@ public:
const DataType& data_type();
void set_data_type(const DataType& type);
virtual const QVariant& get_value(const rational &time);
virtual void set_value(const QVariant& value);
private:
DataType data_type_;
QVariant value_;
};
#endif // NODEOUTPUT_H
+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/>.
add_subdirectory(viewer)
set(OLIVE_SOURCES
${OLIVE_SOURCES}
PARENT_SCOPE
)
+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/output/viewer/viewer.h
node/output/viewer/viewer.cpp
PARENT_SCOPE
)
+6
View File
@@ -0,0 +1,6 @@
#include "viewer.h"
ViewerOutput::ViewerOutput(QObject* parent) :
Node(parent)
{
}
+15
View File
@@ -0,0 +1,15 @@
#ifndef VIEWER_H
#define VIEWER_H
#include "node/node.h"
class ViewerOutput : public Node
{
public:
ViewerOutput(QObject* parent = nullptr);
private:
NodeInput* texture_input_;
};
#endif // VIEWER_H
+5
View File
@@ -40,6 +40,11 @@ void NodeParam::set_name(const QString &name)
name_ = name;
}
Node *NodeParam::parent()
{
return static_cast<Node*>(QObject::parent());
}
bool NodeParam::AreDataTypesCompatible(const NodeParam::DataType &output_type, const NodeParam::DataType &input_type)
{
if (input_type == output_type) {
+8 -1
View File
@@ -22,8 +22,10 @@
#define NODEPARAM_H
#include <QObject>
#include <QVariant>
#include "node/edge.h"
#include "rational.h"
class Node;
@@ -58,6 +60,8 @@ public:
const QString& name();
void set_name(const QString& name);
Node* parent();
static bool AreDataTypesCompatible(const DataType& output_type, const DataType& input_type);
static bool AreDataTypesCompatible(const DataType& output_type, const QList<DataType>& input_types);
@@ -66,10 +70,13 @@ public:
static QString GetDefaultDataTypeName(const DataType &type);
private:
protected:
QVector<NodeEdgePtr> edges_;
private:
QString name_;
};
#endif // NODEPARAM_H