The way I’m generating maps in my v. simple space flying game is to have a parametric function trace out points and to generate toruses (tori? . Another function returns the tangent vector at any given point on the parametric curve so that I can align the tori with it.

``````/**
* Handles the generation of game
* levels based upon any parametric
* function.
*/
public void genLevel()
{
for(float t = 0; t &lt;= 2*M_PI; t += (2*M_PI / 8))
{
Vector2 v = cqLevelOneFunc(t);
float x = v.getx();
float z = v.gety();

// Calculate the amount to rotate each torus by
// so they are parallel to the tangent vector.
float rotateBy = 0.0f;
Vector3 forward = new Vector3(0,0,1);			// Vector pointing along z-axis.
Vector3 tangVector = cqLevelOneTangent(t);		// Tangent vector at this t value.
float dot = gameUtils.dot(forward, tangVector);	// Calculate dot product.
// Calculate theta.
float cos = dot / (gameUtils.length(forward) * gameUtils.length(tangVector));
float theta = (float) Math.toDegrees(Math.acos(cos));

Torus tor = new Torus(this,x * 20,0,-z * 20,theta,0,1,0);