+/* $Id$
+
+This file is part of the MSP Märklin suite
+Copyright © 2006-2010 Mikkosoft Productions, Mikko Rasa
+Distributed under the GPL
+*/
+
#ifndef MARKLIN3D_TRACK_H_
#define MARKLIN3D_TRACK_H_
#include <list>
-#include <msp/gl/color.h>
+#include <msp/gl/renderable.h>
#include <msp/gl/vertexarray.h>
#include <msp/gl/vertexarraybuilder.h>
#include "libmarklin/track.h"
#include "libmarklin/trackpart.h"
+#include "object.h"
namespace Marklin {
-class Track3D
+class Endpoint3D;
+class Layout3D;
+class Path3D;
+class TrackType3D;
+
+class Track3D: public Object3D, public Msp::GL::Renderable
{
private:
- Track &track;
- Msp::GL::Color color;
- std::vector<Point> border;
- Msp::GL::VertexArray varray;
- std::vector<unsigned> base_seq;
- std::vector<unsigned> rail_seq;
- std::vector<std::vector<unsigned> > route_seq;
- unsigned quality;
+ Layout3D &layout;
+ Track &track;
+ const TrackType3D &type;
+ std::vector<Endpoint3D *> endpoints;
+ Path3D *path;
public:
- Track3D(Track &, unsigned);
+ Track3D(Layout3D &, Track &);
+ ~Track3D();
- void set_color(const Msp::GL::Color &c) { color=c; }
- void set_quality(unsigned);
- void get_bounds(float, Point &, Point &) const;
+ Layout3D &get_layout() const { return layout; }
Track &get_track() const { return track; }
- void render() const;
- void render_endpoints() const;
- void render_route(int) const;
-private:
- void prepare_render() const;
- void build_object();
- void build_part(const TrackPart &, Msp::GL::VertexArrayBuilder &, unsigned &);
+ const TrackType3D &get_type() const { return type; }
+ void get_bounds(float, Point &, Point &) const;
+ Path3D &get_path() { return *path; }
+
+ virtual Point get_node() const;
+ virtual bool is_visible() const { return true; }
+
+ void apply_matrix() const;
+ virtual void render(const Msp::GL::Tag &) const;
};
} // namespace Marklin