Skip to end of metadata
Go to start of metadata

Abstract

The goal of this assignment was to implement 3D transformations and perspective viewing. This involved writing new transformation matrix functions to apply to three dimensional images. It also required updating the module functions to include the three dimensional transformations. After implementing these changes we were able to create 3D images with a realistic perspective view:

Description of the Task

The task was to implement 3D images using our graphics system. In order to do this, there were three main tasks. The first was to implement 3D transformation matrices so that we could manipulate our images. Next, we had to create new module functions to include these 3D matrices. Finally, we had to implement the perspective viewing to give our 3D images a realistic view, where objects farther away in the image appear smaller.

How The Task Was Solved

The task consisted of three parts. The first task was to update the transformation matrix functions for application in 3D graphics. These matrices work the same way as 2D transformation matrices: they hold float values in different locations within the matrix, and are multiplied by point vectors. The locations of the float values determine how the point vector is transformed. The only difference between 2D and 3D matrices is that the 3D matrices hold more values to take into account transformations in the Z plane. In addition to the normal transformation matrices, a new transformation was added, Matrix_perspective, which transforms the matrix by a perspective matrix to make it appear correctly in the image.

The second part was to update the module functions to include functions for 3D transformations. These were very similar to the functions for 2D module transformations, except they took in three float parameters to account for the three dimensions instead of just two. The functions placed these three parameters in the proper places within the transformation matrix, and then inserted the matrix into the module.

The final part was to implement the 3D viewing function, which allowed us to view our images in realistic 3D perspective. To implement 3D viewing we had to define a new structure, PerspectiveView, which held all the information necessary to implement our 3D viewing. Specifically, it included the following:

  • View Reference Point, which indicates the origin of the view reference coordinates.
  • View Plane Normal, which is a vector orthogonal to the view plane, and represents the direction the "camera" of the image is pointed.
  • View Up Vector, which indicates which direction is up from the perspective of the "camera"
  • Float d, which is the distance from the View Plane to the View Reference Point
  • Floats du and dv, which describe the extent of the View Plane in world coordinates
  • Floats F and B, which represent the distances to the front and back clip planes along the View Plane Normal
  • Floats screenX and screenY, which determine the dimensions of the output image.
    The 3D viewing function, Matrix_set3DView, takes the parameters from the PerspectiveView structure and uses them to modify the view transformation matrix.

Summary of What We Learned

We learned how to implement three dimensional matrices, as well as how to set up perspective viewing. This could be a useful template in the future for setting up other types of viewing, or even just playing around with perspective viewing to see what kind of results we get.

Additional Images

It is worth to mention, that Bogo spent over two hours creating the dodecahedron - while its twenty vertices are described as all combinations within the following four equations - (±1, ±1, ±1), (0, ±1/f, ±f), (±1/f, ±f, 0) and (±f, 0, ±1/f) - de facto order of edges is slightly different. Thus, Bogo graphed all the points in space in Grapher and found each three successive neighboring points for each of the objects, merging all of the triplets later into a complete dodecahedron.
The dodecahedron also yields an optical illusion. If we don't realize straight away, that the bigger pentagram means closer pentagram or stop paying attention to what happens on the screen, the dodecahedron will quickly appear to change shapes (although it doesn't) - a simple shading would solve this problem (as our brain doesn't know in what order to wire the lines straight away).
Nice, isn't it?

And this is a more complex one by Bogo. Dodecahedron, spinning with a cube inside, with a tetrahedron. In fact, in early eighties, it would possibly make its way into a B-rated sci-fi movie as part of Very Evil Something....

Labels
  • No labels