Simulating a Roller Coaster via Splines

Pranav Rathod

March 27, 2024

In this project, I developed a 3D roller coaster simulation using OpenGL and Catmull-Rom splines. The simulation provides a first-person perspective of the ride while showcasing smooth curves, realistic lighting, and texturing.

Source Code

You can explore the source code for this project on my GitHub repository: https://github.com/pranavsrathod/roller-coaster-splines.

Project Overview

This project was a significant step in understanding and implementing Catmull-Rom splines and OpenGL core profile techniques. It allowed me to create a dynamic and immersive roller coaster simulation in a first-person view. Below are the key aspects of the project:

  • Spline-Based Track Generation: I used Catmull-Rom splines to design a realistic and smooth roller coaster track. The spline interpolation ensures the coaster follows a natural and visually appealing curve, using defined control points to generate continuous and smooth paths.
  • Shader Programming:
    • Texture Mapping: A custom texture shader was applied to the ground to enhance realism, simulating terrain textures effectively.
    • Phong Shading: The roller coaster rails were rendered with a Phong shading shader, which provided per-pixel lighting for depth and realism.
  • First-Person Perspective: The program simulates the experience of riding the roller coaster with a first-person camera. I implemented this using the Frenet Frame approach, dynamically adjusting the camera’s tangent, normal, and binormal vectors to ensure smooth and accurate orientation along the track.
  • Customizable Track Files: Users can load different spline files (e.g., `goodRide.sp`, `rollerCoaster.sp`) to experience various track designs. Each file modifies the control points, resulting in unique roller coaster experiences.
  • Animation Features: The project includes a pre-rendered animation of the roller coaster to showcase its functionality and aesthetics. Screenshots from the animation have been saved in the `AnimationFrames` folder.

Note: Due to specific tangent calculations (Sloan method), certain spline files like `circle.sp` and `lefturn.sp` may require manual adjustments in the `computeUpVector()` function for correct camera movement and orientation.

Citations

Special thanks to the following resources:

  • OpenGL Programming Guide for foundational rendering concepts.
  • WebGL documentation for shader programming insights.
  • Mathematics for 3D Game Programming and Computer Graphics for spline implementation guidance.