Changes between Version 30 and Version 31 of tutorial


Ignore:
Timestamp:
Jun 29, 2013, 10:47:38 PM (11 years ago)
Author:
leon
Comment:

Point cloud vertex shader

Legend:

Unmodified
Added
Removed
Modified
  • tutorial

    v30 v31  
    591591[[Image(point-cloud.png,right)]]
    592592=== Exercises #3 ===
    593  1.Insert {{{teapot.c}}} interactivity example into {{{wavefront.c}}} above and save it as {{{motorbike.c}}}.
    594    Verify that there is no compile problems ant that the {{{main()}}} contains {{{read_wavefront("motorBike.obj");}}}.
    595    Disable lengthy saving in {{{main()}}}.
     593 1. Insert {{{teapot.c}}} interactivity example into {{{wavefront.c}}} above and save it as {{{motorbike.c}}}.
     594   Verify that there are no compile problems and that the {{{main()}}} contains {{{read_wavefront("motorBike.obj");}}}.
     595   Disable lengthy wavefront saving in {{{main()}}}.
    596596 2. Instead of drawing of the teapot in {{{display()}}} we will draw single vertex array object as a point cloud with
    597597  {{{
    598598  #!c
     599   //glutSolidTeapot(0.6);
    599600   glDrawArrays(GL_POINTS, 0, vertices);
    600601  }}}
    601   To be able to draw this, we need to prepare Vertex Array Object and buffer with {{{init();}}} that is called from {{{main()}} just before {{{glutMainLoop();}}}
     602  To be able to draw this, we need to prepare Vertex Array Object and buffer with {{{init();}}} that is called from {{{main()}}} just before {{{glutMainLoop();}}}
    602603  {{{
    603604  #!c
     
    616617}
    617618}}}
     619 3. We see that rotation of the motorbike around front wheel is not really nice.
     620   To compensate we translate all points in {{{vertex_shader[]}}} by adding {{{vec3(-0.75, 0, -0.7);}}}
     621   to every vertex in world coordinates and thus moving motor bike to origin.
     622   Last part of the {{{vertex_shader[]}}}now reads:
     623   {{{
     624  #!c
     625  vec3 position = gl_Vertex.xyz + vec3(-0.75, 0, -0.7); \
     626  gl_Position = gl_ProjectionMatrix * RotationMatrix \
     627   * gl_ModelViewMatrix*vec4(Zoom*position, 1.0); \
     628  }}}
    618629