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


C# BoundingFrustum.ToBoundingSphere方法代碼示例

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


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

示例1: GetIntersectionWithBoundingFrustum

        public override bool GetIntersectionWithBoundingFrustum(ref BoundingFrustum boundingFrustum)
        {
            ContainmentType con = boundingFrustum.Contains(WorldAABB);
            if (con == ContainmentType.Contains)
            {
                return true;
            }

            if (con == ContainmentType.Intersects)
            {
                BoundingSphere sphere = boundingFrustum.ToBoundingSphere(HelperFrustumCorners);

                //  Get min and max cell coordinate where boundingBox can fit
                BoundingBox sphereBoundingBox = BoundingBoxHelper.InitialBox;
                BoundingBoxHelper.AddSphere(sphere, ref sphereBoundingBox);
                MyMwcVector3Int cellCoordMin = GetDataCellCoordinateFromMeters(ref sphereBoundingBox.Min);
                MyMwcVector3Int cellCoordMax = GetDataCellCoordinateFromMeters(ref sphereBoundingBox.Max);

                //  Fix min and max cell coordinates so they don't overlap the voxelmap
                FixDataCellCoord(ref cellCoordMin);
                FixDataCellCoord(ref cellCoordMax);

                MyMwcVector3Int cellCoord;
                for (cellCoord.X = cellCoordMin.X; cellCoord.X <= cellCoordMax.X; cellCoord.X++)
                {
                    for (cellCoord.Y = cellCoordMin.Y; cellCoord.Y <= cellCoordMax.Y; cellCoord.Y++)
                    {
                        for (cellCoord.Z = cellCoordMin.Z; cellCoord.Z <= cellCoordMax.Z; cellCoord.Z++)
                        {
                            //  If no overlap between bounding pitch of data cell and the sphere
                            BoundingBox dataCellBoundingBox;
                            GetDataCellBoundingBox(ref cellCoord, out dataCellBoundingBox);
                            if (MyUtils.IsBoxIntersectingSphere(ref dataCellBoundingBox, ref sphere) == false) continue;

                            //  Get cell from cache. If not there, precalc it and store in the cache.
                            //  If null is returned, we know that cell doesn't contain any triangleVertexes so we don't need to do intersections.
                            MyVoxelCacheCellData cachedDataCell = null;
                            using (MyVoxelCacheData.Locker.AcquireSharedUsing())
                            {
                                cachedDataCell = MyVoxelCacheData.GetCell(this, ref cellCoord, true);

                                if (cachedDataCell == null) continue;

                                for (int i = 0; i < cachedDataCell.VoxelTrianglesCount; i++)
                                {
                                    MyVoxelTriangle voxelTriangle = cachedDataCell.VoxelTriangles[i];

                                    MyVoxelVertex voxelVertex0 = cachedDataCell.VoxelVertices[voxelTriangle.VertexIndex0];
                                    MyVoxelVertex voxelVertex1 = cachedDataCell.VoxelVertices[voxelTriangle.VertexIndex1];
                                    MyVoxelVertex voxelVertex2 = cachedDataCell.VoxelVertices[voxelTriangle.VertexIndex2];

                                    if (boundingFrustum.Contains(voxelVertex0.Position + PositionLeftBottomCorner) == ContainmentType.Contains)
                                        return true;
                                    if (boundingFrustum.Contains(voxelVertex1.Position + PositionLeftBottomCorner) == ContainmentType.Contains)
                                        return true;
                                    if (boundingFrustum.Contains(voxelVertex2.Position + PositionLeftBottomCorner) == ContainmentType.Contains)
                                        return true;
                                }
                            }
                        }
                    }
                }
            }
            return false;
        }
開發者ID:Bunni,項目名稱:Miner-Wars-2081,代碼行數:65,代碼來源:MyVoxelMap.cs


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