llbbox.h

Go to the documentation of this file.
00001 
00032 #ifndef LL_BBOX_H
00033 #define LL_BBOX_H
00034 
00035 #include "v3math.h"
00036 #include "llquaternion.h"
00037 
00038 // Note: "local space" for an LLBBox is defined relative to agent space in terms of
00039 // a translation followed by a rotation.  There is no scale term since the LLBBox's min and 
00040 // max are not necessarily symetrical and define their own extents.
00041 
00042 class LLBBox
00043 {
00044 public:
00045         LLBBox() {mEmpty = TRUE;}
00046         LLBBox( const LLVector3& pos_agent,
00047                 const LLQuaternion& rot,
00048                 const LLVector3& min_local,
00049                 const LLVector3& max_local )
00050                 :
00051                 mMinLocal( min_local ), mMaxLocal( max_local ), mPosAgent(pos_agent), mRotation( rot), mEmpty( TRUE )
00052                 {}
00053 
00054         // Default copy constructor is OK.
00055 
00056         const LLVector3&        getPositionAgent() const                        { return mPosAgent; }
00057         const LLQuaternion&     getRotation() const                                     { return mRotation; }
00058 
00059         const LLVector3&        getMinLocal() const                                     { return mMinLocal; }
00060         void                            setMinLocal( const LLVector3& min )     { mMinLocal = min; }
00061 
00062         const LLVector3&        getMaxLocal() const                                     { return mMaxLocal; }
00063         void                            setMaxLocal( const LLVector3& max )     { mMaxLocal = max; }
00064 
00065         LLVector3                       getCenterLocal() const                          { return (mMaxLocal - mMinLocal) * 0.5f + mMinLocal; }
00066         LLVector3                       getCenterAgent() const                          { return localToAgent( getCenterLocal() ); }
00067 
00068         LLVector3                       getExtentLocal() const                          { return mMaxLocal - mMinLocal; }
00069 
00070         BOOL                            containsPointLocal(const LLVector3& p) const;
00071         BOOL                            containsPointAgent(const LLVector3& p) const;
00072 
00073         BOOL                            intersects(const LLBBox& b) const;
00074 
00075         void                            addPointAgent(LLVector3 p);
00076         void                            addBBoxAgent(const LLBBox& b);
00077         
00078         void                            addPointLocal(const LLVector3& p);
00079         void                            addBBoxLocal(const LLBBox& b) { addPointLocal( b.mMinLocal ); addPointLocal( b.mMaxLocal ); }
00080 
00081         void                            expand( F32 delta );
00082 
00083         LLVector3                       localToAgent( const LLVector3& v ) const;
00084         LLVector3                       agentToLocal( const LLVector3& v ) const;
00085 
00086         // Changes rotation but not position
00087         LLVector3                       localToAgentBasis(const LLVector3& v) const;
00088         LLVector3                       agentToLocalBasis(const LLVector3& v) const;
00089 
00090 
00091 //      friend LLBBox operator*(const LLBBox& a, const LLMatrix4& b);
00092 
00093 private:
00094         LLVector3                       mMinLocal;
00095         LLVector3                       mMaxLocal;
00096         LLVector3                       mPosAgent;  // Position relative to Agent's Region
00097         LLQuaternion            mRotation;
00098         BOOL                            mEmpty;         // Nothing has been added to this bbox yet
00099 };
00100 
00101 //LLBBox operator*(const LLBBox &a, const LLMatrix4 &b);
00102 
00103 
00104 #endif  // LL_BBOX_H

Generated on Fri May 16 08:33:15 2008 for SecondLife by  doxygen 1.5.5