Maximum
25
Deadline
28.04.2014

Stage 3

Pracovna verzia. Konkretne zadanie stage sa este upresni. Vsetky informacie su zatial informacne

Hide invisible faces. Compute flat shading on the model.

Upload

Pracovna verzia. Konkretne zadanie stage sa este upresni. Vsetky informacie su zatial informacne

1. Implement back face culling

Hide invisible faces based on the angle between their normal vector and the vector towards camera. Remember, the camera is positioned in the axis and we use orthogonal projection. 

2. Add inputs to your application

Your application will have the following inputs:

  • Light X, Light Y, Light Z. These will allow the user to input the position of the light (e.g. x = 3, y = 3, z = 5).
  • Color R, Color G, Color B (or use a color selection dialog). This will define the object color (e.g. R = 255, G = 255, B = 0).

 

3. Render flat-shaded object

Compute diffuse light intensity in the center of every face. Use this light intensity to compute the color of the face: 
Example: 
 object color = RGB(255, 255, 0) 
 intensity = 0.6 
 resulting color = RGB(153, 153, 0)

Use the color to draw a filled polygon of the face. You can use API function to draw the filled polygon. 

Examples:

Cylinder, RGB(255,255,0), Light (0,0,10):

Cylinder, RGB(255,255,0), Light (0,0,10)

Sphere.obj , RGB(255,255,255), Light (0,10,0):

Sphere, RGB(255,255,255), Light(0,10,0)

Kocka.obj , 5x RotateX, 5x RotateY, RGB (255,255,255), Light (0,0,10)

Cube, 5x RotateX, 5x RotateY, RGB(255,255,255), Light(0,0,10)


Powered by nAIS  |  Public beta test  |  Please, report errors to: Matej Novotný  |  nAIS version 0.9.42 - 2013/01/10 17:27:58