Due: Thursday 5/2 10:00am
GitHub link: https://classroom.github.com/a/fF--LPqF
No signs of intelligent life found
Add scanline conversion and z-buffering (to be explained Monday) to your graphics engine. Ignore all mentions of the z-buffer until then.
Parser Note:
- In the previous assignment, I noted that the
clear
command was no longer needed, because we immediately clear the polygon/edge matrix after a shape is drawn. In order to test Scanline conversion on multiple shapes, a different version of clear is useful. Now, clear will clear the screen and zbuffer, allowing us to reset and test multiple shapes in the same script.- I have added this command to the provided source code, but everyone should implement it.
Additions to the engine:
- Scanline conversion
- Create a function to draw a single scanline. Since scanlines are always horizontal, it should be a much simpler function than our all-purpose
draw_line
- Create a new function that handles the scanline conversion. It should use your new
draw_scanline
function. - Call
scanline_convert
in yourdraw_polygons
function. - Make sure that you change color values for each triangle.
- You can do random coloring, create a cycle of colors to go through, don’t take up too much time on this.
- Create a function to draw a single scanline. Since scanlines are always horizontal, it should be a much simpler function than our all-purpose
- Z-buffering
- Z-buffering will be explained in more detail soon…
- In the base files provided, I’ve added a z-buffer argument to the necessary functions, but have not done anything with it.
- The z-buffer should only be modified in your
plot
function, or whenclear_zbuffer
is called. - You will need to calculate z values in
scanline_convert
,draw_scanline
, anddraw_line
. - Your z values are not limited to the integers.