Changes between Version 30 and Version 31 of tutorial
- Timestamp:
- Jun 29, 2013, 10:47:38 PM (11 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
tutorial
v30 v31 591 591 [[Image(point-cloud.png,right)]] 592 592 === 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 antthat 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()}}}. 596 596 2. Instead of drawing of the teapot in {{{display()}}} we will draw single vertex array object as a point cloud with 597 597 {{{ 598 598 #!c 599 //glutSolidTeapot(0.6); 599 600 glDrawArrays(GL_POINTS, 0, vertices); 600 601 }}} 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();}}} 602 603 {{{ 603 604 #!c … … 616 617 } 617 618 }}} 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 }}} 618 629