public void DrawSegment(FVector2 start, FVector2 end, Color color) { //if (!_primitiveBatch.IsReady()) //{ // throw new InvalidOperationException("BeginCustomDraw must be called before drawing anything."); //} lineListBatch.Add(FDVertex.FromLine(start, end, color)); //_primitiveBatch.AddVertex(start, color, PrimitiveType.LineList); //_primitiveBatch.AddVertex(end, color, PrimitiveType.LineList); }
public void DrawPolygon(FVector2[] vertices, int count, Color color) { //if (!_primitiveBatch.IsReady()) //{ // throw new InvalidOperationException("BeginCustomDraw must be called before drawing anything."); //} for (int i = 0; i < count - 1; i++) { lineListBatch.Add(FDVertex.FromLine(vertices[i], vertices[i + 1], color)); //_primitiveBatch.AddVertex(vertices[i], color, PrimitiveType.LineList); //_primitiveBatch.AddVertex(vertices[i + 1], color, PrimitiveType.LineList); } lineListBatch.Add(FDVertex.FromLine(vertices[count - 1], vertices[0], color)); //_primitiveBatch.AddVertex(vertices[count - 1], color, PrimitiveType.LineList); //_primitiveBatch.AddVertex(vertices[0], color, PrimitiveType.LineList); }
public void DrawCircle(FVector2 center, float radius, Color color) { //if (!_primitiveBatch.IsReady()) //{ // throw new InvalidOperationException("BeginCustomDraw must be called before drawing anything."); //} const double increment = Math.PI * 2.0 / CircleSegments; double theta = 0.0; for (int i = 0; i < CircleSegments; i++) { FVector2 v1 = center + radius * new FVector2((float)Math.Cos(theta), (float)Math.Sin(theta)); FVector2 v2 = center + radius * new FVector2((float)Math.Cos(theta + increment), (float)Math.Sin(theta + increment)); lineListBatch.Add(FDVertex.FromLine(v1, v2, color)); //_primitiveBatch.AddVertex(v1, color, PrimitiveType.LineList); //_primitiveBatch.AddVertex(v2, color, PrimitiveType.LineList); theta += increment; } }