From dcfa1e9503b7e97b61396d7458f0b2e5896779cd Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sun, 7 Mar 2010 10:33:15 +0000 Subject: [PATCH] Forgot to add the new files --- source/3d/object.h | 27 +++++++++++++++++++++++++++ source/3d/train.cpp | 31 +++++++++++++++++++++++++++++++ source/3d/train.h | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 93 insertions(+) create mode 100644 source/3d/object.h create mode 100644 source/3d/train.cpp create mode 100644 source/3d/train.h diff --git a/source/3d/object.h b/source/3d/object.h new file mode 100644 index 0000000..8b9353d --- /dev/null +++ b/source/3d/object.h @@ -0,0 +1,27 @@ +/* $Id$ + +This file is part of the MSP Märklin suite +Copyright © 2010 Mikkosoft Productions, Mikko Rasa +Distributed under the GPL +*/ + +#ifndef MARKLIN3D_OBJECT_H_ +#define MARKLIN3D_OBJECT_H_ + +#include "libmarklin/geometry.h" + +namespace Marklin { + +class Object3D +{ +protected: + Object3D() { } +public: + virtual ~Object3D() { } + + virtual Point get_node() const = 0; +}; + +} // namespace Marklin + +#endif diff --git a/source/3d/train.cpp b/source/3d/train.cpp new file mode 100644 index 0000000..d14225e --- /dev/null +++ b/source/3d/train.cpp @@ -0,0 +1,31 @@ +/* $Id$ + +This file is part of the MSP Märklin suite +Copyright © 2010 Mikkosoft Productions, Mikko Rasa +Distributed under the GPL +*/ + +#include "layout.h" +#include "train.h" + +namespace Marklin { + +Train3D::Train3D(Layout3D &l, const Train &t): + layout(l), + train(t) +{ + layout.add_train(*this); +} + +Train3D::~Train3D() +{ + layout.remove_train(*this); +} + +Point Train3D::get_node() const +{ + const Point &pos = train.get_position(); + return Point(pos.x, pos.y, pos.z+0.02); +} + +} // namespace Marklin diff --git a/source/3d/train.h b/source/3d/train.h new file mode 100644 index 0000000..098d344 --- /dev/null +++ b/source/3d/train.h @@ -0,0 +1,35 @@ +/* $Id$ + +This file is part of the MSP Märklin suite +Copyright © 2010 Mikkosoft Productions, Mikko Rasa +Distributed under the GPL +*/ + +#ifndef MARKLIN3D_TRAIN_H_ +#define MARKLIN3D_TRAIN_H_ + +#include "libmarklin/train.h" +#include "object.h" + +namespace Marklin { + +class Layout3D; + +class Train3D: public Object3D +{ +private: + Layout3D &layout; + const Train &train; + +public: + Train3D(Layout3D &, const Train &); + ~Train3D(); + + const Train &get_train() const { return train; } + + virtual Point get_node() const; +}; + +} // namespace Marklin + +#endif -- 2.45.2