glc_frustum.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 
00003  This file is part of the GLC-lib library.
00004  Copyright (C) 2005-2008 Laurent Ribon (laumaya@users.sourceforge.net)
00005  http://glc-lib.sourceforge.net
00006 
00007  GLC-lib is free software; you can redistribute it and/or modify
00008  it under the terms of the GNU Lesser General Public License as published by
00009  the Free Software Foundation; either version 3 of the License, or
00010  (at your option) any later version.
00011 
00012  GLC-lib is distributed in the hope that it will be useful,
00013  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  GNU Lesser General Public License for more details.
00016 
00017  You should have received a copy of the GNU Lesser General Public License
00018  along with GLC-lib; if not, write to the Free Software
00019  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00020 
00021  *****************************************************************************/
00023 
00024 #ifndef GLC_FRUSTUM_H_
00025 #define GLC_FRUSTUM_H_
00026 
00027 #include "../maths/glc_plane.h"
00028 #include "../glc_boundingbox.h"
00029 #include "../glc_config.h"
00030 
00031 class GLC_LIB_EXPORT GLC_Viewport;
00032 
00035 
00038 
00039 class GLC_LIB_EXPORT GLC_Frustum
00040 {
00041 private:
00042         enum planeId
00043         {
00044                 LeftPlane= 0,
00045                 RightPlane= 1,
00046                 TopPlane= 2,
00047                 BottomPlane= 3,
00048                 NearPlane= 4,
00049                 FarPlane= 5
00050         };
00051 public:
00052         enum Localisation
00053         {
00054                 InFrustum = 0,
00055                 IntersectFrustum = 1,
00056                 OutFrustum= 3
00057         };
00059 
00061 
00062 public:
00064         GLC_Frustum();
00065 
00067         GLC_Frustum(const GLC_Frustum&);
00068 
00070         ~GLC_Frustum();
00072 
00074 
00076 
00077 public:
00078 
00080         inline GLC_Plane leftClippingPlane() const
00081         {return m_PlaneList.at(LeftPlane);}
00082 
00084         inline GLC_Plane rightClippingPlane() const
00085         {return m_PlaneList.at(RightPlane);}
00086 
00088         inline GLC_Plane topClippingPlane() const
00089         {return m_PlaneList.at(TopPlane);}
00090 
00092         inline GLC_Plane bottomClippingPlane() const
00093         {return m_PlaneList.at(BottomPlane);}
00094 
00096         inline GLC_Plane nearClippingPlane() const
00097         {return m_PlaneList.at(NearPlane);}
00098 
00100         inline GLC_Plane farClippingPlane() const
00101         {return m_PlaneList.at(FarPlane);}
00102 
00104         Localisation localizeBoundingBox(const GLC_BoundingBox&) const;
00105 
00107         Localisation localizeSphere(const GLC_Point3d&, double) const;
00108 
00110 
00112 
00114 
00115 public:
00116 
00118         inline void setLeftClippingPlane(const GLC_Plane& plane)
00119         {m_PlaneList[LeftPlane]= plane;}
00120 
00122         inline void setRightClippingPlane(const GLC_Plane& plane)
00123         {m_PlaneList[RightPlane]= plane;}
00124 
00126         inline void setTopClippingPlane(const GLC_Plane& plane)
00127         {m_PlaneList[TopPlane]= plane;}
00128 
00130         inline void setBottomClippingPlane(const GLC_Plane& plane)
00131         {m_PlaneList[BottomPlane]= plane;}
00132 
00134         inline void setNearClippingPlane(const GLC_Plane& plane)
00135         {m_PlaneList[NearPlane]= plane;}
00136 
00138         inline void setFarClippingPlane(const GLC_Plane& plane)
00139         {m_PlaneList[FarPlane]= plane;}
00140 
00142 
00143         bool update(const GLC_Matrix4x4&);
00144 
00146 
00147 // Private services function
00149 private:
00151         Localisation localizeSphereToPlane(const GLC_Point3d&, double, const GLC_Plane&) const;
00152 
00154 // Private Member
00156 private:
00157 
00159         QList<GLC_Plane> m_PlaneList;
00160 
00162         GLC_Matrix4x4 m_PreviousMatrix;
00163 };
00164 
00165 #endif /* GLC_FRUSTUM_H_ */

SourceForge.net Logo

©2005-2011 Laurent Ribon