Created
September 3, 2014 02:15
-
-
Save Corosauce/39fada3cffb60d8171df to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float radius = 5F; | |
int lats = 10; | |
int longs = 10; | |
//quad based Icosahedron | |
int i, j; | |
for (i = 0; i <= lats; i++) { | |
double lat0 = Math.PI * (-0.5D + (double) (i - 1) / lats); | |
double z0 = Math.sin(lat0); | |
double zr0 = Math.cos(lat0); | |
double lat1 = Math.PI * (-0.5D + (double) (i) / lats); | |
double z1 = Math.sin(lat1); | |
double zr1 = Math.cos(lat1); | |
GL11.glBegin(GL11.GL_QUAD_STRIP); | |
for (j = 0; j <= longs; j++) { | |
double lng = 2D * Math.PI * (double) (j - 1) / longs; | |
double x = Math.cos(lng); | |
double y = Math.sin(lng); | |
//GL11.glColor3d(rand.nextDouble(), rand.nextDouble(), rand.nextDouble()); | |
GL11.glColor3d(i / (double)lats, j / (double)longs, 1D); | |
GL11.glNormal3d(x * zr0, y * zr0, z0); | |
GL11.glVertex3d(x * zr0, y * zr0, z0); | |
GL11.glNormal3d(x * zr1, y * zr1, z1); | |
GL11.glVertex3d(x * zr1, y * zr1, z1); | |
} | |
GL11.glEnd(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment