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


C# Plane.GetSide方法代码示例

本文整理汇总了C#中Plane.GetSide方法的典型用法代码示例。如果您正苦于以下问题:C# Plane.GetSide方法的具体用法?C# Plane.GetSide怎么用?C# Plane.GetSide使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Plane的用法示例。


在下文中一共展示了Plane.GetSide方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetClipPlanesForDirectionalLightShadowGeneration

        static Plane[] GetClipPlanesForDirectionalLightShadowGeneration( Camera camera,
            RenderLight light, float farClipDistance)
        {
            float shadowFarDistance = SceneManager.Instance.ShadowFarDistance;

            Frustum cameraFrustum = FrustumUtils.GetFrustumByCamera( camera, farClipDistance );

            Vec3 cameraPosition = cameraFrustum.Origin;

            Vec3 farCenterPoint;
            {
                float distance = shadowFarDistance;
                //small border
                distance *= 1.05f;

                //not optimal
                distance *= MathFunctions.Sqrt( 2 );

                farCenterPoint = cameraPosition + cameraFrustum.Axis.Item0 * distance;
            }
            Vec3 pyramidCenter = ( cameraPosition + farCenterPoint ) * .5f;

            Plane farPlane;
            {
                Vec3 normal = ( farCenterPoint - cameraPosition ).GetNormalize();
                float distance = Vec3.Dot( normal, farCenterPoint );
                farPlane = new Plane( normal, distance );
            }

            Vec3[] farCorners = new Vec3[ 4 ];
            {
                //4 - top-right far, 5 - top-left far, 6 - bottom-left far, 7 - bottom-right far.
                Vec3[] points = camera.GetWorldSpaceCorners();

                for( int n = 0; n < 4; n++ )
                {
                    Ray ray = new Ray( cameraPosition, points[ n + 4 ] - cameraPosition );
                    float scale;
                    farPlane.RayIntersection( ray, out scale );
                    farCorners[ n ] = ray.GetPointOnRay( scale );
                }
            }

            Vec3[] pyramidPoints = new Vec3[ 5 ];
            {
                pyramidPoints[ 0 ] = cameraPosition;
                for( int n = 0; n < 4; n++ )
                    pyramidPoints[ n + 1 ] = farCorners[ n ];
            }

            Line[] pyramidEdges = new Line[ 8 ];
            {
                for( int n = 0; n < 4; n++ )
                {
                    pyramidEdges[ n ] = new Line( cameraPosition, farCorners[ n ] );
                    pyramidEdges[ n + 4 ] = new Line( farCorners[ n ],
                        farCorners[ ( n + 1 ) % 4 ] );
                }
            }

            List<Plane> clipPlanes = new List<Plane>( 7 );
            {
                Vec3 lightDirectionOffset = light.Direction * 10000.0f;

                //back planes
                {
                    if( farPlane.GetSide( farCenterPoint - lightDirectionOffset ) ==
                        Plane.Side.Negative )
                    {
                        clipPlanes.Add( farPlane );
                    }

                    for( int n = 0; n < 4; n++ )
                    {
                        Plane plane = Plane.FromPoints( cameraPosition, farCorners[ n ],
                            farCorners[ ( n + 1 ) % 4 ] );

                        if( plane.GetSide( cameraPosition - lightDirectionOffset ) ==
                            Plane.Side.Negative )
                        {
                            clipPlanes.Add( farPlane );
                        }
                    }
                }

                //generate edge planes
                foreach( Line pyramidEdge in pyramidEdges )
                {
                    Vec3 p1 = pyramidEdge.Start;
                    Vec3 p2 = pyramidEdge.End;
                    Vec3 p3 = p1 - lightDirectionOffset;

                    Plane plane;
                    {
                        plane = Plane.FromPoints( p1, p2, p3 );
                        if( plane.GetSide( pyramidCenter ) == Plane.Side.Positive )
                            plane = Plane.FromPoints( p2, p1, p3 );
                    }

                    bool existsPyramidPointsOnBothSides = false;
//.........这里部分代码省略.........
开发者ID:DarrenHassan,项目名称:GDM4242-GroupD,代码行数:101,代码来源:LowLevelSceneManagement.cs


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