public static void DrawLine(Vector3 from, Vector3 to, System.Drawing.Color color) { var vertices = new PositionColored[2]; vertices[0] = new PositionColored(Vector3.Zero, color.ToArgb()); from = from.LSSwitchYZ(); to = to.LSSwitchYZ(); vertices[1] = new PositionColored(to - from, color.ToArgb()); InternalRender(from); Drawing.Direct3DDevice.DrawUserPrimitives(PrimitiveType.LineList, vertices.Length / 2, vertices); }
/// <summary> /// Draws the circle. /// </summary> /// <param name="position">The position.</param> /// <param name="radius">The radius.</param> /// <param name="color">The color.</param> /// <param name="width">The width.</param> /// <param name="zDeep">if set to <c>true</c> the circle will be drawn with depth buffering.</param> public static void DrawCircle(Vector3 position, float radius, Color color, int width = 5, bool zDeep = false) { try { if (Device == null || Device.IsDisposed) { return; } if (_vertices == null) { CreateVertexes(); } if (_vertices == null || _vertices.IsDisposed || _vertexDeclaration.IsDisposed || _effect.IsDisposed || _technique.IsDisposed) { return; } var olddec = Device.VertexDeclaration; _effect.Technique = _technique; _effect.Begin(); _effect.BeginPass(0); _effect.SetValue( "ProjectionMatrix", Matrix.Translation(position.LSSwitchYZ()) * Drawing.View * Drawing.Projection); _effect.SetValue( "CircleColor", new Vector4(color.R / 255f, color.G / 255f, color.B / 255f, color.A / 255f)); _effect.SetValue("Radius", radius); _effect.SetValue("Border", 2f + width); _effect.SetValue("zEnabled", zDeep); Device.SetStreamSource(0, _vertices, 0, Utilities.SizeOf<Vector4>() * 2); Device.VertexDeclaration = _vertexDeclaration; Device.DrawPrimitives(PrimitiveType.TriangleList, 0, 2); _effect.EndPass(); _effect.End(); Device.VertexDeclaration = olddec; } catch (Exception e) { _vertices = null; Console.WriteLine(@"DrawCircle: " + e); } }
public static void DrawLine(Line line, Vector3 from, Vector3 to, ColorBGRA color, Size size = default(Size), float[] scale = null, float rotation = 0.0f) { if (line != null) { from = from.LSSwitchYZ(); to = to.LSSwitchYZ(); Matrix nMatrix = (scale != null ? Matrix.Scaling(scale[0], scale[1], 0) : Matrix.Scaling(1)) * Matrix.RotationZ(rotation) * Matrix.Translation(from); Vector3[] vec = { from, to }; line.DrawTransform(vec, nMatrix, color); } }