Working on source interpolation

This commit is contained in:
Bruno
2021-04-18 10:56:37 +02:00
parent cc752050f8
commit 7cafbc032b
4 changed files with 137 additions and 0 deletions

85
CopyVisitor.cpp Normal file
View File

@@ -0,0 +1,85 @@
#include "GlmToolkit.h"
#include "Scene.h"
#include "Source.h"
#include "CopyVisitor.h"
Node *CopyVisitor::deepCopy(Node *node)
{
CopyVisitor cv;
node->accept(cv);
return cv.current_;
}
CopyVisitor::CopyVisitor() : current_(nullptr)
{
}
void CopyVisitor::visit(Node &n)
{
}
void CopyVisitor::visit(Group &n)
{
Group *here = new Group;
// node
current_ = here;
current_->copyTransform(&n);
current_->visible_ = n.visible_;
// loop
for (NodeSet::iterator node = n.begin(); node != n.end(); ++node) {
(*node)->accept(*this);
here->attach( current_ );
current_ = here;
}
}
void CopyVisitor::visit(Switch &n)
{
Switch *here = new Switch;
// node
current_ = here;
current_->copyTransform(&n);
current_->visible_ = n.visible_;
// switch properties
here->setActive( n.active() );
// loop
for (uint i = 0; i < n.numChildren(); ++i) {
n.child(i)->accept(*this);
here->attach( current_ );
current_ = here;
}
}
void CopyVisitor::visit(Scene &n)
{
Scene *here = new Scene;
current_ = here->root();
n.root()->accept(*this);
}
void CopyVisitor::visit(Primitive &n)
{
Primitive *here = new Primitive;
// node
current_ = here;
current_->copyTransform(&n);
current_->visible_ = n.visible_;
}

24
CopyVisitor.h Normal file
View File

@@ -0,0 +1,24 @@
#ifndef COPYVISITOR_H
#define COPYVISITOR_H
#include "Visitor.h"
class SourceCore;
class CopyVisitor : public Visitor
{
Node *current_;
CopyVisitor();
public:
static Node *deepCopy(Node *node);
void visit(Scene& n) override;
void visit(Node& n) override;
void visit(Primitive& n) override;
void visit(Group& n) override;
void visit(Switch& n) override;
};
#endif // COPYVISITOR_H

6
Interpolator.cpp Normal file
View File

@@ -0,0 +1,6 @@
#include "Interpolator.h"
Interpolator::Interpolator()
{
}

22
Interpolator.h Normal file
View File

@@ -0,0 +1,22 @@
#ifndef INTERPOLATOR_H
#define INTERPOLATOR_H
#include "Source.h"
class Interpolator
{
public:
Interpolator();
Source *target_;
SourceCore from_;
SourceCore to_;
SourceCore current_;
float cursor_;
};
#endif // INTERPOLATOR_H