辅导COMP3811程序、辅导Python,Java编程

- 首页 >> Python编程
COMP3811: Computer Graphics
Coursework 1
Rasterization
Due Date: 5 November 2021, 5 pm
Marc de Kamps, Markus Billeter
October 22, 2021
Marking
This coursework is summative and counts towards your final mark for 30 % (total coursework counts
for 100 %).
Submission Instruction and Note on Plagiarism
Submission should be done through the VLE by the due date. Submissions through the SSO will be
ignored and result in 0 marks. Your submission should be in a single tar (not rar!) file that contains
a report and source code. Source code must be provided with a Makefile and must compile and run
on the School’s machines (e.g., feng-linux, Bragg building machines).
Source code that does not compile and run will not be looked at and no marks will be awarded
to any programming exercise that it relates to. The report is basis for assessment, with the source
code as supporting evidence for assertions made in the report. Answer all the questions and provide
the explanations that are asked for. Refer to your code in explanations, but do not provide answers
like: ’see source code’.
You are allowed to discuss ideas with colleagues. You must program independently and not base
your submission on any other code than is provided with this coursework assignment, which is in
a tar file called cw1.tar.gz, which is located in the coursework 1 folder on the VLE, the same
folder which contains this specification. Changing variable names in someone else’s code is not a
good idea.
Drawing lines
Unpack the tar file. Run qmake and make as you have been taught in the tutorial. Run the resulting
pixelate application. The application window shows a rasterized screen with a single red pixel.
The PixelWidget.cpp contains a method DefinePixelValues
v oi d Pi x elWi d g et : : D e f i n e P i x e l V a l u e s ( ) {
S e t P i x e l ( 1 9 , 9 , RGBVal ( 2 5 5 , 0 , 0 ) ) ;
}
It is clear that by adding SetPixel calls it is possible to construct larger primitives, made up from
pixels. We use this widget to make the effects of rasterization more visible.
1
Assigment 1: First make sure that you are able to set arbitrary pixels (within the widget) to arbitrary
RGB values. Adopt the following convention: a pair of floats define a pixel on the screen. The first
gives the horizontal distance in number of pixels from the top left corner, the second the vertical
distance. Add a method call DrawLine to the PixelWidget class that is able to take four floating
point values, the first two defining the starting point, and the second two the end point, and that
draws a line of white pixels between them. Use the parameterised version of a line to calculate the
pixels that will be hit between the two points. You must ensure that every pixel that contains the
mathematical ideal of the line lights up. This entails choosing steps that are small enough to ensure
you hit every pixels, but large enough to be not overly wasteful. Motivate your choice for a step
size. Make sure that this method is called in paintEvent, so that a line is drawn. Add a screenshot
to the report and explain whether the result is as expected.
[3 marks]
Assignment 2: Adapt the method you have just created so that it is able to accept an RGB value (use
struct RGBVal) for starting point, another one for end point and interpolate the colour along the line.
Again, add a screenshot to your report explaining the results.
[4 marks]
Assignment 3: Create a method that accepts three points and associated RGB values. Use barycentric
coordinates to interpolate pixels that are part of the triangle.
[4 marks]
Assignment 4: Implement the half plane test for determining whether a point is inside or outside
the triangle. Create a function called IsInside that takes as arguments the three vertices (each one
specified by two floats), defining the triangle and a point in pixel coordinates. Apply this function
to all pixels in your image. Produce a file which lists the barycentric coordinates of each pixel and
the result of your function. Perform a comparison between the results of your function and the
barycentric coordinates (you can do this in a separate script if you like). In your report describe the
method, and comment on whether the results are as expected.
[3 marks]
Assignment 5: Create a ppm image from an interpolated triangle. The format for such images are
defined here: http://paulbourke.net/dataformats/ppm/.
[1 marks]
[15 marks total]
2

站长地图