/** Draw the old CSE logo */ import javax.media.opengl.*; public class CSELogo { static double[][] logodata = { // initial positions of cubes {2,2,2},{1,2,2},{2,2,1},{2,0,2},{0,2,2},{2,2,0},{1,0,2},{-1,2,2},{2,-1,2}, {2,0,1},{2,2,-1},{2,-2,2},{0,0,2},{-2,2,2},{2,0,0},{2,2,-2},{1,2,-2}, {1,-2,2},{-1,0,2},{-2,1,2},{2,-2,1},{2,0,-1},{-2,2,1},{0,-2,2},{-2,0,2}, {2,-2,0},{2,0,-2},{-2,2,0},{2,-2,-1},{-2,2,-1},{-1,2,-2},{-1,-2,2}, {-2,-2,2},{2,-2,-2},{-2,2,-2}}; static double cuberadius = 0.35; // radius of cubes in logo //draw all the cubes in the logo public static void logo(GL gl) { for (int i=0; i < logodata.length; i++){ gl.glPushMatrix(); gl.glTranslated(logodata[i][0], logodata[i][1], logodata[i][2]); gl.glScaled(cuberadius,cuberadius,cuberadius); cube(gl); gl.glPopMatrix(); } } //data for one cube static float[][] cubeMats = { //face materials {0.4f, 0.0f, 0.0f, 1.0f}, //red {1.0f, 1.0f, 0.0f, 1.0f}, //yellow {0.0f, 0.0f, 1.0f, 1.0f} //blue }; static double[][] vertices = { //cube vertices {1,1,1}, {1,1,-1}, {1,-1,1}, {1,-1,-1}, {-1,1,1}, {-1,1,-1}, {-1,-1,1}, {-1,-1,-1} }; static int[][] faces = {// the faces //first one is material index rest are vertex indices {0, 0,2,3,1}, //right {0, 4,5,7,6}, //left {1, 0,1,5,4}, //top {1, 2,6,7,3}, //bottom {2, 0,4,6,2}, //front {2, 1,3,7,5} //back }; static double[][] facenormals = {// normals to each face {1,0,0}, {-1,0,0}, {0,1,0}, {0,-1,0}, {0,0,1}, {0,0,-1} }; static double[][] texCoord = {// texture coords for each face {0,0}, {0,1}, {1,1}, {1,0} }; //draw one cube - it has yellow, red and blue faces public static void cube(GL gl){ for (int f = 0; f < faces.length; f++){ gl.glMaterialfv(GL.GL_FRONT, GL.GL_AMBIENT_AND_DIFFUSE, cubeMats[faces[f][0]], 0); gl.glBegin(GL.GL_POLYGON); gl.glNormal3dv(facenormals[f], 0); //gl.glNormal3d(1,0,0); for (int i = 1; i < faces[f].length; i++){ gl.glTexCoord2dv(texCoord[i-1],0); gl.glVertex3dv(vertices[faces[f][i]], 0); } gl.glEnd(); } } }