camera_additions

camera_additions - / = / Here are the prototypes for five...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
// ==================================================================== // Here are the prototypes for five pure virtual functions for // initializing, placing, dollying, trucking, and rotating an // OpenGL camera. These should be added to the Camera class and // each of its subclasses // ==================================================================== #include <GL/gl.h> #include <GL/glu.h> virtual void glInit(int w, int h) = 0; virtual void glPlaceCamera(void) = 0; virtual void dollyCamera(float dist) = 0; virtual void truckCamera(float dx, float dy) = 0; virtual void rotateCamera(float rx, float ry) = 0; // ==================================================================== // Below are the function bodies for // each of these routines for the OrthographicCamera // and PerspectiveCamera subclasses // ==================================================================== // ==================================================================== // Create an orthographic camera with the appropriate dimensions that // crops the screen in the narrowest dimension. // ==================================================================== void OrthographicCamera::glInit(int w, int h) { glMatrixMode(GL_PROJECTION); glLoadIdentity(); if (w > h) glOrtho(-size/2.0, size/2.0, -size*(float)h/(float)w/2.0, size*(float)h/(float)w/2.0, 0.5, 40.0); else glOrtho(-size*(float)w/(float)h/2.0, size*(float)w/(float)h/2.0, -size/2.0, size/2.0, 0.5, 40.0); } // ==================================================================== // Place an orthographic camera within an OpenGL scene // ==================================================================== void OrthographicCamera::glPlaceCamera(void) { gluLookAt(center.x(), center.y(), center.z(), center.x()+direction.x(), center.y()+direction.y(), center.z()+direction.z(), up.x(), up.y(), up.z()); } // ==================================================================== // dollyCamera, truckCamera, and RotateCamera
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/14/2011 for the course EECS 6.837 taught by Professor Durand during the Fall '03 term at MIT.

Page1 / 4

camera_additions - / = / Here are the prototypes for five...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online