I love RCT and would love to help out, but unfortunately my programming experience ends with some embedded C code and a C++ DOS Tic-Tac-Toe game. However, I can help a little with the in game physics.
First, I'm assuming you guys aren't developing a full blown physics engine and are only adding in bits and pieces where it's needed, (i.e. you're not detecting collisions between every object at all times) but will only add it for roller coasters and some other rides.
So the first thing you'll probably want is to get a roller coaster moving along the track. The formula for finding velocity is V = Vi + at, where 'a' equals acceleration 't' is equal to time and Vi is the initial velocity. To find the acceleration you just need the sine of the angle the car is tilted at (with respect to the horizontal) multiplied by the force of gravity. So for example, a car titled at 60 degrees, the acceleration would be sin(60) * 9.8m/s = 8.48m/s.
Now you may have noticed that v = at is a linear equation, it's meant for a constant acceleration, and a roller coaster is far from constant. So what you can do is find the velocity for little increments of time. The smaller the increments of time, the smoother and more accurate this method becomes. So first you figure how many times per second you want to update the cars velocity. Say we choose 100, the 't' in the equation in the inverse of the number updates per second, so 1/100 = 0.01 = t. 50 times per second would be 0.02 and so on...
After every
increment you add it to the total velocity and you're left with a accurate approximation
of the cars actual speed. In code it might look something like this,
V = Vp + sin(angle) * 9.8 *
0.01;
Vp = V;
Vp here can be called 'velocity, previous' and I'm assuming 100 calculations
per second.
To get this to work properly you'll need to know whether the car is moving up or down, so you can tack on a negative sign to one of the directions (if you don't the car will never slow down, it'll just go faster and faster). Or, you can use the full 360 degrees (probably easiest). So instead of saying it's heading 90 degrees straight down, use 270 degrees and you'll automatically get your negative sign.
If you guys find this helpful I can figure out some more stuff, like multiple cars (think I have that one figured) finding G-forces etc...
- Besides gravity, there is also air friction which is needed to prevent you from accelerating too much (ie there is a terminal velocity).
- It would be good if there was some rollercoaster type data involved too, otherwise wooden rollercoaster and steel rollercoasters would behave a lot alike. I am thinking "mass" and "wheel friction", but perhaps there are other interesting parameters that could be used?
angle:
- My current approach does not start from an angle, it starts from a path in 3D, coded as a sequence of cubic spline bezier curves.
- The roll is also provided.
- From these two, the pitch and yaw should be computed. Together with the roll that gives the sprite to draw.
- The gravity vector needs to be computed too (but that's easy; it's simply the z component of the movement, I think).
Train of cars:
- When you connect several cars together, the train of cars as a whole moves.
- Could the distribution of weight be used too (passengers may use only a few seats)?
V = Vp + [ (Vcar1 + Vcar2 +... VcarN) / N ]
Where 'N' is the number of cars and VcarN = sin(pitch angle of that car) * 9.8 * t (what 't' can be was described in my first post).
The only thing distribution of people would effect would be, say when a coaster is cresting a hill real slow, if all the people were sitting up front the train would have it make it over, or if all the people were in the back, it wouldn't make it. It would be a lot of work for a small feature.
Passenger experience:
- Nausea needs to be computed from the physics.
- Also something called "excitement" or perhaps "scaryness" of the coaster.
- Perhaps other nice parameters can be computed too? I don't know how coasters are rated but I guess someone has invented a way to give a coaster a grade.
That's a bit crude, air friction also means you approach the upper limit slowly.
I'd have to look it up, but doesn't mass play a role in the conversion from g to v ?
No, I think pitch is not enough. Think about roll of 90 degrees, pitch has no influence any more then.
As for cubic bezier stuff, it's juts a 3rd degree polynomial, see also http://en.wikipedia.org/wiki/B%C3%A9zier_curve
"sequence" just means you have more than one to describe the path (useful for very bendy tracks). For physics, just considering one bezier is sufficient, selecting which one to use is a matter of careful administration.
I am sure someone will file a bug report for it :p
But indeed, not needed for an initial implementation. It can always be improved later.
A more interesting problem is the "scaryness" or "excitement" or whatever you want to call it. Absolute no idea how to derive a number for that :(