當前位置: 首頁>>代碼示例>>C#>>正文


C# BoundingBox.IsInside方法代碼示例

本文整理匯總了C#中BoundingBox.IsInside方法的典型用法代碼示例。如果您正苦於以下問題:C# BoundingBox.IsInside方法的具體用法?C# BoundingBox.IsInside怎麽用?C# BoundingBox.IsInside使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在BoundingBox的用法示例。


在下文中一共展示了BoundingBox.IsInside方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: CreateBoundingSphere

        /// <summary>
        /// Implicitly initializes the bounding sphere.
        /// Calculates the bounding sphere automatically
        /// </summary>
        /// <param name="center"></param>
        /// <param name="radius"></param>
        public void CreateBoundingSphere()
        {
            this.boundingSphere = new HairBoundingSphere(new Vector3(0, 0, 0), 0);

            // Get lowest xyz and highest xyz coordinates
            Vector3 lowest = new Vector3(float.MaxValue, float.MaxValue, float.MaxValue);
            Vector3 highest = Vector3.Zero;

            // Iterate through every vertex
            foreach (HairMesh m in this.meshes)
            {
                if (m != null)
                    foreach (HairStrand s in m.strands)
                        foreach (HairStrandVertex v in s.vertices)
                        {
                            // Lowest
                            lowest.x = (lowest.x > v.position.x) ? v.position.x : lowest.x;
                            lowest.y = (lowest.y > v.position.y) ? v.position.y : lowest.y;
                            lowest.z = (lowest.z > v.position.z) ? v.position.z : lowest.z;

                            // Highest
                            highest.x = (highest.x < v.position.x) ? v.position.x : highest.x;
                            highest.y = (highest.y < v.position.y) ? v.position.y : highest.y;
                            highest.z = (highest.z < v.position.z) ? v.position.z : highest.z;
                        }
            }

            BoundingBox boundingBox = new BoundingBox(lowest, highest);
            this.boundingSphere.center = boundingBox.Center;
            this.boundingSphere.radius = boundingBox.IsInside(boundingBox.Center) ? (boundingBox.Center - highest).Length : 0f;
        }
開發者ID:kennux,項目名稱:TressFXUnity,代碼行數:37,代碼來源:Hair.cs


注:本文中的BoundingBox.IsInside方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。