0

I need help figuring out how to create a planet (spherical) using quads. I need it to be quads due to the method the rest of my coding uses. However I somehow seem to be screwing up badly somewhere and can't figure out where. SPLIT_FACE is the amount of times I split a side of the cube's face. x and y both range from 0 to 4*SPLIT_FACE.

I want a cube almost like the cube they have in this image. Does anyone know what I need to do and what I'm doing wrong?

float polar[]= new float[]{(float) (((x)*Math.PI)/(2*SPLIT_FACE)),(float) ((y)*Math.PI/(2*SPLIT_FACE)),(float) Math.sqrt(SIZE*SIZE/2)};                             
    //this.rotY = (float) (polar[1]*(360)/(2*Math.PI)); // temporary values for 2D plane
    //this.rotX = (float) (polar[1]*(360)/(2*Math.PI));
    this.rotZ = (float) (polar[0]*(360)/(2*Math.PI));
    this.x =-(float) (Math.cos(Math.toRadians(rotZ)))*(polar[2]);
    this.y = -(float) (Math.sin(Math.toRadians(rotZ)))*polar[2];
    //this.z = -(float) (Math.sin(Math.toRadians(rotY)))*polar[2];
    rotZ+=45;

I want the faces to still overlap. This is basically what I did, but I want it in 3 dimensions, i.e. also rotating about the y-axis. (Many faces on the other side are not visible, but are there, they've been culled)

Community
  • 1
  • 1
betarunex
  • 48
  • 1
  • 10
  • why you are not using spherical equations instead of polar? now you are computing 2D position and rotate it in the same plane so no Z coordinate change which makes the output planar ... look here is what you want http://stackoverflow.com/a/25082674/2521214 especially read edit1 – Spektre Mar 02 '15 at 08:09
  • if you do not need to have the same area per quad then tessellate sphere by the same angle step ... (that will eliminate the holes between layers of quads with different quad counts – Spektre Mar 02 '15 at 08:16
  • http://mathproofs.blogspot.de/2005/07/mapping-cube-to-sphere.html – Dawnkeeper Mar 02 '15 at 11:14

0 Answers0