dimanche 1 mars 2015

Create spherical planet in lwjgl using quads



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)




Aucun commentaire:

Enregistrer un commentaire