当前位置: 首页>>代码示例>>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;未经允许,请勿转载。