Computer graphics in Game development
Ivan Belyavtsev
24.01.2020
It’s possible construct any image using the next operation:
Let’s implement it together
\[y = ax+b\]
\[a = \frac{y_1 - y_2}{x_1 - x_2}\] \[b = y_1 - x_1\frac{y_1 - y_2}{x_1 - x_2}\]
\[y= y_1 + \frac{y_1 - y_2}{x_1 - x_2}(x - x_1)\]
slope = (y_begin - y_end)/(x_begin - x_end)
for x in range(x_begin, x_end):
    y = y_begin + slope*(x - x_begin)
    draw_point(x, round(y))[1]
Let’s implement it together
[1]
Let’s implement it together
[2]
[3]
[4]
[3]
# - commentv - vertexvn - normalsvt - texture coordinatesf - face (polygon) - list of vertexes, normals, and tex coordinates [5]## Object floor
v  -1.01  0.00   0.99
v   1.00  0.00   0.99
v   1.00  0.00  -1.04
v  -0.99  0.00  -1.04
g floor
usemtl floor
f -4 -3 -2 -1
## Object ceiling
v  -1.02  1.99   0.99  
v  -1.02  1.99  -1.04
v   1.00  1.99  -1.04
v   1.00  1.99   0.99
g ceiling
usemtl ceiling
f -4 -3 -2 -1Let’s implement it together
1. Marschner S., Shirley P. Fundamentals of computer graphics, fourth edition. 4th ed. Natick, MA, USA: A. K. Peters, Ltd., 2016.
2. Turk G. The stanford bunny [Electronic resource]. 2000. URL: https://www.cc.gatech.edu/~turk/bunny/bunny.html.
3. McGuire M. Computer graphics archive. 2017.
4. Computer Graphics C.U.P. of. Cornell box data [Electronic resource]. 2005. URL: http://www.graphics.cornell.edu/online/box/data.html.
5. Wavefront obj file format summary // FileFormat.Info.