本文整理汇总了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;
}