Created
April 20, 2017 16:52
-
-
Save rms80/67f0a6164b701241f889dcf776530864 to your computer and use it in GitHub Desktop.
func to generate borders of HUDShapes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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