159.235 Assignment 3 - A 3D Graphics Scene
This assignment covers the concepts of coordinate transformations (in homogeneous coordinates),
ray tracing, illumination shading, and texture mapping.
On the Stream site, are provided some startup .java code together with some images you
can use as texture maps.
? Bring up IntelliJ and create a new project - call it Assignment3 (or whatever you like).
? In your project, create a new package called nz.ac.massey.graphics.toybox
? Copy all the .java files from Stream in to the package folder in IntelliJ.
? Copy the images into the top level folder of your project.
? Run Main.java from IntelliJ. You should see a JPanel/Jframe with a little blue square
at the centre. This is the view of the graphics scene from the point-of-view of an
imaginary camera placed on the z-axis and looking down.
? Have a look at the code and read the comments and figure out what is going on. Note
that the planar surface is rendered by the ray tracing method.
? Our initial graphics scene comprised just of a unit xy-plane centred on the world
coordinate origin. Try changing the size, orientation, and displacement of the plane
and see what happens.
? Try changing the camera position and see what happens.
? Try and create 6 planes and manipulate them so that they form the 6 faces of a cube.
The assignment proper
The project is incomplete in that it doesn’t implement visibility, ray tracing on spherical
surfaces, illumination shading, and texture mapping.
1. Modify the Camera class to implement the technique of z-buffering for visibility. See
the lecture notes on how it works.
2. Complete the code for the Sphere class to implement ray tracing for spherical surfaces.
Note that in this class you are working in local coordinates of the surface object.
3. Complete the calcShading() method in the Surface class. This should calculate the
correct shading factor, to apply to a colour, according to the standard local illumination
4. This class holds a BufferedImage that holds a texture image and allows one to pick a
colour from the image given the normalized texture coordinates (u, v). Complete the
implementation of the pickColour() method.
With these tasks complete, use your project to generate a realistic 3D graphics scene comprising
planar and spherical surfaces.
To get high marks you should showcase the following:
? A plane surface with a texture pasted on it.
? The visible faces of a uniform colour cube correctly placed and shaded.
? A uniform colour sphere with a shiny surface (ie specular highlight)
? A sphere with a texture pasted on it (eg the beachball)
To get full marks you should generate a scene that adds more to the above. Marks will be
awarded for initiative. Be creative!
? Do not use OpenGL. Do not use Java 3D. Do not use java.awt.GradientPaint.
? A graphical user interface is not required in this assignment. Your program should
directly display the rendered scene to the screen upon running the program. An additional
class Display is provided to do that.
? This assignment will count up to 15% of your final grade.
? Due date: 2019 October 20, 11:55 pm.
You are not required to do any of the following here. However, it is interesting to
consider how this assignment could be extended:
? More realism would be achieved if we could render the shadows of objects onto other
surfaces. How could this be done?
? Here, a simple texture mapping procedure is used where the texture images are sampled
to the nearest pixel. You may (or may not) see some aliasing. How could the texture
mapping be improved to deal with this?
? What other types of surfaces could be added to this framework? Consider for example,
cones, torii, etc.
? Similarly, how could could one of the wireframe modelled objects be placed into the