00001
00032 #ifndef LL_LLVIEWERCAMERA_H
00033 #define LL_LLVIEWERCAMERA_H
00034
00035 #include "llcamera.h"
00036 #include "lltimer.h"
00037 #include "llstat.h"
00038 #include "m4math.h"
00039
00040 class LLCoordGL;
00041 class LLViewerObject;
00042
00043
00044
00045 const F32 OGL_TO_CFR_ROTATION[16] = { 0.f, 0.f, -1.f, 0.f,
00046 -1.f, 0.f, 0.f, 0.f,
00047 0.f, 1.f, 0.f, 0.f,
00048 0.f, 0.f, 0.f, 1.f };
00049
00050 class LLViewerCamera : public LLCamera
00051 {
00052 public:
00053 LLViewerCamera();
00054
00055
00056
00057
00058 void updateCameraLocation(const LLVector3 ¢er,
00059 const LLVector3 &up_direction,
00060 const LLVector3 &point_of_interest);
00061
00062 static void updateFrustumPlanes(LLCamera& camera, BOOL ortho = FALSE);
00063 void setPerspective(BOOL for_selection, S32 x, S32 y_from_bot, S32 width, S32 height, BOOL limit_select_distance, F32 z_near = 0, F32 z_far = 0);
00064
00065 const LLMatrix4 &getProjection() const;
00066 const LLMatrix4 &getModelview() const;
00067
00068
00069 void projectScreenToPosAgent(const S32 screen_x, const S32 screen_y, LLVector3* pos_agent ) const;
00070 BOOL projectPosAgentToScreen(const LLVector3 &pos_agent, LLCoordGL &out_point, const BOOL clamp = TRUE) const;
00071 BOOL projectPosAgentToScreenEdge(const LLVector3 &pos_agent, LLCoordGL &out_point) const;
00072
00073
00074 LLStat *getVelocityStat() { return &mVelocityStat; }
00075 LLStat *getAngularVelocityStat() { return &mAngularVelocityStat; }
00076
00077 void getPixelVectors(const LLVector3 &pos_agent, LLVector3 &up, LLVector3 &right);
00078 LLVector3 roundToPixel(const LLVector3 &pos_agent);
00079
00080 void setDefaultFOV(F32 fov) { mCameraFOVDefault = fov; }
00081 F32 getDefaultFOV() { return mCameraFOVDefault; }
00082
00083 BOOL cameraUnderWater() const;
00084
00085 const LLVector3 &getPointOfInterest() { return mLastPointOfInterest; }
00086 BOOL areVertsVisible(LLViewerObject* volumep, BOOL all_verts);
00087 F32 getPixelMeterRatio() const { return mPixelMeterRatio; }
00088 S32 getScreenPixelArea() const { return mScreenPixelArea; }
00089
00090 void setZoomParameters(F32 factor, S16 subregion) { mZoomFactor = factor; mZoomSubregion = subregion; }
00091 F32 getZoomFactor() { return mZoomFactor; }
00092 S16 getZoomSubRegion() { return mZoomSubregion; }
00093
00094
00095
00096 void updateStereoValues();
00097 void rotateToLeftEye();
00098 void rotateToRightEye();
00099
00100
00101
00102 protected:
00103 void calcProjection(const F32 far_distance) const;
00104
00105 LLStat mVelocityStat;
00106 LLStat mAngularVelocityStat;
00107 mutable LLMatrix4 mProjectionMatrix;
00108 mutable LLMatrix4 mModelviewMatrix;
00109 F32 mCameraFOVDefault;
00110 LLVector3 mLastPointOfInterest;
00111 F32 mPixelMeterRatio;
00112 S32 mScreenPixelArea;
00113 F32 mZoomFactor;
00114 S16 mZoomSubregion;
00115
00116
00117 LLVector3 mCameraTempPosition;
00118 LLVector3 mStereoLastPOI;
00119
00120
00121 public:
00122 F64 mGLProjectionMatrix[16];
00123
00124 };
00125
00126 extern LLViewerCamera *gCamera;
00127 extern F64 gGLModelView[16];
00128 extern F64 gGLProjection[16];
00129 extern S32 gGLViewport[4];
00130
00131 #endif // LL_LLVIEWERCAMERA_H