#include "libmarklin/tracktype.h"
#include "endpoint.h"
#include "layout.h"
+#include "path.h"
#include "track.h"
#include "tracktype.h"
Track3D::Track3D(Layout3D &l, Track &t):
layout(l),
track(t),
- type(layout.get_catalogue().get_track(track.get_type()))
+ type(layout.get_catalogue().get_track(track.get_type())),
+ path(new Path3D(*this))
{
layout.add_track(*this);
layout.get_scene().add(*this);
- const vector<Endpoint> &type_eps = track.get_type().get_endpoints();
+ const vector<TrackType::Endpoint> &type_eps = track.get_type().get_endpoints();
for(unsigned i=0; i<type_eps.size(); ++i)
endpoints.push_back(new Endpoint3D(*this, i));
}
Track3D::~Track3D()
{
+ delete path;
+
layout.remove_track(*this);
layout.get_scene().remove(*this);
return Point(pos.x+c*center.x-s*center.y, pos.y+s*center.x+c*center.y, pos.z+0.02);
}
-void Track3D::render(const GL::Tag &tag) const
+void Track3D::apply_matrix() const
{
- GL::PushMatrix push_mat;
-
const Point &pos = track.get_position();
float rot = track.get_rotation();
- glTranslatef(pos.x, pos.y, pos.z);
- glRotatef(rot*180/M_PI, 0, 0, 1);
- glRotatef(track.get_slope()/track.get_type().get_total_length()*180/M_PI, 0, -1, 0);
+ GL::translate(pos.x, pos.y, pos.z);
+ GL::rotate(rot*180/M_PI, 0, 0, 1);
+ GL::rotate(track.get_slope()/track.get_type().get_total_length()*180/M_PI, 0, -1, 0);
+}
+
+void Track3D::render(const GL::Tag &tag) const
+{
+ GL::PushMatrix push_mat;
+
+ apply_matrix();
glPushName(reinterpret_cast<unsigned>(this));