Skip to content

Instantly share code, notes, and snippets.

@rms80
Created April 20, 2017 16:52
Show Gist options
  • Save rms80/67f0a6164b701241f889dcf776530864 to your computer and use it in GitHub Desktop.
Save rms80/67f0a6164b701241f889dcf776530864 to your computer and use it in GitHub Desktop.
func to generate borders of HUDShapes
public static fCurveGameObject MakeBackgroundMeshBorder(HUDShape Shape, float LineWidth, Colorf LineColor)
{
if (Shape.Type == HUDShapeType.Disc) {
fCircleGameObject go = GameObjectFactory.CreateCircleGO("border", Shape.Radius, LineColor, LineWidth);
go.SetSteps(Shape.Slices);
return go;
} else if (Shape.Type == HUDShapeType.Rectangle) {
List<Vector3f> Vertices = new List<Vector3f>() {
new Vector3f(-Shape.Width / 2, 0, -Shape.Height / 2),
new Vector3f(Shape.Width / 2, 0, -Shape.Height / 2),
new Vector3f(Shape.Width / 2, 0, Shape.Height / 2),
new Vector3f(-Shape.Width / 2, 0, Shape.Height / 2) };
fPolylineGameObject go = GameObjectFactory.CreatePolylineGO("bordeR", Vertices, LineColor, LineWidth);
return go;
} else if (Shape.Type == HUDShapeType.RoundRect) {
RoundRectGenerator rectgen = new RoundRectGenerator();
rectgen.Width = Shape.Width; rectgen.Height = Shape.Height;
rectgen.Radius = Shape.Radius;
rectgen.CornerSteps = Shape.Slices;
rectgen.SharpCorners = (RoundRectGenerator.Corner)Shape.RoundRectSharpCorners;
Vector3d[] verts = rectgen.GetBorderLoop();
List<Vector3f> Vertices = new List<Vector3f>();
for (int i = 0; i < verts.Length; ++i)
Vertices.Add((Vector3f)verts[i]);
fPolylineGameObject go = GameObjectFactory.CreatePolylineGO("bordeR", Vertices, LineColor, LineWidth);
return go;
} else {
throw new Exception("HUDUtil.MakeBackgroundMesh: unknown shape type!");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment