mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-05 15:30:00 +01:00
Working on source interpolation
This commit is contained in:
85
CopyVisitor.cpp
Normal file
85
CopyVisitor.cpp
Normal 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
24
CopyVisitor.h
Normal 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
6
Interpolator.cpp
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#include "Interpolator.h"
|
||||||
|
|
||||||
|
Interpolator::Interpolator()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
22
Interpolator.h
Normal file
22
Interpolator.h
Normal 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
|
||||||
Reference in New Issue
Block a user