/// <summary> /// Draw debug. /// </summary> /// <returns></returns> public override void DebugDraw() { if (!MyRender.Settings.DebugRenderClipmapCells) { return; } int lod = m_metadata.Cell.Lod; if (lod >= LOD_COLORS.Length) { return; } const double DRAW_DIST = 8.0; const double TARGET_DIST = 7.0; var targetPoint = MyRenderCamera.Position + (Vector3D)MyRenderCamera.ForwardVector * TARGET_DIST; var worldAabb = m_aabb; if (true) { MyDebugDraw.DrawAABBLine(ref m_aabb, ref LOD_COLORS[lod], 1f, true); } if (worldAabb.Distance(targetPoint) < DRAW_DIST && lod == 0) { if (false) { MyDebugDraw.DrawAABBLine(ref m_aabb, ref LOD_COLORS[lod], 1f, true); } } }
private static void DrawDebugMessages() { //DepthStencilState.None.Apply(); DepthStencilState.DepthRead.Apply(); BlendState.NonPremultiplied.Apply(); while (m_debugDrawMessages.Count > 0) { IMyRenderMessage debugDrawMessage = m_debugDrawMessages.Dequeue(); MyRenderMessageEnum messageType = debugDrawMessage.MessageType; switch (messageType) { case MyRenderMessageEnum.DebugDrawLine3D: { MyRenderMessageDebugDrawLine3D message = (MyRenderMessageDebugDrawLine3D)debugDrawMessage; MyDebugDraw.DrawLine3D( message.PointFrom, message.PointTo, message.ColorFrom, message.ColorTo, message.DepthRead); break; } case MyRenderMessageEnum.DebugDrawLine2D: { MyRenderMessageDebugDrawLine2D message = (MyRenderMessageDebugDrawLine2D)debugDrawMessage; MyDebugDraw.DrawLine2D( message.PointFrom, message.PointTo, message.ColorFrom, message.ColorTo, message.Projection); break; } case MyRenderMessageEnum.DebugDrawSphere: { MyRenderMessageDebugDrawSphere message = (MyRenderMessageDebugDrawSphere)debugDrawMessage; MyDebugDraw.DrawSphere( message.Position, message.Radius, message.Color, message.Alpha, message.DepthRead, message.Smooth, message.Cull); break; } case MyRenderMessageEnum.DebugDrawAABB: { MyRenderMessageDebugDrawAABB message = (MyRenderMessageDebugDrawAABB)debugDrawMessage; Color color = new Color(message.Color, message.Alpha); var aabb = new BoundingBoxD(message.AABB.Min, message.AABB.Max); MyDebugDraw.DrawAABBLine( ref aabb, ref color, message.Scale, message.DepthRead); break; } case MyRenderMessageEnum.DebugDrawAxis: { MyRenderMessageDebugDrawAxis message = (MyRenderMessageDebugDrawAxis)debugDrawMessage; MyDebugDraw.DrawAxis( (MatrixD)message.Matrix, message.AxisLength, 1, message.DepthRead); break; } case MyRenderMessageEnum.DebugDrawOBB: { MyRenderMessageDebugDrawOBB message = (MyRenderMessageDebugDrawOBB)debugDrawMessage; if (message.Smooth) { MyDebugDraw.DrawLowresBoxSmooth( message.Matrix, message.Color, message.Alpha, message.DepthRead, message.Cull); } else { MyDebugDraw.DrawOBBLine( new MyOrientedBoundingBoxD(message.Matrix), message.Color, message.Alpha, message.DepthRead); //BoundingBoxD bd = new BoundingBoxD(message.Matrix.Translation - new Vector3(100),message.Matrix.Translation + new Vector3(100)); //Vector4 c = new Vector4(message.Color.X, message.Color.Y, message.Color.Z, message.Alpha); //MyDebugDraw.DrawAABBLine(ref bd, ref c, 1, false); } break; } case MyRenderMessageEnum.DebugDrawCylinder: { MyRenderMessageDebugDrawCylinder message = (MyRenderMessageDebugDrawCylinder)debugDrawMessage; if (message.Smooth) { MyDebugDraw.DrawLowresCylinderSmooth( (MatrixD)message.Matrix, message.Color, message.Alpha, message.DepthRead); } else { MyDebugDraw.DrawLowresCylinderWireframe( (MatrixD)message.Matrix, message.Color, message.Alpha, message.DepthRead); } break; } case MyRenderMessageEnum.DebugDrawTriangle: { MyRenderMessageDebugDrawTriangle message = (MyRenderMessageDebugDrawTriangle)debugDrawMessage; MyDebugDraw.DrawTriangle((Vector3D)message.Vertex0, (Vector3D)message.Vertex1, (Vector3D)message.Vertex2, message.Color, message.Color, message.Color, message.Smooth, message.DepthRead); break; } case MyRenderMessageEnum.DebugDrawTriangles: { MyRenderMessageDebugDrawTriangles message = (MyRenderMessageDebugDrawTriangles)debugDrawMessage; MyDebugDraw.DrawTriangles(message.WorldMatrix, message.Vertices, message.Indices, message.Color, message.DepthRead, message.Shaded); break; } case MyRenderMessageEnum.DebugDrawCapsule: { MyRenderMessageDebugDrawCapsule message = (MyRenderMessageDebugDrawCapsule)debugDrawMessage; if (message.Shaded) { MyDebugDraw.DrawCapsuleShaded(message.P0, message.P1, message.Radius, message.Color, message.DepthRead); } else { MyDebugDraw.DrawCapsule(message.P0, message.P1, message.Radius, message.Color, message.DepthRead); } break; } case MyRenderMessageEnum.DebugDrawText2D: { MyRenderMessageDebugDrawText2D message = (MyRenderMessageDebugDrawText2D)debugDrawMessage; MyDebugDraw.DrawText( message.Coord, new StringBuilder(message.Text), message.Color, message.Scale, false, message.Align); break; } case MyRenderMessageEnum.DebugDrawText3D: { MyRenderMessageDebugDrawText3D message = (MyRenderMessageDebugDrawText3D)debugDrawMessage; MyDebugDraw.DrawText( (Vector3D)message.Coord, new StringBuilder(message.Text), message.Color, message.Scale, message.DepthRead, message.Align, message.CustomViewProjection); break; } case MyRenderMessageEnum.DebugDrawModel: { MyRenderMessageDebugDrawModel message = (MyRenderMessageDebugDrawModel)debugDrawMessage; MyDebugDraw.DrawModel(MyRenderModels.GetModel(message.Model), message.WorldMatrix, message.Color, message.DepthRead); break; } case MyRenderMessageEnum.DebugDrawPlane: { MyRenderMessageDebugDrawPlane message = (MyRenderMessageDebugDrawPlane)debugDrawMessage; MyDebugDraw.DrawPlane((Vector3D)message.Position, message.Normal, message.Color, message.DepthRead); break; } default: { System.Diagnostics.Debug.Assert(false, "Unknown debug draw message"); break; } } } }