Exemplo n.º 1
0
        private (PrimitiveTopology, IEnumerable <int>) TransformPrimitive(MeshPrimitive primitive)
        {
            switch (primitive.DrawPrimitiveType)
            {
            case PrimitiveType.TRIANGLES:
                return(PrimitiveTopology.TriangleList,
                       primitive.GetTriangleIndices().SelectMany(_ => new[] { _.Item1, _.Item2, _.Item3 }));

            case PrimitiveType.TRIANGLE_STRIP:
                return(PrimitiveTopology.TriangleList,
                       primitive.GetTriangleIndices().SelectMany(_ => new[] { _.Item1, _.Item2, _.Item3 }));

            case PrimitiveType.TRIANGLE_FAN:
                return(PrimitiveTopology.TriangleList,
                       primitive.GetTriangleIndices().SelectMany(_ => new[] { _.Item1, _.Item2, _.Item3 }));

            case PrimitiveType.POINTS:
                return(PrimitiveTopology.PointList, primitive.GetPointIndices());

            case PrimitiveType.LINES:
                return(PrimitiveTopology.LineList,
                       primitive.GetLineIndices().SelectMany(_ => new[] { _.Item1, _.Item2 }));

            case PrimitiveType.LINE_STRIP:
                return(PrimitiveTopology.LineList,
                       primitive.GetLineIndices().SelectMany(_ => new[] { _.Item1, _.Item2 }));

            case PrimitiveType.LINE_LOOP:
                return(PrimitiveTopology.LineList,
                       primitive.GetLineIndices().SelectMany(_ => new[] { _.Item1, _.Item2 }));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }