00001 00002 00003 00004 00005 // ChangeLog is at the implementation file 00006 00007 #ifndef __VPCAMERA_H 00008 #define __VPCAMERA_H 00009 00010 //~ #include "vppoint2d.h" 00011 //~ #include "vppoint3d.h" 00012 //~ #include "vpvector3d.h" 00013 #include "vppoint4d.h" 00014 #include <string> //STL include 00015 00020 class VPCamera { 00021 friend std::ostream& operator<<(std::ostream& output, const VPCamera& cam); 00022 public: 00023 enum ProjectionType { ORTHOGRAPHIC, PERSPECTIVE }; 00024 VPCamera(); 00029 VPCamera(const VPPoint4D& position, const VPPoint4D& focus, const VPPoint4D& upVec); 00030 VPCamera(const VPCamera& cam); 00031 VPCamera& operator=(const VPCamera& cam); 00033 const std::string& GetDescription() const { return description; } 00035 void SetDescription(const std::string& descriptionValue); 00037 ProjectionType GetProjectionType() const { return projectionType; } 00039 void SetProjectionType(ProjectionType newValue) { projectionType = newValue; } 00041 float GetAspectRatio() const { return aspectRatio; } 00043 void SetAspectRatio(float newAR) { aspectRatio = newAR; } 00045 float GetNearPlaneDistance() const { return nearPlaneDistance; } 00047 void SetNearPlaneDistance(float newValue) { nearPlaneDistance = newValue; } 00049 float GetFarPlaneDistance() const { return farPlaneDistance; } 00051 void SetFarPlaneDistance(float newValue) { farPlaneDistance = newValue; } 00053 float GetFovY() const; 00055 void SetFovY(float f); 00057 VPPoint4D GetLocation() const; 00059 void SetLocation(const VPPoint4D& locationValue); 00061 VPPoint4D GetTarget() const; 00063 void SetTarget(const VPPoint4D& targetValue); 00065 VPPoint4D GetUp() const; 00067 void SetUp(const VPPoint4D& upValue); 00069 void SetVisibleVolumeHLimits(double left, double right) 00070 { vvLeft = left; vvRight = right; } 00072 void SetVisibleVolumeVLimits(double top, double bottom) 00073 { vvTop = top; vvBottom = bottom; } 00074 00076 00078 void SetVisibleVolumeHeight(double newValue); 00079 00081 void YawAroundTarget(double radians); 00083 void Yaw(double radians); 00085 void PitchAroundTarget(double radians); 00087 void MoveForward(double distance); 00089 void MoveSideways(double distance); 00091 void MoveUp(double distance); 00092 00095 bool DrawOGL() const; 00096 00097 //~ VPPoint2D GetWinBottomLeft() const; 00098 //~ void SetWinBottomLeft(VPPoint2D winBottomLeftValue); 00099 //~ void GetWinTopRight(float &x, float &y); 00100 //~ void SetWinTopRight(float x, float y); 00101 //~ VPPoint2D GetWinTopRight() const; 00102 //~ void SetWinTopRight(VPPoint2D winTopRightValue); 00103 //~ VPPoint2D GetWinLeftRight(); 00104 //~ void SetWinLeftRight(VPPoint2D winLeftRightValue); 00105 //~ VPPoint2D GetWinBottomTop(); 00106 //~ void SetWinBottomTop(VPPoint2D winBottomTopValue); 00107 //~ void SetViewDimension(int h, int w); 00108 //~ void GetViewDimension(int &h, int &w) const; 00109 //~ int GetViewWidth() const; 00110 //~ int GetViewHeight() const; 00111 private: 00112 std::string description; 00113 // Indicates whether a perspective ou orthographic projection should be used 00114 ProjectionType projectionType; 00115 00116 float nearPlaneDistance; 00117 float farPlaneDistance; 00118 //Vertical angle of frustum. Used if projectionType == PERSPECTIVE. 00119 float fovY; 00120 // Viewing aspect ratio (width/height). 00121 float aspectRatio; 00122 00123 // Coordinates of the visible volume. Values are in world coordinates. 00124 // Used if projectionType is ORTHOGRAPHIC. 00125 double vvLeft; // visible volume left coordinate 00126 double vvRight; 00127 double vvTop; 00128 double vvBottom; 00129 00130 VPPoint4D location; 00131 VPPoint4D target; 00132 //FixMe: Should be kept orthogonal to (target-location). 00133 VPPoint4D up; 00134 00135 // FixMe: It seems that viewHeight, viewWidth, winBottomLeft and winTopRight 00136 // used to hold values that now come from aspectRatio and height; 00137 //~ int viewHeight; 00138 //~ int viewWidth; 00139 //~ VPPoint2D winBottomLeft; 00140 //~ VPPoint2D winTopRight; 00141 }; 00142 00143 #endif // __VPCAMERA_H