X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2Fmoof%2Ffrustum.hh;fp=src%2Fmoof%2Ffrustum.hh;h=1e44701402577b26c2edc29c3c1dc948a717d471;hp=0000000000000000000000000000000000000000;hb=831f04d4bc19a390415ac0bbac4331c7a65509bc;hpb=299af4f2047e767e5d79501c26444473bda64c64 diff --git a/src/moof/frustum.hh b/src/moof/frustum.hh new file mode 100644 index 0000000..1e44701 --- /dev/null +++ b/src/moof/frustum.hh @@ -0,0 +1,74 @@ + +/*] Copyright (c) 2009-2010, Charles McGarvey [************************** +**] All rights reserved. +* +* vi:ts=4 sw=4 tw=75 +* +* Distributable under the terms and conditions of the 2-clause BSD license; +* see the file COPYING for a complete text of the license. +* +**************************************************************************/ + +#ifndef _MOOF_FRUSTUM_HH_ +#define _MOOF_FRUSTUM_HH_ + +/** + * \file frustum.hh + * All things related to frustums! + */ + +#include +#include + + +namespace moof { + + +template class aabb; +template class sphere; + + +/** + * A six-sided volume for representing the space visible by a position + * looking outward. + */ +class frustum +{ +public: + + enum collision + { + outside = 0, + inside = 1, + intersecting = 2 + }; + + frustum() {} + frustum(const matrix4& modelview, const matrix4& projection) + { + init(modelview, projection); + } + frustum(const matrix4& modelview, scalar fovy, scalar aspect, + scalar abutting, scalar distant) + { + init(modelview, fovy, aspect, abutting, distant); + } + + void init(const matrix4& modelview, const matrix4& projection); + void init(const matrix4& modelview, scalar fovy, scalar aspect, + scalar abutting, scalar distant); + + collision contains(const aabb<3>& aabb) const; + collision contains(const sphere<3>& sphere) const; + + +private: + + plane planes_[6]; // left, right, bottom, top, near, far +}; + + +} // namespace moof + +#endif // _MOOF_FRUSTUM_HH_ +