Matt Fowles's Graphics Lab 7


This lab was centered around creating a z-buffer system. We decided to integrate it with our heirachical modelling system from the start, since it could be implemented fairly easily, by taking advantage of a few virtual function. We also chose to use linked lists for each position so that we could include alpha calculations.


How can you/did you connect your z-buffer algorithm with the rest of your 3D modelings system?

We created a class responsible for doing the z-buffer calculation, that had a virtual drawPoint3D function. Thus it could intercept any calls to drawPoint3D and place the point into the array of linked lists that is our z-buffer. We had to change the perspective transform function to cache the z value from the CVV and place that in the points after the perspective transform, but that was a minor change. The larger change was to force all of our line drawing algorithms (and scan fill ones) to interpolate z-values between endpoints. Once that was done we had our new class only draw to the image when it was told to write to file. Otherwise, it would just add (or not, as appropriate) the point to the z-buffer. Debugging was the longest part, it took us a few hours of debugging to realize that we were interpolating in the wrong direction (-= instead of +=), but after that it change it worked well.


We know that z varies inversely with x and y for perspective projection. How does z vary relative to x and y for parallel project?

Depth varies linearly with respect to x and y for parallen projection; however, this is not horribly useful to us, since our system only does perspective projection.


What extensions did you do for this assignment, how did you do them, and how well did they work?

We implemented everything within our heirachical modelling system, including support for alpha blending and polyline as well as polygon z-buffering.
We implemented alpha blending by having each element in our z-buffer be a linked list. Each item in the list has a color and alpha value associated with it. When a new item is added to a particular list, its position in the list is determined using it z-value. If the item is not-transparent, then anything below its insertion point is deleted, otherwise it is just inserted normally. If it finds a non-transparent element before it finds its location, then the point is not visible. This approach works quite well, although it does require a bit of pointer games to find the appropriate spot.

Inclusion in the heirachical system came along for free thanks to inheritance and virtual functions. It really was not all that bad at all.

This is a 1x1 green semi-transparent square is oriented parallel to the view plane, and it is intersected by a .4x1x1 opaque blue prism that is rotated about its vertical axis to point partially away from the viewer. A 1x1 semi-transparent, tilted red plane rotates about the vertical axis through the other two objects. req1.gif

Last modified 2003-10-07 22:15 EST