I am using a standard heightmapped procedural terrain in my project. However, I want the terrain to appear spherical when the user zooms out. This is an attempt to simulate the appearance of a spherical planet. Here is my current algorithm:
//get the direction from the "planet" center to this vert
Vector3 sphereCentertoVertPosition = vert.Position - SphereCenter;
sphereCentertoVertPosition.Normalize();
//our rotation axis is the cross between the direction from this vert to the planet center and the root (center of the terrain) to the planet center
RotationAxis = Vector3.Cross(sphereCentertoVertPosition, sphereCenterToRootPosition);
//the amount we rotate is based on the distance of this vert from the center of the terrain
Vector3 fromCenter = vert.Position - Root.Position;
float amount = (fromCenter.Length() / ((myTextureWidth / Scale) / 2)) * (float)Math.PI;
Quaternion rot = Quaternion.CreateFromAxisAngle(RotationAxis, amount);
Vector3.Transform(ref vert.Position, ref rot, out vert.Position);
My main concern is that the rotation axis is not correct. Theoretically, should it be the cross between the vert-to-planet-center and the terrain-center-to-planet-center?