   Cube to Sphere (Need help) : Update
  Hey gamedevers,I am currently trying to map a cube to sphere by the method described onhttp://mathproofs.blogspot.com/2005/07/mapping-cube-to-sphere.htmlunfortunately my maths is kind of dodgy at best and when it is saying using a unit cube from -1 to 1, is it possible to go from say -m_patchSize to m_patchSizeor 0 to m_patchSize, i don't quite understand it, m_patchSize is the size of the side of a cube i am drawing.Or do i have to do it from -1 to 1 and scale it later on in the equation?Thanks for any help guys.PS.Sorry here is the code i am using.With this equation X seems to get some correct values, but  Y and Z all i get is-1.#INFVector3 FractalMesh::SpherizePoint(Vector3 point){//====================================================================//Maths refernced from//http://mathproofs.blogspot.com/2005/07/mapping-cube-to-sphere.html//====================================================================float x = point.getX();float y = point.getY();float z = point.getZ();float xPrime, yPrime, zPrime;float xp, yp, zp, added;float yzp, zxp, xyp;//cout << "In X: "  << x << " Y: " << y << " Z: " << z << endl;//Mapping the point to a sphere//Getting the altered X Y and Z co-ordinatesxp = (x * x) / 2;yp= (y * y) / 2;zp = (z * z) / 2;yzp = ((y * y) * (z * z)) / 3;zxp = ((z * z) * (x * x)) / 3;xyp = ((x * x) * (y * y)) / 3;xPrime = x * (sqrt(1 - (yp - zp + yzp)));yPrime = y * (sqrt(1 - (zp - xp + zxp)));zPrime = z * (sqrt( 1 - (xp - yp + xyp)));point.setX(x);point.setY(y);point.setZ(z);return point;}UPDATE: Now i have the values working now so that it is a plane, but the offset to make it bluge out into a sphere is now my problem, i have tried passing in a radius from -1 to 1, but it doesn't quite work , it gives me a diagonal curve...sort of...[Edited by - Deftoned on August 17, 2008 2:25:15 AM]
  Hi,how I do it is actually very simple, and I did it very quickly once i worked it out. First you need a tesslated cube. Mine is made of 6 vertex grids. How the grids get into cube form does not really matter, although I would reccommend using a numerically accurate method.Once you have the grid the point on the sphere can be computed in several ways. My algorithm works like this:For Each Grid    For Each Point On the Grid   Compute The Vector from the Center of the Cube to the Point   normalize the vector into a variable (say norm for example)   set the spherical vertex position to be vpos = norm * sphere_radius;    next pointnext gridthis method works fine for me ... in fact I don't even multiply by the sphere radius andinstead use the World Transform Matrix to set the scale when rendering. Hope this helps.   