00001 /* 00002 * ViewFrustum header 00003 * 00004 * This file is part of the "SoftPixel Engine" (Copyright (c) 2008 by Lukas Hermanns) 00005 * See "SoftPixelEngine.hpp" for license information. 00006 */ 00007 00008 #ifndef __SP_VIEWFRUSTUM_H__ 00009 #define __SP_VIEWFRUSTUM_H__ 00010 00011 00012 #include "Base/spStandard.hpp" 00013 #include "Base/spConvexPolyhedron.hpp" 00014 00015 00016 namespace sp 00017 { 00018 namespace scene 00019 { 00020 00021 00023 enum EViewFrustumPlanes 00024 { 00025 VIEWFRUSTUM_NEAR = 0, 00026 VIEWFRUSTUM_FAR, 00027 VIEWFRUSTUM_LEFT, 00028 VIEWFRUSTUM_RIGHT, 00029 VIEWFRUSTUM_BOTTOM, 00030 VIEWFRUSTUM_TOP, 00031 00032 VIEWFRUSTUM_PLANE_COUNT, 00033 }; 00034 00035 00044 class SP_EXPORT ViewFrustum : public ConvexPolyhedron<f32, VIEWFRUSTUM_PLANE_COUNT> 00045 { 00046 00047 public: 00048 00049 ViewFrustum(); 00050 ViewFrustum(const dim::matrix4f &Matrix); 00051 ViewFrustum(const ViewFrustum &Other); 00052 virtual ~ViewFrustum(); 00053 00054 /* === Functions === */ 00055 00057 void setFrustum(const dim::matrix4f &Matrix); 00058 00060 void setFrustum(const dim::matrix4f &ViewMatrix, const dim::matrix4f &ProjectionMatrix); 00061 00063 dim::vector3df getLeftUp() const; 00064 00066 dim::vector3df getLeftDown() const; 00067 00069 dim::vector3df getRightUp() const; 00070 00072 dim::vector3df getRightDown() const; 00073 00074 /* === Inline functions === */ 00075 00077 inline const dim::plane3df& getPlane(const EViewFrustumPlanes Type) const 00078 { 00079 return Planes_[Type]; 00080 } 00082 inline dim::plane3df& getPlane(const EViewFrustumPlanes Type) 00083 { 00084 return Planes_[Type]; 00085 } 00086 00087 }; 00088 00089 00090 } // /namespace scene 00091 00092 } // /namespace sp 00093 00094 00095 #endif 00096 00097 00098 00099 // ================================================================================