public override void Draw() { base.Draw(); if (MySector.MainCamera != null) { var pos = MySector.MainCamera.Position; var dir = MySector.MainCamera.ForwardVector; var hit = MyPhysics.CastRay(pos, pos + 500 * dir); if (hit.HasValue) { var entity = hit.Value.HkHitInfo.GetHitEntity(); if (entity != null) { var voxel = entity.GetTopMostParent() as MyVoxelPhysics; if (voxel != null) { var planet = voxel.Parent; var grav = planet as IMyGravityProvider; if (grav != null) { var gravity = grav.GetWorldGravity(hit.Value.Position); gravity.Normalize(); var point = planet.PositionComp.GetPosition() - gravity * 9503; MyRenderProxy.DebugDrawSphere(point, 0.5f, Color.Red, 1, false); MyRenderProxy.DebugDrawSphere(point, 5.5f, Color.Yellow, 1, false); hit = MyPhysics.CastRay(point, point + gravity * 500); if (hit.HasValue) { MyRenderProxy.DebugDrawText2D(new Vector2(10, 10), (hit.Value.HkHitInfo.HitFraction * 500).ToString(), Color.White, 0.8f); } } } } } } if (!MyDebugDrawSettings.ENABLE_DEBUG_DRAW) { return; } if (MyCubeBuilder.Static == null) { return; } if (m_smartPath != null) { m_smartPath.DebugDraw(); VRageRender.MyRenderProxy.DebugDrawSphere(m_currentTarget, 2.0f, Color.HotPink, 1.0f, false); for (int i = 1; i < m_pastTargets.Count; ++i) { VRageRender.MyRenderProxy.DebugDrawLine3D(m_pastTargets[i], m_pastTargets[i - 1], Color.Blue, Color.Blue, false); } } var bb = MyCubeBuilder.Static.GetBuildBoundingBox(); VRageRender.MyRenderProxy.DebugDrawOBB(bb, Color.Red, 0.25f, false, false); var src = MyScreenManager.GetScreenWithFocus(); if (MyScreenManager.GetScreenWithFocus() == null || MyScreenManager.GetScreenWithFocus().DebugNamePath != "MyGuiScreenGamePlay") { return; } if (m_drawSphere) { VRageRender.MyRenderProxy.DebugDrawSphere(m_sphere.Center, m_sphere.Radius, Color.Red, 1.0f, false, cull: true); VRageRender.MyRenderProxy.DebugDrawAxis(m_sphereMatrix, 50.0f, false); VRageRender.MyRenderProxy.DebugDrawText2D(new Vector2(200.0f, 0.0f), m_string, Color.Red, 0.5f); } VRageRender.MyRenderProxy.DebugDrawSphere(m_point1, 0.5f, Color.Orange.ToVector3(), 1.0f, true); VRageRender.MyRenderProxy.DebugDrawSphere(m_point2, 0.5f, Color.Orange.ToVector3(), 1.0f, true); foreach (var point in DebugDrawPoints) { //VRageRender.MyRenderProxy.DebugDrawSphere(point.Position, 0.05f, point.Color.ToVector3(), 1.0f, false); VRageRender.MyRenderProxy.DebugDrawSphere(point.Position, 0.03f, point.Color, 1.0f, false); } foreach (var sphere in DebugDrawSpheres) { VRageRender.MyRenderProxy.DebugDrawSphere(sphere.Position, sphere.Radius, sphere.Color, 1.0f, false); } foreach (var box in DebugDrawBoxes) { VRageRender.MyRenderProxy.DebugDrawAABB(box.Box, box.Color, 1.0f, 1.0f, false); } if (DebugDrawMesh != null) { Matrix identity = Matrix.Identity; DebugDrawMesh.DebugDraw(ref identity, MyDebugDrawSettings.DEBUG_DRAW_NAVMESHES); } foreach (var poly in DebugDrawPolys) { MatrixD identity = MatrixD.Identity; poly.DebugDraw(ref identity); } MyPolygonBoolOps.Static.DebugDraw(MatrixD.Identity); if (Boxes != null) { foreach (var box in Boxes) { VRageRender.MyRenderProxy.DebugDrawAABB(box, Color.Red, 1.0f, 1.0f, true); } } }
public virtual void DebugDraw(ref Matrix drawMatrix) { if (!MyDebugDrawSettings.ENABLE_DEBUG_DRAW) { return; } if (MyDebugDrawSettings.DEBUG_DRAW_NAVMESHES != MyWEMDebugDrawMode.NONE) { m_mesh.DebugDraw(ref drawMatrix, MyDebugDrawSettings.DEBUG_DRAW_NAVMESHES); m_mesh.CustomDebugDrawFaces(ref drawMatrix, MyDebugDrawSettings.DEBUG_DRAW_NAVMESHES, (obj) => (obj as MyNavigationTriangle).Index.ToString()); } //VRageRender.MyRenderProxy.DebugDrawText2D(new Vector2(0.0f, 0.0f), "Navmesh size approximation: " + ApproximateMemoryFootprint() + "B", Color.Yellow, 1.0f); if (MyFakes.DEBUG_DRAW_FUNNEL) { VRageRender.MyRenderProxy.DebugDrawSphere(Vector3.Transform(m_vertex, drawMatrix), 0.05f, Color.Yellow.ToVector3(), 1.0f, false); VRageRender.MyRenderProxy.DebugDrawSphere(Vector3.Transform(m_vertex + m_normal, drawMatrix), 0.05f, Color.Orange.ToVector3(), 1.0f, false); VRageRender.MyRenderProxy.DebugDrawSphere(Vector3.Transform(m_left, drawMatrix), 0.05f, Color.Red.ToVector3(), 1.0f, false); VRageRender.MyRenderProxy.DebugDrawSphere(Vector3.Transform(m_right, drawMatrix), 0.05f, Color.Green.ToVector3(), 1.0f, false); foreach (var point in m_debugPointsLeft) { VRageRender.MyRenderProxy.DebugDrawSphere(Vector3.Transform(point, drawMatrix), 0.03f, Color.Red.ToVector3(), 1.0f, false); } foreach (var point in m_debugPointsRight) { VRageRender.MyRenderProxy.DebugDrawSphere(Vector3.Transform(point, drawMatrix), 0.04f, Color.Green.ToVector3(), 1.0f, false); } Vector3?prevPoint = null; if (m_path != null) { foreach (var point in m_path) { Vector3 pointWorld = Vector3.Transform(point, drawMatrix); VRageRender.MyRenderProxy.DebugDrawSphere(pointWorld + Vector3.Up * 0.2f, 0.02f, Color.Orange.ToVector3(), 1.0f, false); if (prevPoint.HasValue) { VRageRender.MyRenderProxy.DebugDrawLine3D(prevPoint.Value + Vector3.Up * 0.2f, pointWorld + Vector3.Up * 0.2f, Color.Orange, Color.Orange, true); } prevPoint = pointWorld; } } prevPoint = null; if (m_path2 != null) { foreach (var point in m_path2) { Vector3 pointWorld = Vector3.Transform(point, drawMatrix); if (prevPoint.HasValue) { VRageRender.MyRenderProxy.DebugDrawLine3D(prevPoint.Value + Vector3.Up * 0.1f, pointWorld + Vector3.Up * 0.1f, Color.Violet, Color.Violet, true); } prevPoint = pointWorld; } } if (m_debugFunnel.Count > 0) { var section = m_debugFunnel[m_debugFunnelIdx % m_debugFunnel.Count]; var a = Vector3.Transform(section.Apex, drawMatrix); var l = Vector3.Transform(section.Left, drawMatrix); var r = Vector3.Transform(section.Right, drawMatrix); l = a + (l - a) * 10.0f; r = a + (r - a) * 10.0f; Color c = Color.Cyan; VRageRender.MyRenderProxy.DebugDrawLine3D(a + Vector3.Up * 0.1f, l + Vector3.Up * 0.1f, c, c, true); VRageRender.MyRenderProxy.DebugDrawLine3D(a + Vector3.Up * 0.1f, r + Vector3.Up * 0.1f, c, c, true); } } }