Currently, I am in the process of developing a small 3D game that incorporates a spline for generating randomized tracks. To better explain this concept visually, think of games like Impossible Road and Audiosurf. I started this project about a week ago using Godot but switched to Three JS recently because I find TypeScript easier to work with compared to GDScript.
Both Godot and Three provide bezier spline classes which I found helpful. I began building my spline with cubic beziers by defining various "prefab segments" such as turns and loops. By randomizing the sequence of these segments, I aim to create dynamically generated tracks similar to Impossible road.
Initially, working on a flat plane (XZ), where the track is one-dimensional, went smoothly. However, when I introduced height variance into the equation, complications arose. My primary objective is to ensure a consistent descent speed along the spline, maintaining uniform displacement over the y-axis per distance covered on the XZ plane.
While exploring methods to implement descending slopes on the spline, traditional rotation techniques proved ineffective due to the curve's structure. This led me to contemplate how to add 'y' values for descent while ensuring continuity between curve segments.
I have encountered challenges in calculating the rate of descent elegantly for curves since simple linear adjustments do not apply directly to curved surfaces. It seems traditional approaches geared towards straight line segments are insufficient for managing dynamic curves efficiently.
My current focus lies in unraveling the intricacies of implementing continuous descents within bezier splines effectively. Despite researching extensively, I remain unable to find conclusive answers or resources addressing this specific issue.
Moreover, I am contemplating whether utilizing B-Splines or Catmull-Rom Splines might offer more straightforward solutions for creating seamless paths. While aware that other types of splines could potentially simplify the process, adapting my segment definitions to fit their requirements presents another obstacle.
If you're interested in delving deeper into the technicalities, feel free to explore my complete code repository on GitHub: https://github.com/thomasboyt/rascal