Esempio n. 1
0
        public static VertexInput[] Create(float radius, float height, int edgeCount, IGeometryTextureDefintion textureDefinition)
        {
            var edgePoints = CircleComposer.GetEdgePoints(radius, edgeCount);
            var vertices   = new List <VertexInput>();
            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());
        }
Esempio n. 2
0
        public static VertexInput[] Create(float radius, float height, int edgeCount,
                                           IGeometryTextureDefintion sideTexture, IGeometryTextureDefintion endTexture)
        {
            var vertices = new List <VertexInput>();

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

            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());
        }