Ejemplo n.º 1
0
	bool BoundingBox::CheckOutsideFrustum( const Frustum& f, const Matrix4& mat ) const
	{
		Halia::Vector3 v[] = 
		{
			mat.TransformCoord( Halia::Vector3( min.x, min.y, min.z ) ),
			mat.TransformCoord( Halia::Vector3( max.x, min.y, min.z ) ),
			mat.TransformCoord( Halia::Vector3( min.x, max.y, min.z ) ),
			mat.TransformCoord( Halia::Vector3( min.x, min.y, max.z ) ),
			mat.TransformCoord( Halia::Vector3( max.x, max.y, min.z ) ),
			mat.TransformCoord( Halia::Vector3( max.x, min.y, max.z ) ),
			mat.TransformCoord( Halia::Vector3( min.x, max.y, max.z ) ),
			mat.TransformCoord( Halia::Vector3( max.x, max.y, max.z ) )
		};

		for( int i = 0; i < 6; ++i )
		{
			int out = 0;
			int in = 0;
			for( int j = 0; j < 8; ++j )
			{
				if( f.p[i].DotProductCoord( v[j] ) < -2.0f )
					out++;
				else
					in++;
			}
			if( !in )
				return true;
			else if( out )
				return false;
		}
		return false;
	};
Ejemplo n.º 2
0
	void BoundingBox::AddTransformedBB( const BoundingBox& b, const Matrix4& mat )
	{
		AddPoint( mat.TransformCoord( Vector3( b.min.x, b.min.y, b.min.z ) ) );
		AddPoint( mat.TransformCoord( Vector3( b.min.x, b.max.y, b.min.z ) ) );
		AddPoint( mat.TransformCoord( Vector3( b.max.x, b.min.y, b.min.z ) ) );
		AddPoint( mat.TransformCoord( Vector3( b.min.x, b.min.y, b.max.z ) ) );
		AddPoint( mat.TransformCoord( Vector3( b.max.x, b.max.y, b.min.z ) ) );
		AddPoint( mat.TransformCoord( Vector3( b.max.x, b.min.y, b.max.z ) ) );
		AddPoint( mat.TransformCoord( Vector3( b.min.x, b.max.y, b.max.z ) ) );
		AddPoint( mat.TransformCoord( Vector3( b.max.x, b.max.y, b.max.z ) ) );
	};
Ejemplo n.º 3
0
	bool BoundingSphere::CheckOutsideFrustum( const Frustum& f, const Matrix4& mat ) const
	{
		Halia::Vector3 realcenter = mat.TransformCoord( center );

		for( int i = 0; i < 6; ++i )
		{
			if( f.p[i].DotProductCoord( realcenter ) < -radius )
				return true;
		}

		return false;
	};