public void DrawSolidCircle(FVector2 center, float radius, FVector2 axis, 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; Color colorFill = color * 0.5f; FVector2 v0 = center + radius * new FVector2((float)Math.Cos(theta), (float)Math.Sin(theta)); theta += increment; for (int i = 1; i < CircleSegments - 1; 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)); triangleListBatch.Add(FDVertex.FromTriangleList(v0, v1, v2, colorFill)); //_primitiveBatch.AddVertex(v0, colorFill, PrimitiveType.TriangleList); //_primitiveBatch.AddVertex(v1, colorFill, PrimitiveType.TriangleList); //_primitiveBatch.AddVertex(v2, colorFill, PrimitiveType.TriangleList); theta += increment; } DrawCircle(center, radius, color); DrawSegment(center, center + axis * radius, color); }
public void DrawSolidPolygon(FVector2[] vertices, int count, Color color, bool outline) { //if (!_primitiveBatch.IsReady()) //{ // throw new InvalidOperationException("BeginCustomDraw must be called before drawing anything."); //} if (count == 2) { DrawPolygon(vertices, count, color); return; } Color colorFill = color * (outline ? 0.5f : 1.0f); for (int i = 1; i < count - 1; i++) { triangleListBatch.Add(FDVertex.FromTriangleList(vertices[0], vertices[i], vertices[i + 1], colorFill)); //_primitiveBatch.AddVertex(vertices[0], colorFill, PrimitiveType.TriangleList); //_primitiveBatch.AddVertex(vertices[i], colorFill, PrimitiveType.TriangleList); //_primitiveBatch.AddVertex(vertices[i + 1], colorFill, PrimitiveType.TriangleList); } if (outline) { DrawPolygon(vertices, count, color); } }
public static FDVertex FromLine(FVector2 begin, FVector2 end, Color color) { FDVertex fv = new FDVertex(); fv.Position = new Vector3[2]; fv.Position[0] = FSHelper.FVector2ToVector3(begin); fv.Position[1] = FSHelper.FVector2ToVector3(end); fv.Color = color; return(fv); }
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 static FDVertex FromTriangleList(FVector2 p0, FVector2 p1, FVector2 p2, Color color) { FDVertex fv = new FDVertex(); fv.Position = new Vector3[3]; fv.Position[0] = FSHelper.FVector2ToVector3(p0); fv.Position[1] = FSHelper.FVector2ToVector3(p1); fv.Position[2] = FSHelper.FVector2ToVector3(p2); fv.Color = color; return(fv); }
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; } }