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());
        }
Exemple #2
0
        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());
        }
Exemple #3
0
        public static VertexPositionNormalTexture[] Create(float radius, float height, int edgeCount,
                                                           ITextureDefintion sideTexture, ITextureDefintion endTexture1, ITextureDefintion endTexture2)
        {
            var vertices = new List <VertexPositionNormalTexture>();

            var sides = TubeComposer.Create(radius, height, edgeCount, sideTexture);
            var end1  = CircleComposer.Create(radius, edgeCount, endTexture1);
            var end2  = CircleComposer.Create(radius, edgeCount, endTexture2);

            VertexTransformer.Rotate(end1, new Vector3(0, 0, -MathHelper.PiOver2));
            VertexTransformer.Offset(end1, new Vector3(height / 2f, 0, 0));
            VertexTransformer.Rotate(end2, new Vector3(0, 0, MathHelper.PiOver2));
            VertexTransformer.Offset(end2, new Vector3(-height / 2f, 0, 0));

            vertices.AddRange(sides);
            vertices.AddRange(end1);
            vertices.AddRange(end2);

            return(vertices.ToArray());
        }