Alexander Aseme
GitHub IconLinkedIn Icon

Rollercoaster Simulation

This is a 3D roller coaster simulation using Catmull-Rom splines and shader-based OpenGL rendering. The track is defined by a sequence of control points loaded from external spline files, and a camera smoothly animates along it in a first-person view. The roller coaster rail is rendered as a geometric mesh using triangle strips and shaded with a Phong lighting shader. Simultaneously, the scene includes a textured ground plane rendered with a second shader, demonstrating multi-shader rendering in a single OpenGL scene.

A Catmull-Rom spline defined the track's geometry, while the ride camera moved along it with correct orientation using tangent, normal, and binormal vectors. The rail geometry was rendered using triangle strips and a ground plane was rendered undeneath the rollercoaster.

Key Features

  • Spline-based rail track using Catmull-Rom interpolation
  • First-person ride camera with tangent-aligned orientation
  • Triangle-strip mesh generation of roller coaster rail
  • Dual shader programs for lighting (Phong) and textured ground
  • Phong shading with directional light on rail geometry
  • Textured terrain and animated ride experience
  • Animation output via frame-by-frame screenshots

Extra Credit Features

  • Element Arrays and triangle Strip Rendering: Building on the heighfiled project, I already had these implemented, though indexing the rails with triangle strips proved very difficult.
  • T-Shaped Rail Cross-Section: Initially rendered as just a rectangle, I further added a T-shaped cross-section to the rail geometry.
  • Double rails: Initially rendered as a single rail underneath the camera, I further created two parallel rails below the camera on either side.
  • Heightfield Renderer: I reused the heightfield renderer from the previous project to render the ground plane.
  • Colorfield-based Ground Shading: I used a colorfield to shade the ground plane in the vertex shader.

Technical Details

  • API: OpenGL 3.2 Core Profile
  • Language: C++ and GLSL
  • Special Skills: Spline math, writing shaders in HLSL, animation (by moving camera)

Project Demo