private static MeshDraft Platform(float radius, float baseOffset, int segments, float heignt) { float segmentAngle = 360f / segments; float currentAngle = 0; var lowerRing = new List <Vector3>(segments); var upperRing = new List <Vector3>(segments); for (var i = 0; i < segments; i++) { var lowerPoint = PTUtils.PointOnCircle3XZ(radius + baseOffset, currentAngle); lowerRing.Add(lowerPoint + Vector3.down * heignt); var upperPoint = PTUtils.PointOnCircle3XZ(radius, currentAngle); upperRing.Add(upperPoint); currentAngle -= segmentAngle; } var platform = new MeshDraft { name = "Platform" }; var bottom = MeshDraft.TriangleFan(lowerRing); bottom.Add(MeshDraft.Band(lowerRing, upperRing)); bottom.Paint(new Color(0.5f, 0.5f, 0.5f, 1)); platform.Add(bottom); upperRing.Reverse(); var top = MeshDraft.TriangleFan(upperRing); top.Paint(new Color(0.8f, 0.8f, 0.8f, 1)); platform.Add(top); return(platform); }
public static MeshDraft Platform(float radius, float heignt, int segments = 128) { float segmentAngle = 360f / segments; float currentAngle = 0; var lowerRing = new List <Vector3>(segments); var upperRing = new List <Vector3>(segments); for (var i = 0; i < segments; i++) { var lowerPoint = PTUtils.PointOnCircle3XZ(radius + heignt, currentAngle); lowerRing.Add(lowerPoint + Vector3.down * heignt); var upperPoint = PTUtils.PointOnCircle3XZ(radius, currentAngle); upperRing.Add(upperPoint); currentAngle -= segmentAngle; } var platform = new MeshDraft { name = "Platform" }; platform.Add(new MeshDraft() .AddTriangleFan(lowerRing) .Add(MeshDraft.Band(lowerRing, upperRing)) .Paint(new Color(0.5f, 0.5f, 0.5f, 1))); upperRing.Reverse(); platform.Add(new MeshDraft() .AddTriangleFan(upperRing) .Paint(new Color(0.8f, 0.8f, 0.8f, 1))); return(platform); }