diff --git a/CopyVisitor.cpp b/CopyVisitor.cpp new file mode 100644 index 0000000..58b77e9 --- /dev/null +++ b/CopyVisitor.cpp @@ -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_; + +} diff --git a/CopyVisitor.h b/CopyVisitor.h new file mode 100644 index 0000000..8f7ac37 --- /dev/null +++ b/CopyVisitor.h @@ -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 diff --git a/Interpolator.cpp b/Interpolator.cpp new file mode 100644 index 0000000..ac7d148 --- /dev/null +++ b/Interpolator.cpp @@ -0,0 +1,6 @@ +#include "Interpolator.h" + +Interpolator::Interpolator() +{ + +} diff --git a/Interpolator.h b/Interpolator.h new file mode 100644 index 0000000..4bfa688 --- /dev/null +++ b/Interpolator.h @@ -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