本文整理汇总了C#中System.Vector4.Select方法的典型用法代码示例。如果您正苦于以下问题:C# Vector4.Select方法的具体用法?C# Vector4.Select怎么用?C# Vector4.Select使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Vector4
的用法示例。
在下文中一共展示了Vector4.Select方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestBox
/// <summary>
/// http://www.iquilezles.org/www/articles/frustumcorrect/frustumcorrect.htm
/// </summary>
/// <param name="ps"></param>
/// <returns></returns>
public ObjectClipResult TestBox(Vector4[] ps)
{
float mMinX, mMinY, mMinZ, mMaxX, mMaxY, mMaxZ;
mMinX = ps.Select(v => v.X).Min();
mMinY = ps.Select(v => v.Y).Min();
mMinZ = ps.Select(v => v.Z).Min();
mMaxX = ps.Select(v => v.X).Max();
mMaxY = ps.Select(v => v.Y).Max();
mMaxZ = ps.Select(v => v.Z).Max();
// check box outside/inside of frustum
int boxout;
bool boxpartial = false;
for (int i = 0; i < 6; i++)
{
boxout = 0;
boxout += ((Vector4.Dot(clippingPlane[i], new Vector4(mMinX, mMinY, mMinZ, 1.0f)) < 0.0) ? 1 : 0);
boxout += ((Vector4.Dot(clippingPlane[i], new Vector4(mMaxX, mMinY, mMinZ, 1.0f)) < 0.0) ? 1 : 0);
boxout += ((Vector4.Dot(clippingPlane[i], new Vector4(mMinX, mMaxY, mMinZ, 1.0f)) < 0.0) ? 1 : 0);
boxout += ((Vector4.Dot(clippingPlane[i], new Vector4(mMaxX, mMaxY, mMinZ, 1.0f)) < 0.0) ? 1 : 0);
boxout += ((Vector4.Dot(clippingPlane[i], new Vector4(mMinX, mMinY, mMaxZ, 1.0f)) < 0.0) ? 1 : 0);
boxout += ((Vector4.Dot(clippingPlane[i], new Vector4(mMaxX, mMinY, mMaxZ, 1.0f)) < 0.0) ? 1 : 0);
boxout += ((Vector4.Dot(clippingPlane[i], new Vector4(mMinX, mMaxY, mMaxZ, 1.0f)) < 0.0) ? 1 : 0);
boxout += ((Vector4.Dot(clippingPlane[i], new Vector4(mMaxX, mMaxY, mMaxZ, 1.0f)) < 0.0) ? 1 : 0);
if (boxout == 8) return ObjectClipResult.TotallyOutside;
if (boxout > 0) boxpartial = true;
}
if (!boxpartial) return ObjectClipResult.TotallyInside;
int boxout2;
boxout2=0; for( int i=0; i<8; i++ ) boxout2 += ((corner[i].X > mMaxX)?1:0); if( boxout2==8 ) return ObjectClipResult.TotallyOutside;
boxout2=0; for( int i=0; i<8; i++ ) boxout2 += ((corner[i].X < mMinX)?1:0); if( boxout2==8 ) return ObjectClipResult.TotallyOutside;
boxout2=0; for( int i=0; i<8; i++ ) boxout2 += ((corner[i].Y > mMaxY)?1:0); if( boxout2==8 ) return ObjectClipResult.TotallyOutside;
boxout2=0; for( int i=0; i<8; i++ ) boxout2 += ((corner[i].Y < mMinY)?1:0); if( boxout2==8 ) return ObjectClipResult.TotallyOutside;
boxout2=0; for( int i=0; i<8; i++ ) boxout2 += ((corner[i].Z > mMaxZ)?1:0); if( boxout2==8 ) return ObjectClipResult.TotallyOutside;
boxout2=0; for( int i=0; i<8; i++ ) boxout2 += ((corner[i].Z < mMinZ)?1:0); if( boxout2==8 ) return ObjectClipResult.TotallyOutside;
return ObjectClipResult.PartiallyInside;
}