llmanipscale.h

Go to the documentation of this file.
00001 
00032 #ifndef LL_MANIPSCALE_H
00033 #define LL_MANIPSCALE_H
00034 
00035 // llmanipscale.h
00036 //
00037 // copyright 2001-2002, linden research inc
00038 
00039 
00040 #include "lltool.h"
00041 #include "v3math.h"
00042 #include "v4math.h"
00043 #include "llmanip.h"
00044 #include "llviewerobject.h"
00045 #include "llbbox.h"
00046 
00047 class LLToolComposite;
00048 class LLColor4;
00049 
00050 typedef enum e_scale_manipulator_type
00051 {
00052         SCALE_MANIP_CORNER,
00053         SCALE_MANIP_FACE
00054 } EScaleManipulatorType;
00055 
00056 
00057 class LLManipScale : public LLManip
00058 {
00059 public:
00060         class ManipulatorHandle
00061         {
00062         public:
00063                 LLVector3       mPosition;
00064                 EManipPart      mManipID;
00065                 EScaleManipulatorType                   mType;
00066 
00067                 ManipulatorHandle(LLVector3 pos, EManipPart id, EScaleManipulatorType type):mPosition(pos), mManipID(id), mType(type){}
00068         };
00069 
00070 
00071         LLManipScale( LLToolComposite* composite );
00072         ~LLManipScale();
00073 
00074         virtual BOOL    handleMouseDown( S32 x, S32 y, MASK mask );
00075         virtual BOOL    handleMouseUp( S32 x, S32 y, MASK mask );
00076         virtual BOOL    handleHover( S32 x, S32 y, MASK mask );
00077         virtual void    render();
00078         virtual void    handleSelect();
00079         virtual void    handleDeselect();
00080 
00081         virtual BOOL    handleMouseDownOnPart(S32 x, S32 y, MASK mask);
00082         virtual void    highlightManipulators(S32 x, S32 y);    // decided which manipulator, if any, should be highlighted by mouse hover
00083         virtual BOOL    canAffectSelection();
00084 
00085         static void             setUniform( BOOL b );
00086         static BOOL             getUniform();
00087         static void             setStretchTextures( BOOL b );
00088         static BOOL             getStretchTextures();
00089         static void             setShowAxes( BOOL b );
00090         static BOOL             getShowAxes();
00091 
00092 private:
00093         void                    renderCorners( const LLBBox& local_bbox );
00094         void                    renderFaces( const LLBBox& local_bbox );
00095         void                    renderEdges( const LLBBox& local_bbox );
00096         void                    renderBoxHandle( F32 x, F32 y, F32 z );
00097         void                    renderAxisHandle( const LLVector3& start, const LLVector3& end );
00098         void                    renderGuidelinesPart( const LLBBox& local_bbox );
00099         void                    renderSnapGuides( const LLBBox& local_bbox );
00100 
00101         void                    revert();
00102         
00103         inline void             conditionalHighlight( U32 part, const LLColor4* highlight = NULL, const LLColor4* normal = NULL );
00104 
00105         void                    drag( S32 x, S32 y );
00106         void                    dragFace( S32 x, S32 y );
00107         void                    dragCorner( S32 x, S32 y );
00108 
00109         void                    sendUpdates( BOOL send_position_update, BOOL send_scale_update, BOOL corner = FALSE);
00110 
00111         LLVector3               faceToUnitVector( S32 part ) const;
00112         LLVector3               cornerToUnitVector( S32 part ) const;
00113         LLVector3               edgeToUnitVector( S32 part ) const;
00114         LLVector3               partToUnitVector( S32 part ) const;
00115         LLVector3               unitVectorToLocalBBoxExtent( const LLVector3& v, const LLBBox& bbox ) const;
00116         F32                             partToMaxScale( S32 part, const LLBBox& bbox ) const;
00117         F32                             partToMinScale( S32 part, const LLBBox& bbox ) const;
00118         LLVector3               nearestAxis( const LLVector3& v ) const;
00119 
00120         void                    stretchFace( const LLVector3& drag_start_agent, const LLVector3& drag_delta_agent);
00121 
00122         void                    adjustTextureRepeats();         // Adjusts texture coords based on mSavedScale and current scale, only works for boxes
00123 
00124         void                    updateSnapGuides(const LLBBox& bbox);
00125 private:
00126 
00127         F32                             mBoxHandleSize;         // The size of the handles at the corners of the bounding box
00128         F32                             mScaledBoxHandleSize; // handle size after scaling for selection feedback
00129         EManipPart              mManipPart;
00130         LLVector3d              mDragStartPointGlobal;
00131         LLVector3d              mDragStartCenterGlobal; // The center of the bounding box of all selected objects at time of drag start
00132         LLVector3d              mDragPointGlobal;
00133         LLVector3d              mDragFarHitGlobal;
00134         S32                             mLastMouseX;
00135         S32                             mLastMouseY;
00136         BOOL                    mSendUpdateOnMouseUp;
00137         U32                     mLastUpdateFlags;
00138         LLLinkedList<ManipulatorHandle>         mProjectedManipulators;
00139         LLVector4               mManipulatorVertices[14];
00140         F32                             mScaleSnapUnit1;  // size of snap multiples for axis 1
00141         F32                             mScaleSnapUnit2;  // size of snap multiples for axis 2
00142         LLVector3               mScalePlaneNormal1; // normal of plane in which scale occurs that most faces camera
00143         LLVector3               mScalePlaneNormal2; // normal of plane in which scale occurs that most faces camera
00144         LLVector3               mSnapGuideDir1;
00145         LLVector3               mSnapGuideDir2;
00146         LLVector3               mSnapDir1;
00147         LLVector3               mSnapDir2;
00148         F32                             mSnapRegimeOffset;
00149         F32                             mSnapGuideLength;
00150         LLVector3               mScaleCenter;
00151         LLVector3               mScaleDir;
00152         F32                             mScaleSnapValue;
00153         BOOL                    mInSnapRegime;
00154         F32*                    mManipulatorScales;
00155 };
00156 
00157 #endif  // LL_MANIPSCALE_H

Generated on Thu Jul 1 06:08:50 2010 for Second Life Viewer by  doxygen 1.4.7