Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

OSGFrustumVolume.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002  *                                OpenSG                                     *
00003  *                                                                           *
00004  *                                                                           *
00005  *                 Copyright (C) 2000 by the OpenSG Forum                    *
00006  *                                                                           *
00007  *                            www.opensg.org                                 *
00008  *                                                                           *
00009  *   contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de          *
00010  *                                                                           *
00011 \*---------------------------------------------------------------------------*/
00012 /*---------------------------------------------------------------------------*\
00013  *                                License                                    *
00014  *                                                                           *
00015  * This library is free software; you can redistribute it and/or modify it   *
00016  * under the terms of the GNU Library General Public License as published    *
00017  * by the Free Software Foundation, version 2.                               *
00018  *                                                                           *
00019  * This library is distributed in the hope that it will be useful, but       *
00020  * WITHOUT ANY WARRANTY; without even the implied warranty of                *
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         *
00022  * Library General Public License for more details.                          *
00023  *                                                                           *
00024  * You should have received a copy of the GNU Library General Public         *
00025  * License along with this library; if not, write to the Free Software       *
00026  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                 *
00027  *                                                                           *
00028  *                                                                           *
00029 \*---------------------------------------------------------------------------*/
00030 /*---------------------------------------------------------------------------*\
00031  *                                Changes                                    *
00032  *                                                                           *
00033  *                                                                           *
00034  *                                                                           *
00035  *                                                                           *
00036  *                                                                           *
00037  *                                                                           *
00038 \*---------------------------------------------------------------------------*/
00039 
00040 #ifndef _OSG_FRUSTUMVOLUME_H_
00041 #define _OSG_FRUSTUMVOLUME_H_
00042 
00043 #include "OSGConfig.h"
00044 #include "OSGBase.h"
00045 #include "OSGVolume.h"
00046 #include "OSGPlane.h"
00047 #include "OSGMatrix.h"
00048 
00049 OSG_BEGIN_NAMESPACE
00050 
00054 class OSG_BASE_DLLMAPPING FrustumVolume : public Volume
00055 {
00056     /*==========================  PUBLIC  =================================*/
00057 
00058   public:
00059     
00060     /*---------------------------------------------------------------------*/
00064     enum { P_NONE   = 0,
00065            P_NEAR   = 1, 
00066            P_FAR    = 2,
00067            P_LEFT   = 4,
00068            P_RIGHT  = 8,
00069            P_TOP    = 16,
00070            P_BOTTOM = 32,
00071            P_ALL    = P_NEAR | P_FAR | P_LEFT | P_RIGHT | P_TOP | P_BOTTOM
00072          };
00073          
00074     typedef UInt8 PlaneSet;
00075          
00077     /*---------------------------------------------------------------------*/
00081     FrustumVolume(      void                                     ); 
00082     FrustumVolume(const Plane         &pnear, const Plane &pfar,
00083                   const Plane         &left,  const Plane &right,
00084                   const Plane         &top,   const Plane &bottom);
00085     FrustumVolume(const FrustumVolume &obj                       );
00086 
00088     /*---------------------------------------------------------------------*/
00092     ~FrustumVolume(void); 
00093     
00095     /*---------------------------------------------------------------------*/
00099             const Plane  &getNear        (void         ) const;
00100             const Plane  &getFar         (void         ) const;
00101             const Plane  &getLeft        (void         ) const;
00102             const Plane  &getRight       (void         ) const;
00103             const Plane  &getTop         (void         ) const;
00104             const Plane  &getBottom      (void         ) const;
00105             const Plane  *getPlanes      (void         ) const; 
00106 
00107     virtual       void    getCenter      (Pnt3f &center) const;
00108     virtual       Real32  getScalarVolume(void         ) const;
00109     virtual       void    getBounds      (Pnt3f &minPnt,
00110                                           Pnt3f &maxPnt) const;
00111     
00113     /*---------------------------------------------------------------------*/
00117     void setPlanes(const Plane  &pnear, const Plane &pfar,
00118                    const Plane  &left,  const Plane &right,
00119                    const Plane  &top,   const Plane &bottom);
00120     void setPlanes(const Pnt3f  &nlt,   const Pnt3f &nlb,
00121                    const Pnt3f  &nrt,   const Pnt3f &nrb,
00122                    const Pnt3f  &flt,   const Pnt3f &flb,
00123                    const Pnt3f  &frt,   const Pnt3f &frb   );
00124     void setPlanes(const Matrix &matrix                    );
00125                                     
00127     /*---------------------------------------------------------------------*/
00131     virtual void extendBy(const Pnt3f         &pt    );
00132     virtual void extendBy(const Volume        &volume);   
00133     inline  void extendBy(const FrustumVolume &bb    );
00134 
00136     /*---------------------------------------------------------------------*/
00140     virtual bool intersect  (const Pnt3f         &point  ) const;
00141     virtual bool intersect  (const Line          &line   ) const;
00142     virtual bool intersect  (const Line          &line,
00143                                    Real32        &minDist,
00144                                    Real32        &maxDist) const;
00145     virtual bool intersect  (const Volume        &volume ) const;
00146             bool intersect  (const FrustumVolume &bb     ) const;
00147     virtual bool isOnSurface(const Pnt3f         &point  ) const;
00148 
00150     /*---------------------------------------------------------------------*/
00154     virtual void transform(const Matrix &m);
00155 
00157     /*---------------------------------------------------------------------*/
00161     const FrustumVolume &operator =(const FrustumVolume &b1);
00162 
00164     /*---------------------------------------------------------------------*/
00168     virtual void dump(      UInt32    uiIndent = 0, 
00169                       const BitVector bvFlags  = 0) const;
00170     
00172     /*=========================  PROTECTED  ===============================*/
00173 
00174   protected:
00175 
00176     /*==========================  PRIVATE  ================================*/
00177 
00178   private:
00179 
00180     Plane _planeVec[6];
00181 
00182 };
00183 
00184 OSG_BASE_DLLMAPPING
00185 bool operator ==(const FrustumVolume &b1, const FrustumVolume &b2);
00186 
00187 inline
00188 bool operator !=(const FrustumVolume &b1, const FrustumVolume &b2);
00189 
00190 OSG_BASE_DLLMAPPING 
00191 bool intersect(const FrustumVolume &frustum, const Volume &vol, 
00192                FrustumVolume::PlaneSet &inplanes);
00193 
00194 OSG_END_NAMESPACE
00195 
00196 #include <OSGFrustumVolume.inl>
00197 
00198 #endif /* _OSG_FRUSTUMVOLUME_H_ */
00199 

Generated on Thu Aug 25 04:05:17 2005 for OpenSG by  doxygen 1.4.3