Changes between Version 20 and Version 21 of tutorial


Ignore:
Timestamp:
Jun 28, 2013, 11:04:44 PM (6 years ago)
Author:
leon
Comment:

Rotate normals too.

Legend:

Unmodified
Added
Removed
Modified
  • tutorial

    v20 v21  
    480480}}}
    481481=== Exercises #3 ===
    482  1. Introduce zoom in/out functionality of the viewer by adding mouse wheel events to the end of `mouse()`
     482 1. OK, it rotates. But how come the light rotates with the teapot? I'm pretty sure that the light is not rotated while the teapot vertices are. Answer: Take a look into the `normal`. You need to rotate the vertex normal in the `vertex_shader[]` too! With a code like:
     483  {{{
     484  #!c
     485  vec4 n = RotationMatrix*vec4(gl_NormalMatrix*gl_Normal, 1);\
     486  normal=normalize(n.xyz);
     487  }}}
     488 2. Introduce zoom in/out functionality of the viewer by adding mouse wheel events to the end of `mouse()`
    483489  {{{
    484490  #!c
     
    500506   if (location >= 0)  glUniform1f(location, zoom);
    501507  }}}
     508
     509
     510
    502511 
    503 
    504 
    505