Ejemplo n.º 1
0
        ConvexPolyhedron GetConvexPolyhedronFromFrustum( ref Frustum frustum )
        {
            Vec3[] frustumPoints = null;
            frustum.ToPoints( ref frustumPoints );

            Vec3[] points = new Vec3[ 5 ];
            points[ 0 ] = frustum.Origin;
            points[ 1 ] = frustumPoints[ 4 ];
            points[ 2 ] = frustumPoints[ 5 ];
            points[ 3 ] = frustumPoints[ 6 ];
            points[ 4 ] = frustumPoints[ 7 ];

            ConvexPolyhedron.Face[] faces = new ConvexPolyhedron.Face[ 6 ];
            faces[ 0 ] = new ConvexPolyhedron.Face( 0, 1, 2 );
            faces[ 1 ] = new ConvexPolyhedron.Face( 0, 2, 3 );
            faces[ 2 ] = new ConvexPolyhedron.Face( 0, 3, 4 );
            faces[ 3 ] = new ConvexPolyhedron.Face( 0, 4, 1 );
            faces[ 4 ] = new ConvexPolyhedron.Face( 1, 3, 2 );
            faces[ 5 ] = new ConvexPolyhedron.Face( 3, 1, 4 );

            return new ConvexPolyhedron( points, faces, .0001f );
        }
		ConvexPolyhedron GetConvexPolyhedronFromFrustum( ref Frustum frustum )
		{
			Vec3[] points = null;
			frustum.ToPoints( ref points );

			ConvexPolyhedron.Face[] faces = new ConvexPolyhedron.Face[ 12 ];

			faces[ 0 ] = new ConvexPolyhedron.Face( 5, 4, 7 );
			faces[ 1 ] = new ConvexPolyhedron.Face( 7, 6, 5 );
			faces[ 2 ] = new ConvexPolyhedron.Face( 0, 1, 2 );
			faces[ 3 ] = new ConvexPolyhedron.Face( 2, 3, 0 );

			faces[ 4 ] = new ConvexPolyhedron.Face( 4, 0, 3 );
			faces[ 5 ] = new ConvexPolyhedron.Face( 3, 7, 4 );
			faces[ 6 ] = new ConvexPolyhedron.Face( 1, 5, 6 );
			faces[ 7 ] = new ConvexPolyhedron.Face( 6, 2, 1 );

			faces[ 8 ] = new ConvexPolyhedron.Face( 6, 7, 3 );
			faces[ 9 ] = new ConvexPolyhedron.Face( 3, 2, 6 );
			faces[ 10 ] = new ConvexPolyhedron.Face( 4, 5, 1 );
			faces[ 11 ] = new ConvexPolyhedron.Face( 1, 0, 4 );

			return new ConvexPolyhedron( points, faces, .0001f );
		}