00001
00002
00003 #ifndef __CAMERA_H
00004 #define __CAMERA_H
00005
00006 #include <gra/GRAObject.h>
00007 #include <gra/camera/Projection.h>
00008 #include <esg/AutoPtr.h>
00009
00026 namespace gra {
00027
00028 class GRA_EXPORT Camera : public GRAObject {
00029 protected:
00030 Matrix4 * _pTrMat;
00031 AutoPtr<Projection> * _pAProjection;
00032 Projection * _pProjection;
00033
00034 public:
00035 enum PixelSample {
00036 PS_CENTROID,
00037 PS_UPPER_LEFT_CORNER,
00038 PS_UPPER_RIGHT_CORNER,
00039 PS_LOWER_RIGHT_CORNER,
00040 PS_LOWER_LEFT_CORNER,
00041 PS_RANDOM
00042 };
00043
00044 public:
00050 Camera(AutoPtr<Projection> * pAP);
00051
00055 Camera();
00056
00063 Camera(const Camera& src);
00064
00068 virtual ~Camera();
00069
00075 virtual void setTransform(const Matrix4& trMat);
00076
00080 virtual void unsetTransform();
00081
00087 virtual void rotateX(float angle);
00088
00094 virtual void rotateY(float angle);
00095
00101 virtual void rotateZ(float angle);
00102
00109 virtual void rotate (float angle, const Vector3& axis);
00110
00117 virtual void translate(float x, float y, float z);
00118
00126 virtual bool isTransformed(Matrix4* pTrMat) const;
00127
00133 virtual void setProjection(AutoPtr<Projection>* pProj);
00134
00138 const Projection& getProjection() const { return *_pProjection; }
00139
00147 Vector2 getPixelSize(unsigned resX, unsigned resY) const;
00148
00157 void getProjectionPlane(Vector3& ll, Vector3& ul,
00158 Vector3& ur, Vector3& lr) const;
00159
00160
00172 virtual Vector2 mapPixelToProjPlane(unsigned posX,
00173 unsigned posY,
00174 unsigned resX,
00175 unsigned resY,
00176 PixelSample sample) const;
00177
00186 virtual Vector3 getProjectionDirection(const Vector2& point);
00187
00191 virtual Vector3 getDirection();
00192
00196 virtual Vector3 getZenith();
00197
00206 virtual Vector2 project(const Vector3& point) const;
00207
00216 virtual bool projectAndClip(const Vector3& point, Vector2* res) const;
00217 };
00218
00219 }
00220
00221 #endif // __CAMERA_H