Songhocaopenglgltransformhtml michael tao csc418

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ode s glMatrixMode ( GL_PROJECTION ) ; glLoa dIdentit y () ; glFrustum ( left , right , bottom , top , nearVal , farVal ) ; // option 1 glOrtho ( left , right , bottom , top , nearVal , farVal ) ; // option 2 gluPe rspectiv e ( fovy , aspect , zNear , zFar ) ; // option 3 glMatrixMode ( GL_MODELVIEW ) ; glLoa dIdentit y () ; gluLookAt ( eyeX , eyeY , eyeZ , centerX , centerY , centerZ , upX , upY , upZ ) ; glRotatef ( angle ,x ,y , z ) ; glTranslate (x ,y , z ) ; glScale (x ,y , z ) ; Michael Tao CSC418: Computer Graphics Tutorial 1 September 20, 2012 27 / 31 Hierarchical Matrix Stacks Fixed Pipeline stores a stack for both matrices This allows for rendering objects in a hierarchy to keep spacial coherency glPushMatrix() glPopMatrix() glMatrixMode ( GL_MODELVIEW ) ; glLoa dIdentit y () ; glPushMatrix () ; w o r l d T oH o u s e S p a c e () ; // house space glPushMatrix () ; ho u s e T oD o o r S p a c e () ; // door space glPushMatrix () ; d o o r T o Do o r n o b S p a c e () ; // doornob space renderDoornob () ; // doornob space glPopMatrix () ; // Door space renderFrame () ; // Door space glPopMatrix () // house space ... render rest of house Michael Tao CSC418: Computer Graphics Tutorial 1 September 20, 2012 28 / 31 Hierarchical Matrix Stacks another example void renderForest () { glMatrixMode ( GL_MODELVIEW ) ; glLoa dIdentit y () ; for ( int i = 0; i <100; ++ i ) { glPushMatrix () ; glTranslatef (i ,0.0 ,0.0) ; // Push ourselves to row i for ( int j = 0; j <100; ++ j ) { glPushMatrix () ; glTranslatef (0.0 , j ,0.0) ; // Push ourselves to row j renderTree () ; // draw tree at position i , j glPopMatrix () ; } glPopMatrix () ; } } Michael Tao CSC418: Computer Graphics Tutorial 1 September 20, 2012 29 / 31 Forest Michael Tao CSC418: Computer Graphics Tutorial 1 September 20, 2012 30 / 31 Questions? Questions? Michael Tao CSC418: Computer Graphics Tutorial 1 September 20, 2012 31 / 31...
View Full Document

This document was uploaded on 02/12/2014.

Ask a homework question - tutors are online