### CPE 474 Final Project - Winter 2015 (Sueda Sensei)

The spline road from a distance.

Goals

To replicate realistic roads using spline curves.
To become familiar with building meshes.
To gain experience working with textures and texture coordinates.
To practice complex vector mathematics.

Features

1. Catmull-Rom Spline Roads. This is the main part of the project. The curves are created using Catmull-Rom splines. The triangles are drawn using combinations of tangents, normals, and binormals of the curve.

2. Basic driving and collision detection. These two components are both remnants of my prior CPE 471 project. The collisions are achieved through axis-aligned bounding boxes and the driving is achieved with way over-simplified physics.

3. Textures and shading. I added basic textures to my world and blinn-phong shading. The ambient and diffuse colors are both acquired using a ratio of the texture color and a provided color.

Design

To make the spline roads, I began by making a Catmull-Rom spline curve. Along with the key points, I included a sort of "normal" vector that would represent the direction that the top of the road points to. From there, I used arc length parametrization to obtain evenly spaced points and linear interpolation to find the pseudo normal at each of those points. By taking the cross product of the fake normal vector and the tangent of the curve, I acquired a new vector that could be used to finding the two edge points of each side of the road at that point in the road. After finding these vertices, I logically ordered them into triangles and made my mesh. This made up the top mesh. I used the same method to make a bottom mesh. The top mesh was then textured with a repeating road pattern while the bottom mesh was textured with a simple concrete pattern. In order for my texture coordinates to overlap for the repeating texture, I split my meshes into segments. I found the normal vectors for shading by taking the cross products of two vectors between subsequent vertices along the road.

Future Work

The main task I would like to complete to make this project whole would be to implement collision detection on the road, allowing my vehicle to drive on the curves. Additionally, I would like to implement realistic driving physics for the vehicle.

Screenshots

A look at the triangles.

Top and side view of the road.

A banked curve between two spheres.

Resources

Examples and files provided with the course: tinyobjloader, Image.cpp, Shape.cpp, Texture.cpp, Program.cpp, as well as some camera code
Primitive shapes provided with the course
Textures from texturise.blogspot.com, jennhacker.blogspot.com, turbosquid.com