本文整理汇总了C#中BoundingBox.GetCenter方法的典型用法代码示例。如果您正苦于以下问题:C# BoundingBox.GetCenter方法的具体用法?C# BoundingBox.GetCenter怎么用?C# BoundingBox.GetCenter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BoundingBox
的用法示例。
在下文中一共展示了BoundingBox.GetCenter方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawAABBLine
public static void DrawAABBLine(ref BoundingBox worldAABB, ref Vector4 color, float fScale)
{
Color colorC = new Color(color);
Vector3 center = worldAABB.GetCenter();
Vector3 halfSize = worldAABB.Size() * fScale * 0.5f;
Vector3 v0 = new Vector3(center.X - halfSize.X, center.Y - halfSize.Y, center.Z - halfSize.Z);
Vector3 v1 = new Vector3(center.X + halfSize.X, center.Y - halfSize.Y, center.Z - halfSize.Z);
Vector3 v2 = new Vector3(center.X - halfSize.X, center.Y + halfSize.Y, center.Z - halfSize.Z);
Vector3 v3 = new Vector3(center.X + halfSize.X, center.Y + halfSize.Y, center.Z - halfSize.Z);
Vector3 v4 = new Vector3(center.X - halfSize.X, center.Y - halfSize.Y, center.Z + halfSize.Z);
Vector3 v5 = new Vector3(center.X + halfSize.X, center.Y - halfSize.Y, center.Z + halfSize.Z);
Vector3 v6 = new Vector3(center.X - halfSize.X, center.Y + halfSize.Y, center.Z + halfSize.Z);
Vector3 v7 = new Vector3(center.X + halfSize.X, center.Y + halfSize.Y, center.Z + halfSize.Z);
MyDebugDraw.DrawLine3D(ref v0, ref v1, ref colorC, ref colorC);
MyDebugDraw.DrawLine3D(ref v0, ref v2, ref colorC, ref colorC);
MyDebugDraw.DrawLine3D(ref v2, ref v3, ref colorC, ref colorC);
MyDebugDraw.DrawLine3D(ref v3, ref v1, ref colorC, ref colorC);
MyDebugDraw.DrawLine3D(ref v4, ref v5, ref colorC, ref colorC);
MyDebugDraw.DrawLine3D(ref v4, ref v6, ref colorC, ref colorC);
MyDebugDraw.DrawLine3D(ref v6, ref v7, ref colorC, ref colorC);
MyDebugDraw.DrawLine3D(ref v5, ref v7, ref colorC, ref colorC);
MyDebugDraw.DrawLine3D(ref v0, ref v4, ref colorC, ref colorC);
MyDebugDraw.DrawLine3D(ref v1, ref v5, ref colorC, ref colorC);
MyDebugDraw.DrawLine3D(ref v2, ref v6, ref colorC, ref colorC);
MyDebugDraw.DrawLine3D(ref v3, ref v7, ref colorC, ref colorC);
}
示例2: Notify
public void Notify(BoundingBox bbox, MyEntity source)
{
System.Diagnostics.Debug.Assert(source == null || !source.Closed);
results.Clear();
m_dangerZoneStructure.OverlapAllBoundingBox<MyDangerZoneElement>(ref bbox, results);
foreach (var dangerZone in results)
{
if (source == null || (dangerZone.Bot != source && MyFactions.GetFactionsRelation(dangerZone.Bot, source) == MyFactionRelationEnum.Enemy))
{
dangerZone.Bot.AddCuriousLocation(source != null ? source.GetPosition() : bbox.GetCenter(), source);
}
}
}
示例3: DrawOcclusionBoundingBox
/// <summary>
/// Draw occlusion bounding box method with our premade effect and box.
/// </summary>
/// <param name="bbox"></param>
/// <param name="scale"></param>
/// <param name="enableDepthTesting"></param>
/// <param name="billboardLike">Indicates whether the occlusion object (box) is rotated to face the camera or not.</param>
public static void DrawOcclusionBoundingBox(BoundingBox bbox, float scale, bool enableDepthTesting, bool billboardLike = false, bool useDepthTarget = true)
{
useDepthTarget &= !MyRenderConstants.RenderQualityProfile.ForwardRender;
var cameraToBBox = bbox.GetCenter() - MyCamera.Position;
Matrix worldMatrix = billboardLike ? Matrix.CreateWorld(Vector3.Zero, MyMwcUtils.Normalize(cameraToBBox), MyMwcUtils.Normalize(MyCamera.UpVector + MyCamera.LeftVector)) : Matrix.Identity;
Vector3 scaleV = (bbox.Max - bbox.Min) * scale;
worldMatrix *= Matrix.CreateScale(scaleV);
worldMatrix.Translation = cameraToBBox;
MyEffectOcclusionQueryDraw effectOQ = MyRender.GetEffect(MyEffects.OcclusionQueryDrawMRT) as MyEffectOcclusionQueryDraw;
if (enableDepthTesting && !MyRenderConstants.RenderQualityProfile.ForwardRender)
effectOQ.SetTechnique(MyEffectOcclusionQueryDraw.Technique.DepthTestEnabled);
else
effectOQ.SetTechnique(MyEffectOcclusionQueryDraw.Technique.DepthTestDisabled);
effectOQ.SetWorldMatrix(worldMatrix);
effectOQ.SetViewMatrix(MyCamera.ViewMatrixAtZero);
effectOQ.SetProjectionMatrix(MyCamera.ProjectionMatrix);
if (useDepthTarget)
{
var depthRenderTarget = MyRender.GetRenderTarget(MyRenderTargets.Depth);
effectOQ.SetDepthRT(depthRenderTarget);
effectOQ.SetScale(MyRender.GetScaleForViewport(depthRenderTarget));
}
effectOQ.Begin();
//draw
m_modelBoxLowRes.Render();
effectOQ.End();
}
示例4: CreateWaypointsAroundLargeStaticObjects
//.........这里部分代码省略.........
{
var pos = w.Position;
box = box.Include(ref pos);
if (nonFree.Contains(w))
goto alreadyConnected;
}
BoundingBox extrudedBox = new BoundingBox(box.Min - (box.Max - box.Min) * 0.01f - new Vector3(5, 5, 5), box.Max + (box.Max - box.Min) * 0.01f + new Vector3(5, 5, 5));
// no - create a new one
int s = 1;
MyWayPoint[, ,] envelope = new MyWayPoint[s + 1, s + 1, s + 1];
for (int i = 0; i <= s; i++) for (int j = 0; j <= s; j++) for (int k = 0; k <= s; k++)
{
envelope[i, j, k] = CreateWaypoint(new Vector3(
extrudedBox.Min.X + i * (extrudedBox.Max.X - extrudedBox.Min.X) / s,
extrudedBox.Min.Y + j * (extrudedBox.Max.Y - extrudedBox.Min.Y) / s,
extrudedBox.Min.Z + k * (extrudedBox.Max.Z - extrudedBox.Min.Z) / s
), null);
envelope[i, j, k].Save = false; // don't save generated waypoints
nonFree.Add(envelope[i, j, k]);
// connect with neighbors
// should use ConnectIfVisible, but it's slow and we can resolve it while computing the GPS
if (i != 0) { if (MyWayPoint.ConnectIfNoAABBBlockers(envelope[i, j, k], envelope[i - 1, j, k])) edgesWithRaycastsAdded++; else edgesWithRaycastsNotAdded++; }
if (j != 0) { if (MyWayPoint.ConnectIfNoAABBBlockers(envelope[i, j, k], envelope[i, j - 1, k])) edgesWithRaycastsAdded++; else edgesWithRaycastsNotAdded++; }
if (k != 0) { if (MyWayPoint.ConnectIfNoAABBBlockers(envelope[i, j, k], envelope[i, j, k - 1])) edgesWithRaycastsAdded++; else edgesWithRaycastsNotAdded++; }
}
// connect all waypoints to the closest corner of the new envelope
foreach (var w in connectedWaypoints)
{
var pos = w.Position;
if (MyWayPoint.ConnectIfNoAABBBlockers(w, envelope[pos.X < extrudedBox.GetCenter().X ? 0 : 1, pos.Y < extrudedBox.GetCenter().Y ? 0 : 1, pos.Z < extrudedBox.GetCenter().Z ? 0 : 1]))
edgesWithRaycastsAdded++;
else
edgesWithRaycastsNotAdded++;
}
envelopes.Add(envelope);
envelopeEntity.Add(null);
envelopeBvh.AddProxy(ref extrudedBox, envelopes.Count - 1, 0);
freeEnvelopes++;
alreadyConnected: { }
}
MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();
MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("connect envelopes");
// connect envelopes together
for (int eIndex = 0; eIndex < envelopes.Count; eIndex++)
{
var e = envelopes[eIndex];
int es = e.GetLength(0) - 1;
var eCenter = 0.5f * (e[0, 0, 0].Position + e[es, es, es].Position);
// get K closest indices
var closestEnvelopeIndices = new List<int>();
for (int i = 200; i <= 6400; i *= 2) // try 200, 400, 800, 1600, 3200, 6400 m
{
var halfExtent = new Vector3(i);
var bbox = new BoundingBox(eCenter - halfExtent, eCenter + halfExtent);
envelopeBvh.OverlapAllBoundingBox(ref bbox, closestEnvelopeIndices);
if (closestEnvelopeIndices.Count >= 16) break;
}
示例5: FastOcclusionBoundingBoxDraw
/// <summary>
/// Needs to have PrepareFastOcclusionBoundingBoxDraw() called first
/// </summary>
public static void FastOcclusionBoundingBoxDraw(BoundingBox bbox, float scale)
{
Vector3 scaleV = (bbox.Max - bbox.Min) * scale;
Matrix worldMatrix = Matrix.CreateScale(scaleV);
worldMatrix.Translation = bbox.GetCenter() - MyCamera.Position;
MyEffectOcclusionQueryDraw effectOQ = MyRender.GetEffect(MyEffects.OcclusionQueryDrawMRT) as MyEffectOcclusionQueryDraw;
effectOQ.SetWorldMatrix(worldMatrix);
effectOQ.SetTechnique(MyRenderConstants.RenderQualityProfile.ForwardRender ? MyEffectOcclusionQueryDraw.Technique.DepthTestDisabled : MyEffectOcclusionQueryDraw.Technique.DepthTestEnabled);
effectOQ.Begin();
//draw
m_modelBoxLowRes.Render();
MyPerformanceCounter.PerCameraDraw.TotalDrawCalls++;
effectOQ.End();
}