summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2021-02-14 14:16:17 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2021-02-14 14:18:36 +0000
commitfcfc640551ae27043fdb9ec8132670f5effd67fa (patch)
treefec5ea14f981cae8f766b81bbd7420c35896954f
parentSwap application of rotX and rotY (diff)
downloadilt-fcfc640551ae27043fdb9ec8132670f5effd67fa.tar.bz2
ilt-fcfc640551ae27043fdb9ec8132670f5effd67fa.tar.xz
ilt-fcfc640551ae27043fdb9ec8132670f5effd67fa.zip
Apply pitch to vehicles on a link
-rw-r--r--application/main.cpp2
-rw-r--r--game/network/rail.cpp6
2 files changed, 4 insertions, 4 deletions
diff --git a/application/main.cpp b/application/main.cpp
index 35d834d..30b4a44 100644
--- a/application/main.cpp
+++ b/application/main.cpp
@@ -67,7 +67,7 @@ public:
auto rl = world.create<RailLinks>();
{
- const glm::vec3 j {-1100, 5, -1100}, k {-1100, 5, -1000}, l {-1150, 10, -1050}, m {-1050, 10, -1050};
+ const glm::vec3 j {-1100, 5, -1100}, k {-1100, 15, -1000}, l {-1150, 30, -1050}, m {-1050, 10, -1050};
rl->addLink<RailLinkStraight>(j, k);
rl->addLink<RailLinkCurve>(l, k, glm::vec2 {l.x, k.z});
rl->addLink<RailLinkStraight>(l, m);
diff --git a/game/network/rail.cpp b/game/network/rail.cpp
index 3b31204..56feec0 100644
--- a/game/network/rail.cpp
+++ b/game/network/rail.cpp
@@ -102,7 +102,7 @@ RailLinkStraight::positionAt(float dist, unsigned char start) const
const auto es {std::make_pair(ends[start].first.get(), ends[1 - start].first.get())};
const auto diff {es.second->pos - es.first->pos};
const auto dir {glm::normalize(diff)};
- return Transform {es.first->pos + dir * dist, {0, vector_yaw(diff) /*, std::atan2(diff.x, -diff.z)*/, 0}};
+ return Transform {es.first->pos + dir * dist, {-vector_pitch(dir), vector_yaw(dir), 0}};
}
RailLinkCurve::RailLinkCurve(const NodePtr & a, const NodePtr & b, glm::vec2 c) :
@@ -147,6 +147,6 @@ RailLinkCurve::positionAt(float dist, unsigned char start) const
const auto relPos {glm::vec3 {std::cos(angArc), 0, -std::sin(angArc)} * radius};
const auto relClimb {
glm::vec3 {0, -centreBase.y + es.first->pos.y + ((es.second->pos.y - es.first->pos.y) * frac), 0}};
-
- return Transform {relPos + relClimb + centreBase, {0, normalize(ang + dirOffset[start]), 0}};
+ const auto pitch {vector_pitch({0, (es.first->pos.y - es.second->pos.y) / length, 0})};
+ return Transform {relPos + relClimb + centreBase, {pitch, normalize(ang + dirOffset[start]), 0}};
}