# Meshing a roller coaster from a spline

This topic is 2597 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I'm working on an open source theme park game, and need to know this. I have the bezier point function worked out:

 for(t=0;t<1;t+=tstep) P(t)=pow(1-t,3)*P1 + 3*pow(1-t,2)*t*P2 + 3*(1-t)*pow(t,2)*P3 + pow(t,3)*P4; 

(I will put this into a matrix form, but used a polynomial statement for clarity.) This gives me the center point for each progression along the spline, but does not give me orientation. I was thinking of stepping the roll, pitch and yaw angles evenly from start to finish, but I still need to rotate the track vertices somehow. Eulers seem to work for most types of track elements, if I go in the progression of roll -> pitch -> yaw, but quaternions would probably be better if I had any skill using them. Another problem is overall track orientation. Since Tracks will be rotated on the y axis (yaw), I need to add a yaw value to the base yaw.

My plan was to center a cross section of track at a certain center of gravity, like the rider's heart (if there was a middle seat). I would then rotate the cross-section by the <pitch,yaw,roll> angle triple, in the order I mentioned. I would start with the first cross section and extrude to the second, and then 3rd, 4th, ... all the way up to the last for the track segment specified by the 4 Bezier control points. is this a good way, or is there a better, streamlined version out there?

I know of the heading concept < right vector, up vector, forward vector > , but am unsure how to implement it in this algorithm.

BTW, we're planning to use Irrlicht engine for this game, so I have to do it in terms of its API.

##### Share on other sites
I can't delve deeply into the maths you're working with as it's far too late for me to try to understand but I do have one suggestion on getting the orientation of the track.

You've probably thought of this already but simply get the location of the previous (or next) point and then create a vector between it and the current point. Perhaps get the vector from the previous point to the current point and average it with the vector of the current point to the next point.

As for roll around the direction of the track that might have to be defined by the track designer or by some method that takes into account the current yaw around the vertical axes so when it goes around corners it rolls in that direction and such.

1. 1
2. 2
3. 3
4. 4
Rutin
17
5. 5

• 11
• 27
• 12
• 12
• 11
• ### Forum Statistics

• Total Topics
631407
• Total Posts
2999915
×