CameraExample.cpp

00001 /*
00002  * First things first -- to apply the Propane Camera we want to call
00003  * the setPerspective method.
00004  */
00005 
00006 Propane::Camera thisCamera;
00007 thisCamera.setPosition(0, 100, 0);      // set to x=0, y=100, z=0
00008 thisCamera.setPerspective();            // tell OpenGL to use this camera
00009 
00010 /*
00011  * To use the Propane Camera, every time you update you must make
00012  * incremental updates -- not entire rotations. Quaternions are
00013  * designed to take updates OVER TIME instead of arbitrary axis-angle
00014  * combinations. Otherwise, we get gimbal lock when we try to handle
00015  * all three axis rotations at once.
00016  */
00017 thisCamera.changePitch(-10.0f);         // this will be applied next time you
00018                                         // call setPerspective or 
00019                                         // getForwardVector!
00020 
00021 /*
00022  * Wanna move forward? You have two options -- use the moveForward method
00023  * or use the getForwardVector method and do the math yourself.
00024  */
00025 thisCamera.moveForward(1.0f);           // Move along current rotation 1.0 units
00026 
00027 Propane::Math::Vector3 sourcePos(100,100,100);
00028 Propane::Math::Vector3 forVec = thisCamera.getForwardVector();
00029 sourcePos += forVec * 10000.0f;         // Move 10000.0f units along current
00030                                         // rotation from (100,100,100)
00031 thisCamera.setPosition(sourcePos);
00032 
00033 /*
00034  * If you want to take the internal quaternion and go do something else
00035  * with it, then call the getAggregate method. Check out the Quaternion
00036  * docs for more information on this neat feature of math.
00037  */
00038 Propane::Math::Quaternion myQuat = thisCamera.getAggregate();
00039 std::cout << "Hello from the quaternion: " << myQuat << std::endl;

Generated on Sun Jan 14 16:49:10 2007 for Propane Injector by  doxygen 1.4.6