public static VertexPositionNormalTexture[] Create(float radius, float height, int edgeCount, ITextureDefintion textureDefinition) { var edgePoints = CircleComposer.GetEdgePoints(radius, edgeCount); var vertices = new List <VertexPositionNormalTexture>(); var halfHeight = height / 2f; for (int i = 0; i < edgeCount; i++) { var edgePoint = edgePoints[i]; var nextEdgePoint = edgePoints[0]; if (i != edgeCount - 1) { nextEdgePoint = edgePoints[i + 1]; } vertices.AddRange(RectangleComposer.Create(new[] { new Vector3(-halfHeight, edgePoint.X, edgePoint.Y), new Vector3(halfHeight, edgePoint.X, edgePoint.Y), new Vector3(-halfHeight, nextEdgePoint.X, nextEdgePoint.Y), new Vector3(halfHeight, nextEdgePoint.X, nextEdgePoint.Y), }, textureDefinition)); textureDefinition.NextElement(); } return(vertices.ToArray()); }
public static VertexPositionNormalTexture[] Create(float radius, float height, int edgeCount, int levels, params ITextureDefintion[] textureDefinitions) { var levelHeight = height / levels; var halfHeight = levelHeight / 2f; var vertices = new List <VertexPositionNormalTexture>(); for (int level = 0; level < levels; level++) { var levelRadius = (float)Math.Sqrt(1f - (float)level / levels) * radius; var levelRadiusUp = (float)Math.Sqrt(1f - (float)(level + 1) / levels) * radius; var edgePoints = CircleComposer.GetEdgePoints(levelRadius, edgeCount); var edgePointsUp = CircleComposer.GetEdgePoints(levelRadiusUp, edgeCount); var textureDefinition = textureDefinitions[level]; for (int i = 0; i < edgeCount; i++) { var edgePoint = edgePoints[i]; var nextEdgePoint = edgePoints[0]; var edgePointUp = edgePointsUp[i]; var nextEdgePointUp = edgePointsUp[0]; if (i != edgeCount - 1) { nextEdgePoint = edgePoints[i + 1]; nextEdgePointUp = edgePointsUp[i + 1]; } var levelHeightPos = levelHeight * level; vertices.AddRange(RectangleComposer.Create(new[] { new Vector3(levelHeightPos - halfHeight, edgePoint.X, edgePoint.Y), new Vector3(levelHeightPos + halfHeight, edgePointUp.X, edgePointUp.Y), new Vector3(levelHeightPos - halfHeight, nextEdgePoint.X, nextEdgePoint.Y), new Vector3(levelHeightPos + halfHeight, nextEdgePointUp.X, nextEdgePointUp.Y), }, textureDefinition)); textureDefinition.NextElement(); } } return(vertices.ToArray()); }