In this part of the lab, you will examine precipitation data
(alternatively, you may do temperatures) and present it in a way that could help someone, e.g.
a meteorologist,
understand and interpret the data.
The following may be found on the \\home\classes server (in gorr\cs445):
Create a top level folder in your netbeans project folder called "data". Place precip.clim.txt into that folder. RainData.java assumes that this is the path for the data file. If you place it somewhere else, you will need to make the appropriate change in RainData.java.
Begin by getting your code just to read in the data. Once that is done, please be sure to consider the following before you continue:
Due Dates:
Note, this part will not be turned in. It is intended to give you practice using lights and materials. Begin with SimpleOpenGL code with animation and a teapot, and try the following:
gl.glEnable(gl.GL_COLOR_MATERIAL); // uses glColor to set the color gl.glEnable(GL.GL_LIGHT0); gl.glEnable(GL.GL_LIGHTING);
float[] lightPosition = {10.0f, 0.0f, 2.0f, 1.0f}; gl.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, lightPosition,0);
float[] lightAmbient = {0.4f, 0.4f, 0.4f, 1.0f}; float[] lightDiffuse = {0.8f, 0.8f, 0.8f, 1.0f}; float[] lightSpecular = {1.0f, 1.0f, 1.0f, 1.0f}; gl.glLightfv(GL.GL_LIGHT0, GL.GL_AMBIENT, lightAmbient,0); gl.glLightfv(GL.GL_LIGHT0, GL.GL_DIFFUSE, lightDiffuse,0); gl.glLightfv(GL.GL_LIGHT0, GL.GL_SPECULAR, lightSpecular,0);Think about the meaning of ambient, diffuse, and specular; vary these parameters to see how the affect the image. Use these parameters to change the color of the light as well. Recall, if an RGB component of light is zero, then it zeros out that component of the surface color.
gl.glShadeModel(GL.GL_FLAT);vs
gl.glShadeModel(GL.GL_SMOOTH);
gl.glEnable(gl.GL_COLOR_MATERIAL)and instead create a material using
gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT, amb,0); gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_DIFFUSE, diff,0); gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_SPECULAR, spec,0); gl.glMaterialf(GL.GL_FRONT_AND_BACK, GL.GL_SHININESS, shine);where amb, diff, and spec are arrays of length 4 and shine is a single float. Experiment with different values. Can you create materials that represent surfaces such as plastic or brass or whatever. Note, without real reflection (e.g. ray tracing), it is hard to create objects that really look shiny.
All objects created after the above material properties are set, will have this material. If you want to use a second material, then you need to reset the parameters. In such a case, it helps to create your own Material class that stores values for a particular type of surface. Include a method that resets all of the above parameters (amb, diff, etc). This will make it easy to switch between materials.
You can do the same with lights, i.e. create your own Light class that stores the parameters of a particular light. This helps to keep your code clean so that it is easy to read, modify, and reuse in a later program.
Begin with either the algebraic surface or the DEM that you created several weeks ago. If you
don't have something you want to use, then begin with the code (steiner.java) on \\home\classes in gorr\cs445.
Have the object rotate so we can see all sides of it.
Then do the following:
gl.glNormal3dv(norm,0); gl.glVertex3dv(point,0);where normal and point are each arrays of doubles (length 3). In your code, be sure to include the line
gl.glEnable(GL.GL_NORMALIZE);to the init method in order to make sure the normals are normalized by opengl.
Due Date:
[top] [Schedule] [CS445 Home]