22 10月 2010

Let's get the show on the road.

The course is still there...
The homework is still there... 
Some years went past, and I'm ready to try it again.


When fell over on graduate school, 
I didn't even know what "runtime", "callback function", and "instance" is..
So rookie on programming, that's my second year to the software world.


I believe I CAN.
----------------------------------------------------------------------------------------------------


The homework: You are required to do the following things in homework #1: 



  • Load a 3D model file of TRI format.
    Draw it in wireframe mode and view it in perspective view.
     
  • You should provide object rotation mode and camera rotation mode, and implement basic transformations such as rotation, translation, scaling and shear. 
  • The camera (eye) can be moved around and into the model. 
  • Clipping is required. Try to show the difference between clipping and non-clipping. 
  • ** You can not use functions gluPerspective and glFrustum !!  
And the course website is here, Interactive Computer Graphics in National Taiwan University.   


Final, I complete the homework again. This time I did that after reading some chapters of several books, instead of just copy one example code content of some Chinese book.


------------------------------------------------------------------------------------------------
Post this article after the due date of the homework this year may be more appropriate. 
Hope this helps some people that hesitate to or shy of asking questions to TAs.


1. You should read book and know what's geometric transformations.
  • OpenGL Transformation Terminology: Viewing, Modeling, Modelview, Projection, Viewport.
  • The term modelview indicates that viewing and modeling are combined in the transformation pipeline into a single matrix -- the modelview matrix.

2. For the homework requirement, 

  • Object rotation mode: it's about modeling, so function is glRotate.
  • Camera rotation mode: it's about viewing, so function is glLookAt.

3. For implementation openGL transformation function API by yourself:

  • You can find some very useful information about the "matrix" in the "Appendix C" of the book: OpenGL Programming Guide 7th., it's official reference book, and called "Red-book" of OpenGL.

4. Finally, the transform matrix of glFrustum() is usually introduced in the books. 
But,  how can we adjust the parameters in the matrix, and let the effects to be the same as using glPerspective()??

  • Assume we have a call : glPerspective( 45, ratio, near, far ) 
  • Note: near=0.1f:non-clip effect, near=3.0f:clip effect.
  • Think about the math function: tangent 
  • If we have a distance between eye and near clip plane "near", and the angle "45".
    Ymax of glFrustum should be: Ymax=near * tan(45/2.0)
  • If we have a 800*600 display window, Xmax = Ymax * (800/600) 

Long and Messy article, I hope next one will be better.
Continue to my Homework #02. :D 

沒有留言:

張貼留言