Skip to content

Day 8 (191018)

Juhwi Eden Kim edited this page Oct 19, 2019 · 1 revision
  • Tried to get "The method I adopt for my code" part
  • Rendered the model with random colored triangles

Flat Shading Render with Random Colors


1. I tried to understand "The method I adopt for my code" part

But, I was needed to know linear algebra to understand it, so I started to learn it. So let's look this part a few days later.

2. I rendered the model with random colored triangles

I used my own triangle function, and the filling code of the lecture:

for (int i=0; i<model->nfaces(); i++) { 
    std::vector<int> face = model->face(i); 
    Vec2i screen_coords[3]; 
    for (int j=0; j<3; j++) { 
        Vec3f world_coords = model->vert(face[j]); 
        screen_coords[j] = Vec2i((world_coords.x+1.)*width/2., (world_coords.y+1.)*height/2.); 
    } 
    triangle(screen_coords[0], screen_coords[1], screen_coords[2], image, TGAColor(rand()%255, rand()%255, rand()%255, 255)); 
}

MyRandomColoredFlatRender

It doesn't look good but not bad I think. I'm gonna fix this after I finish linear algebra and get the algorithm of the lecture's

3. Problems that I've met today.

To use the function code, I have to check the parameters and the arguments. And also the header files of the object that the function uses.