X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2F3d%2Ftrack.cpp;h=ee7671c8886ef337e6fee36ebe9d05d3d2b9b0e1;hb=18c529dfdd34e07f4f6021151ddce29fa85437bc;hp=9797c4a67369c90a7e6d05b07495171fd7afdcfe;hpb=bde934f7d5ba07a9442a305192e10024820d13ed;p=r2c2.git diff --git a/source/3d/track.cpp b/source/3d/track.cpp index 9797c4a..ee7671c 100644 --- a/source/3d/track.cpp +++ b/source/3d/track.cpp @@ -14,13 +14,11 @@ using namespace Msp; namespace R2C2 { Track3D::Track3D(Layout3D &l, Track &t): + Object3D(l, t), GL::ObjectInstance(l.get_catalogue().get_track(t.get_type()).get_object()), - layout(l), track(t), - type(layout.get_catalogue().get_track(track.get_type())), - path(new Path3D(*this)) + type(layout.get_catalogue().get_track(track.get_type())) { - layout.add_track(*this); layout.get_scene().add(*this); const vector &type_eps = track.get_type().get_endpoints(); @@ -38,9 +36,6 @@ Track3D::Track3D(Layout3D &l, Track &t): Track3D::~Track3D() { - delete path; - - layout.remove_track(*this); layout.get_scene().remove(*this); for(vector::iterator i=endpoints.begin(); i!=endpoints.end(); ++i) @@ -53,22 +48,12 @@ Vector Track3D::get_node() const const Vector &minp = bbox.get_minimum_point(); const Vector &maxp = bbox.get_maximum_point(); - return track.get_position()+rotated_vector((minp+maxp)/2.0f, track.get_rotation())+Vector(0, 0, 0.02); -} - -GL::Matrix Track3D::create_matrix() const -{ - GL::Matrix matrix; - matrix.translate(track.get_position()); - matrix.rotate(track.get_rotation(), 0, 0, 1); - matrix.rotate(track.get_slope()/track.get_type().get_total_length(), 0, -1, 0); - - return matrix; + return matrix*((minp+maxp)/2.0f+Vector(0, 0, 0.02)); } void Track3D::setup_render(Msp::GL::Renderer &renderer, const GL::Tag &) const { - renderer.matrix_stack() *= create_matrix(); + renderer.matrix_stack() *= matrix; } void Track3D::link_changed(unsigned i, Track *trk)