コード例 #1
0
ファイル: Frustum.cpp プロジェクト: dabroz/Tamy
void Frustum::calculateBoundingBox( AxisAlignedBox& outBB ) const
{
   Vector points[8];
   PlaneUtils::calculatePlanesIntersection( planes[FP_LEFT], planes[FP_TOP], planes[FP_NEAR], points[0] );
   PlaneUtils::calculatePlanesIntersection( planes[FP_RIGHT], planes[FP_TOP], planes[FP_NEAR], points[1] );
   PlaneUtils::calculatePlanesIntersection( planes[FP_LEFT], planes[FP_BOTTOM], planes[FP_NEAR], points[2] );
   PlaneUtils::calculatePlanesIntersection( planes[FP_RIGHT], planes[FP_BOTTOM], planes[FP_NEAR], points[3] );
   PlaneUtils::calculatePlanesIntersection( planes[FP_LEFT], planes[FP_TOP], planes[FP_FAR], points[4] );
   PlaneUtils::calculatePlanesIntersection( planes[FP_RIGHT], planes[FP_TOP], planes[FP_FAR], points[5] );
   PlaneUtils::calculatePlanesIntersection( planes[FP_LEFT], planes[FP_BOTTOM], planes[FP_FAR], points[6] );
   PlaneUtils::calculatePlanesIntersection( planes[FP_RIGHT], planes[FP_BOTTOM], planes[FP_FAR], points[7] );

   outBB.min.set( FLT_MAX, FLT_MAX, FLT_MAX );
   outBB.max.set( -FLT_MAX, -FLT_MAX, -FLT_MAX );
   for ( char i = 0; i < 8; ++ i )
   {
      outBB.include( points[i] );
   }
}