There once was a girl named Irene who lived on kerosene But she started absorbin' a new hydrocarbon And since then has never Benzene Concept 2.2 : gluLookAt() vs. Modelling Transformations ======================================================= Idea: ===== In the previous concept we posed the question of replacing gluLookAt() with other transformation commands. The answer to the question is 'Yes'. We investigate how to do this in this concept. gluLookAt() the viewing transformation can be replaced by a combination of modelling transformations (i.e. translations and rotations). Experiment: =========== In the template shown above we allow you to use either the gluLookAt() utility (as in Concept 1.21) or use modelling transformations. 1) For the following gluLookAt vlaues can you specify glTranslate() and glRotate() parameters to get the same effect?1 a) gluLookAt(0.0, 3.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); b) gluLookAt(0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0); Here we are looking at the top face of the cube with the Z axis as our up-vector. c) Approximate the effect obtained by the following values gluLookAt(9.0, 0.0 , 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); Come up with your own exercises till you are convinced that gluLookAt() is essentially a combination of modelling transformations. Answers: ======== 1a) glTranslatef(0, 0, -5); glRotatef(45, 1, 0, 0); 1b) glTranslatef(0, 0, -5); glRotatef(45, 1, 0, 0); 1c) glTranslatef(-3, 0, -10); glRotatef(45, 0, -1, 0); Explanation: ============ Remember when not explicitly specified the camera is supposed to be at the origin, pointing down the -ve Z axis with (0, 1, 0) as the up-vector. In this case when using the modelling transformations, instead of moving the camera (with gluLookAt()) we moved the cube away from the camera (with a modelling transformation). This duality in the nature of viewing and modelling transformations is why you need to think about the effects of both types of transformations simultaneously. This is also why modelling and viewing trnasformations are combined into the modelview matrix before the transformations are applied.