Exemple #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());
        }
Exemple #2
0
        public static VertexInput[] Create(float width, float height, float depth,
                                           IGeometryTextureDefintion textureDefinition)
        {
            var vertices = new List <VertexInput>();

            var halfWidth  = width / 2f;
            var halfHeight = height / 2f;
            var halfDepth  = depth / 2f;
            var front      = RectangleComposer.Create(new[]
            {
                new Vector3(-halfWidth, halfHeight, -halfDepth),
                new Vector3(halfWidth, halfHeight, -halfDepth),
                new Vector3(-halfWidth, -halfHeight, -halfDepth),
                new Vector3(halfWidth, -halfHeight, -halfDepth),
            }, textureDefinition);

            textureDefinition.NextElement();

            var back = RectangleComposer.Create(new[]
            {
                new Vector3(-halfWidth, halfHeight, halfDepth),
                new Vector3(halfWidth, halfHeight, halfDepth),
                new Vector3(-halfWidth, -halfHeight, halfDepth),
                new Vector3(halfWidth, -halfHeight, halfDepth),
            }, textureDefinition);

            textureDefinition.NextElement();

            var left = RectangleComposer.Create(new[]
            {
                new Vector3(-halfWidth, halfHeight, -halfDepth),
                new Vector3(-halfWidth, halfHeight, halfDepth),
                new Vector3(-halfWidth, -halfHeight, -halfDepth),
                new Vector3(-halfWidth, -halfHeight, halfDepth),
            }, textureDefinition);

            textureDefinition.NextElement();

            var right = RectangleComposer.Create(new[]
            {
                new Vector3(halfWidth, halfHeight, -halfDepth),
                new Vector3(halfWidth, halfHeight, halfDepth),
                new Vector3(halfWidth, -halfHeight, -halfDepth),
                new Vector3(halfWidth, -halfHeight, halfDepth),
            }, textureDefinition);

            textureDefinition.NextElement();

            var top = RectangleComposer.Create(new[]
            {
                new Vector3(-halfWidth, halfHeight, halfDepth),
                new Vector3(halfWidth, halfHeight, halfDepth),
                new Vector3(-halfWidth, halfHeight, -halfDepth),
                new Vector3(halfWidth, halfHeight, -halfDepth),
            }, textureDefinition);

            textureDefinition.NextElement();

            var bottom = RectangleComposer.Create(new[]
            {
                new Vector3(-halfWidth, -halfHeight, -halfDepth),
                new Vector3(halfWidth, -halfHeight, -halfDepth),
                new Vector3(-halfWidth, -halfHeight, halfDepth),
                new Vector3(halfWidth, -halfHeight, halfDepth),
            }, textureDefinition);

            vertices.AddRange(front);
            vertices.AddRange(back);
            vertices.AddRange(right);
            vertices.AddRange(left);
            vertices.AddRange(top);
            vertices.AddRange(bottom);

            return(vertices.ToArray());
        }