Exemplo n.º 1
0
        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());
        }
Exemplo n.º 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());
        }
Exemplo n.º 3
0
        public static VertexPositionNormalTexture[] Create(Vector3[] edges, ITextureDefintion textureDefinition)
        {
            var tlb = edges[0];
            var tlf = edges[1];
            var trf = edges[2];
            var trb = edges[3];
            var blb = edges[4];
            var blf = edges[5];
            var brf = edges[6];
            var brb = edges[7];

            var vertices = new List <VertexPositionNormalTexture>();

            var front = RectangleComposer.Create(new[]
            {
                tlf,
                trf,
                blf,
                brf
            }, textureDefinition);

            textureDefinition.NextElement();
            var back = RectangleComposer.Create(new[]
            {
                trb,
                tlb,
                brb,
                blb
            }, textureDefinition);

            textureDefinition.NextElement();
            var left = RectangleComposer.Create(new[]
            {
                tlb,
                tlf,
                blb,
                blf
            }, textureDefinition);

            textureDefinition.NextElement();
            var right = RectangleComposer.Create(new[]
            {
                trb,
                trf,
                brb,
                brf
            }, textureDefinition);

            textureDefinition.NextElement();
            var top = RectangleComposer.Create(new[]
            {
                tlb,
                trb,
                tlf,
                trf
            }, textureDefinition);

            textureDefinition.NextElement();
            var bottom = RectangleComposer.Create(new[]
            {
                blb,
                brb,
                blf,
                brf
            }, textureDefinition);

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

            return(vertices.ToArray());
        }
Exemplo n.º 4
0
        public static VertexPositionNormalTexture[] Create(float width, float height, float depth,
                                                           ITextureDefintion textureDefinition)
        {
            var vertices = new List <VertexPositionNormalTexture>();

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

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

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

            return(vertices.ToArray());
        }