CylindricCamera.h

Go to the documentation of this file.
00001 
00007 #ifndef CYLINDRICCAMERA_H
00008 #define CYLINDRICCAMERA_H CYLINDRICCAMERA_H
00009 
00010 #include "Camera.h"
00011 
00016 class CylindricCamera : public Camera
00017 {
00022     Vector3D pos;
00023     
00028     Vector3D up;
00029     
00034     float height;
00035     
00040     float radius;
00041 
00046     float invResX;
00047 
00052     float invResY;
00053   
00054 public:
00055 
00060     CylindricCamera(Vector3D pos,Vector3D up,
00061             float height, float radius,
00062             int resX, int resY
00063             )
00064         : Camera(resX,resY),pos(pos),up(up),height(height),radius(radius)
00065     {
00066         invResX = 1.0 / float(resX);
00067         invResY = 1.0 / float(resY); 
00068     }
00069 
00070     virtual ~CylindricCamera()
00071     {}
00072 
00078     virtual Ray InitRay(float x, float y)
00079     {
00080         Ray ray;
00081         // precompute angles
00082         float alpha = x * invResX * 2.0 * M_PI;
00083 
00084         // compute ray direction
00085         Vector3D p;
00086         p.x() = cos(alpha) * radius;
00087         p.y() = height * 0.5 - y * invResY;
00088         p.z() = sin(alpha) * radius;
00089 
00090         // set position and normalized direction
00091         ray.org = pos + p;
00092         ray.dir = -p.Normalized();
00093 
00094         return ray;
00095     }
00096 
00097 };
00098 
00099 #endif

Generated on Thu Jan 31 21:48:48 2008 for RayTracer by  doxygen 1.5.4