From 7fe7a5a1697d428532e002dfb95baaf5192af477 Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Wed, 3 Mar 2010 08:37:34 +0000 Subject: [PATCH] Bit more progress on getting train to go up and down --- src/SlopeTrack.cpp | 20 +++++++++++++++----- src/Train.cpp | 2 +- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/SlopeTrack.cpp b/src/SlopeTrack.cpp index 6ea5833..4095844 100644 --- a/src/SlopeTrack.cpp +++ b/src/SlopeTrack.cpp @@ -188,8 +188,17 @@ void SlopeTrack::transform(const track::TravelToken& token, double delta) const { assert(delta < length); + debug() << "flip=" << flip + << " axis=" << axis + << " direction=" << token.direction; + + debug() << "f(0)=" << curve(0.0f) + << " f(0.5)=" << curve(0.5f) + << " f(1.0)=" << curve(1.0f); + //if (token.direction == -axis) - // delta = length - delta; + if (flip && token.direction == axis) + delta = length - delta; const float curveDelta = delta / length; @@ -198,13 +207,14 @@ void SlopeTrack::transform(const track::TravelToken& token, double delta) const // const double xTrans = axis == axis::X ? delta : 0; // const double yTrans = axis == axis::Y ? delta : 0; - // const float along = - // token.direction == -axis ? 1.0f - curveValue.x : curveValue.x; + const float along = + (/*token.direction == axis && */flip) ? 1.0f - curveValue.x : curveValue.x; + - const float along = curveValue.x; + //const float along = curveValue.x; const float xTrans = axis == axis::X ? along : 0.0f; - const float yTrans = curveValue.y; + const float yTrans =curveValue.y; const float zTrans = axis == axis::Y ? along : 0.0f; glTranslated(static_cast(origin.x) + xTrans, diff --git a/src/Train.cpp b/src/Train.cpp index 9ce0230..593e3e2 100644 --- a/src/Train.cpp +++ b/src/Train.cpp @@ -116,7 +116,7 @@ Train::Train(IMapPtr aMap) // Bit of a hack to put the engine in the right place move(0.275); - for (int i = 1; i <= 5; i++) + for (int i = 1; i <= 0; i++) addPart(loadWaggon("coal_truck")); smokeTrail = makeSmokeTrail(); -- 2.39.2