Help understanding how to get/set informaion about coaster trains?

60 views
Skip to first unread message

Crof

unread,
Apr 6, 2014, 12:39:09 PM4/6/14
to freer...@googlegroups.com
Currently I'm trying to make the trains obey gravity (acceleration/deceleration), but in the near future I'd like to do other things like have the station platforms work like they should (slow train, briefly stop, restart). 

The problem I'm having is I'm not 100% sure how to get relevant information about a roller coaster car or the entire train.  Current speed was easy (this->speed I believe), but some more useful things would be
  • angle of the car compared to horizon (I was hoping z_der would give me this, but that doesn't seem to be the case...maybe I'm not understanding whats in the variable properly)
  • what type of track is below this car
  • what type of track is ahead of this car/train (important for hill lifts)
  • weight of car (not implemented yet I assume?)
  • position of car in train (if multi-car trains are implemented yet)

I wanted to post here to see if anyone could give me some guidance.  I'm working through the code to look for clues, but I'm not sure the solutions I'm finding for getting this information are the best ones.


Thanks!


James L

unread,
Apr 6, 2014, 2:01:03 PM4/6/14
to freer...@googlegroups.com
I'm no programmer, but I was working on ways to take the track information and apply it to the formulas in the 'Game Physics' thread. Kind of took a break for a while. I could help come up with some algorithms that may be of use though.


z_der: I don't have the code in front of me but 'z_der' sounds like it may be short for 'z_derivative.' If it is, it probably gives you the slope of the line that the car is pitched at. You can use the slope to find the angle though, it'll just take another step.

Weight of the car: Not needed for physics calculations.

Position of car: Like car1, car2, etc...?

Alberth

unread,
Apr 8, 2014, 2:05:55 PM4/8/14
to freer...@googlegroups.com
Hmm, so many difficult questions :p

z_der is indeed the derivative of z (ie vertical speed of the car). The value is however not normalized, so you need to relate it to the horizontal derivative sqrt(x_der*x_der + y_der*y_der) to compute the angle.

The coaster instance has an array of PositionedTrackPiece (this->pieces) which is an array of track pieces (the pieces you can build a coaster track with), each with a start position in the world. If you can make a loop with these positioned pieces (see MakePositionedPiecesLooping) it's a coaster that can have cars on them, a CoasterTrain, to be precise. It has one or more connected cars (this->cars.size()), and it knows the position at the end of the last car (this->back_position) and the length of a car + in-between length iirc. void CoasterTrain::OnAnimate(int delay) computes the position finds the track-piece etc.

Reply all
Reply to author
Forward
0 new messages