• 15
• 15
• 11
• 9
• 10

# Meshing a roller coaster from a spline

This topic is 2507 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.