private void drawSkeleton(float[] output, Color color) { int totalVertices = output.Length/2; var vertices = new VertexPositionColor[totalVertices]; for (int j = 0, i=0; j < totalVertices; j = j + 4, i = i+2) { vertices[i].Position = new Vector3(output[j], output[j + 1], 0); vertices[i + 1].Position = new Vector3(output[j + 2], output[j + 3], 0); vertices[i].Color = color; vertices[i + 1].Color = color; } if (totalVertices > 0) { basicEffect.CurrentTechnique.Passes[0].Apply(); GraphicsDevice.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.LineList, vertices, 0, vertices.Count() / 2); } }
public void DrawCircle(Fixture ObjectPhysic, Color colorFill) { CircleShape circle = (CircleShape)ObjectPhysic.Shape; Transform xf; ObjectPhysic.Body.GetTransform(out xf); Vector2 center = MathUtils.Multiply(ref xf, circle.Position); float radius = circle.Radius; const int segments = 32; const double increment = Math.PI * 2.0 / segments; double theta = 0.0; Vector2 v0 = center + radius * new Vector2((float)Math.Cos(theta), (float)Math.Sin(theta)); theta += increment; VertexPositionColor[] _vertsFill = new VertexPositionColor[(segments-2)*3]; for (int i = 1; i < segments - 1; i++) { Vector2 v1 = center + radius * new Vector2((float)Math.Cos(theta), (float)Math.Sin(theta)); Vector2 v2 = center + radius * new Vector2((float)Math.Cos(theta + increment), (float)Math.Sin(theta + increment)); _vertsFill[(i-1) * 3].Position = new Vector3(v0, 0.0f); _vertsFill[(i - 1) * 3].Color = colorFill; _vertsFill[(i - 1) * 3 + 1].Position = new Vector3(v1, 0.0f); _vertsFill[(i - 1) * 3 + 1].Color = colorFill; _vertsFill[(i - 1) * 3 + 2].Position = new Vector3(v2, 0.0f); _vertsFill[(i - 1) * 3 + 2].Color = colorFill; theta += increment; } EnvironmentVariable.graphics.GraphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, _vertsFill, 0, (_vertsFill.Count() / 3) ); }