当前位置: 首页>>代码示例>>C#>>正文


C# Vector4.Select方法代码示例

本文整理汇总了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;
        }
开发者ID:geofftnz,项目名称:snowscape,代码行数:47,代码来源:Frustum.cs


注:本文中的System.Vector4.Select方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。