Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
CS293 Graphics, Lab 4, Elementary Texture Mapping
In the AP labs don't forget you need to set your environment path as in the first lab to point to a 
folder where the JOGL dll files are. Note, if you add any spaces immediately after a ';' in a path 
variable it does not work. Also, Java will not automatically detect where the files are. These labs 
are set up using NetBeans 5.0, although to the best of my knowledge they work fine with 
NetBeans 5.5.
Use a web browser (preferably Firefox or Opera) to open the web page for the course:
http://www.computing.surrey.ac.uk/courses/cs288/graphics.html
Download these files from the course web site:
● TeaPotOne.zip
Fixing the JOGL library call
First uncompress the TeaPotOne.zip file in your CS293 course directory, or any folder where 
you want to keep lab code. Open the folder as a project in NetBeans. You should get error 
messages at this point as the JOGL library that is referred to in the project properties does not 
exist in your installation. 
Correct the errors as you did for the previous lab by changing the JOGL library call. 
Trying Texture maps.
Run the project. Read the help window, and use the arrow keys to move around and get used to 
the layout.
The Renderer class in the application contains a field: private int textures[] = new 
int[textureNames.length];
Use the 'find usages' option from the menu (the one you get when you right click in the source 
code) to find where this field is used. Now change the code so that each of the squares around 
the teapot displays a different image:
Next consider the code for the central square:
   gl.glPushMatrix();
            gl.glBindTexture(GL.GL_TEXTURE_2D, textures[1]);
            gl.glTranslatef(0.0f, 0.0f, bck -39.0f);
            gl.glScalef(((float)imageW[filter])/((float)imageH[filter]), 1.0f, 1.0f);
            gl.glBegin(GL.GL_QUADS);
            gl.glNormal3f(0.0f, 0.0f, 1.0f);
            gl.glTexCoord2f(0.0f, 0.0f); 
            gl.glVertex3f(-15.0f, -15.0f, 15.0f);
            gl.glTexCoord2f(1.0f, 0.0f);
            gl.glVertex3f(15.0f, -15.0f, 15.0f);
            gl.glTexCoord2f(1.0f, 1.0f);
            gl.glVertex3f(15.0f, 15.0f, 15.0f);
            gl.glTexCoord2f(0.0f, 1.0f);
            gl.glVertex3f(-15.0f, 15.0f, 15.0f);
            gl.glEnd();
        gl.glPopMatrix();
By changing the values in  the  glTexCoord2f method calls only, make the central image appear 
as if reflected. Remember in the lecture we stressed that the texture coordinates had to be chosen 
so that the corners of the image appear in the same order as the corners of the square they are 
attached to. So to get a reflection you need to reverse this order. 
Next using the same technique make the image appear upside down.
Next change the Renderer and InputHandler classes so that a left mouse click makes each object 
in the scene swap its image with the object clockwise one place to the right. 
Advanced: can you get a left mouse click to cause each square to rotate 90-degrees, then change 
image as above, then rotate back to the original position with the new image?