llviewercamera.h

Go to the documentation of this file.
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 // This rotation matrix moves the default OpenGL reference frame 
00044 // (-Z at, Y up) to Cory's favorite reference frame (X at, Z up)
00045 const F32 OGL_TO_CFR_ROTATION[16] = {  0.f,  0.f, -1.f,  0.f,   // -Z becomes X
00046                                                                           -1.f,  0.f,  0.f,  0.f,       // -X becomes Y
00047                                                                            0.f,  1.f,  0.f,  0.f,       //  Y becomes Z
00048                                                                            0.f,  0.f,  0.f,  1.f };
00049 
00050 const BOOL FOR_SELECTION = TRUE;
00051 const BOOL NOT_FOR_SELECTION = FALSE;
00052 
00053 class LLViewerCamera : public LLCamera, public LLSingleton<LLViewerCamera>
00054 {
00055 public:
00056         LLViewerCamera();
00057 
00058 //      const LLVector3 &getPositionAgent() const;
00059 //      const LLVector3d &getPositionGlobal() const;
00060 
00061         void updateCameraLocation(const LLVector3 &center,
00062                                                                 const LLVector3 &up_direction,
00063                                                                 const LLVector3 &point_of_interest);
00064 
00065         static void updateFrustumPlanes(LLCamera& camera, BOOL ortho = FALSE, BOOL zflip = FALSE);
00066         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);
00067 
00068         const LLMatrix4 &getProjection() const;
00069         const LLMatrix4 &getModelview() const;
00070 
00071         // Warning!  These assume the current global matrices are correct
00072         void projectScreenToPosAgent(const S32 screen_x, const S32 screen_y, LLVector3* pos_agent ) const;
00073         BOOL projectPosAgentToScreen(const LLVector3 &pos_agent, LLCoordGL &out_point, const BOOL clamp = TRUE) const;
00074         BOOL projectPosAgentToScreenEdge(const LLVector3 &pos_agent, LLCoordGL &out_point) const;
00075 
00076 
00077         LLStat *getVelocityStat() { return &mVelocityStat; }
00078         LLStat *getAngularVelocityStat() { return &mAngularVelocityStat; }
00079 
00080         void getPixelVectors(const LLVector3 &pos_agent, LLVector3 &up, LLVector3 &right);
00081         LLVector3 roundToPixel(const LLVector3 &pos_agent);
00082 
00083         void setDefaultFOV(F32 fov) { mCameraFOVDefault = fov; }
00084         F32 getDefaultFOV() { return mCameraFOVDefault; }
00085 
00086         BOOL cameraUnderWater() const;
00087 
00088         const LLVector3 &getPointOfInterest() { return mLastPointOfInterest; }
00089         BOOL areVertsVisible(LLViewerObject* volumep, BOOL all_verts);
00090         F32 getPixelMeterRatio() const                          { return mPixelMeterRatio; }
00091         S32 getScreenPixelArea() const                          { return mScreenPixelArea; }
00092 
00093         void setZoomParameters(F32 factor, S16 subregion) { mZoomFactor = factor; mZoomSubregion = subregion; }
00094         F32 getZoomFactor() { return mZoomFactor; }                             
00095         S16 getZoomSubRegion() { return mZoomSubregion; } 
00096 
00097 protected:
00098         void calcProjection(const F32 far_distance) const;
00099 
00100         LLStat mVelocityStat;
00101         LLStat mAngularVelocityStat;
00102         mutable LLMatrix4       mProjectionMatrix;      // Cache of perspective matrix
00103         mutable LLMatrix4       mModelviewMatrix;
00104         F32                                     mCameraFOVDefault;
00105         LLVector3                       mLastPointOfInterest;
00106         F32                                     mPixelMeterRatio; // Divide by distance from camera to get pixels per meter at that distance.
00107         S32                                     mScreenPixelArea; // Pixel area of entire window
00108         F32                                     mZoomFactor;
00109         S16                                     mZoomSubregion;
00110 
00111 public:
00112 };
00113 
00114 extern F64 gGLModelView[16];
00115 extern F64 gGLLastModelView[16];
00116 extern F64 gGLProjection[16];
00117 extern S32 gGLViewport[4];
00118 extern F32 gGLZNear;
00119 extern F32 gGLZFar;
00120 
00121 #endif // LL_LLVIEWERCAMERA_H

Generated on Fri May 16 08:34:09 2008 for SecondLife by  doxygen 1.5.5