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  Version 2.0.0 Beta 1, packaged on April 2010.
00006 
00007  http://glc-lib.sourceforge.net
00008 
00009  GLC-lib is free software; you can redistribute it and/or modify
00010  it under the terms of the GNU General Public License as published by
00011  the Free Software Foundation; either version 2 of the License, or
00012  (at your option) any later version.
00013 
00014  GLC-lib is distributed in the hope that it will be useful,
00015  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  GNU General Public License for more details.
00018 
00019  You should have received a copy of the GNU General Public License
00020  along with GLC-lib; if not, write to the Free Software
00021  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00022 
00023  *****************************************************************************/
00025 
00026 #ifndef GLC_FRUSTUM_H_
00027 #define GLC_FRUSTUM_H_
00028 
00029 #include "../maths/glc_plane.h"
00030 #include "../glc_boundingbox.h"
00031 #include "../glc_config.h"
00032 
00033 class GLC_LIB_EXPORT GLC_Viewport;
00034 
00037 
00040 
00041 class GLC_LIB_EXPORT GLC_Frustum
00042 {
00043 private:
00044         enum planeId
00045         {
00046                 LeftPlane= 0,
00047                 RightPlane= 1,
00048                 TopPlane= 2,
00049                 BottomPlane= 3,
00050                 NearPlane= 4,
00051                 FarPlane= 5
00052         };
00053 public:
00054         enum Localisation
00055         {
00056                 InFrustum = 0,
00057                 IntersectFrustum = 1,
00058                 OutFrustum= 3
00059         };
00061 
00063 
00064 public:
00066         GLC_Frustum();
00067 
00069         GLC_Frustum(const GLC_Frustum&);
00070 
00072         ~GLC_Frustum();
00074 
00076 
00078 
00079 public:
00080 
00082         inline GLC_Plane leftClippingPlane() const
00083         {return m_PlaneList.at(LeftPlane);}
00084 
00086         inline GLC_Plane rightClippingPlane() const
00087         {return m_PlaneList.at(RightPlane);}
00088 
00090         inline GLC_Plane topClippingPlane() const
00091         {return m_PlaneList.at(TopPlane);}
00092 
00094         inline GLC_Plane bottomClippingPlane() const
00095         {return m_PlaneList.at(BottomPlane);}
00096 
00098         inline GLC_Plane nearClippingPlane() const
00099         {return m_PlaneList.at(NearPlane);}
00100 
00102         inline GLC_Plane farClippingPlane() const
00103         {return m_PlaneList.at(FarPlane);}
00104 
00106         Localisation localizeBoundingBox(const GLC_BoundingBox&) const;
00107 
00109         Localisation localizeSphere(const GLC_Point3d&, double) const;
00110 
00112 
00114 
00116 
00117 public:
00118 
00120         inline void setLeftClippingPlane(const GLC_Plane& plane)
00121         {m_PlaneList[LeftPlane]= plane;}
00122 
00124         inline void setRightClippingPlane(const GLC_Plane& plane)
00125         {m_PlaneList[RightPlane]= plane;}
00126 
00128         inline void setTopClippingPlane(const GLC_Plane& plane)
00129         {m_PlaneList[TopPlane]= plane;}
00130 
00132         inline void setBottomClippingPlane(const GLC_Plane& plane)
00133         {m_PlaneList[BottomPlane]= plane;}
00134 
00136         inline void setNearClippingPlane(const GLC_Plane& plane)
00137         {m_PlaneList[NearPlane]= plane;}
00138 
00140         inline void setFarClippingPlane(const GLC_Plane& plane)
00141         {m_PlaneList[FarPlane]= plane;}
00142 
00144 
00145         bool update(const GLC_Matrix4x4&);
00146 
00148 
00149 // Private services function
00151 private:
00153         Localisation localizeSphereToPlane(const GLC_Point3d&, double, const GLC_Plane&) const;
00154 
00156 // Private Member
00158 private:
00159 
00161         QList<GLC_Plane> m_PlaneList;
00162 
00164         GLC_Matrix4x4 m_PreviousMatrix;
00165 };
00166 
00167 #endif /* GLC_FRUSTUM_H_ */

SourceForge.net Logo

©2005 Laurent Ribon