Exemplo n.º 1
0
        public PrimitiveData(VertexShaderDesc info, IEnumerable <Vertex> points, EPrimitiveType type)
        {
            _bufferInfo = info;
            _type       = type;
            _influences = null;

            List <Vertex> vertices = points.ToList();
            Remapper      remapper = null;

            switch (_type)
            {
            case EPrimitiveType.Triangles:
                remapper = SetTriangleIndices(vertices);
                break;

            case EPrimitiveType.Lines:
                remapper = SetLineIndices(vertices);
                break;

            default:
                //case EPrimitiveType.Points:
                remapper = SetPointIndices(vertices);
                break;
            }

            int[] firstAppearanceArray = null;
            if (remapper == null)
            {
                firstAppearanceArray = new int[vertices.Count];
                for (int i = 0; i < vertices.Count; ++i)
                {
                    firstAppearanceArray[i] = i;
                }
            }
            else
            {
                firstAppearanceArray = remapper.ImplementationTable;
            }

            CreateFacePoints(firstAppearanceArray.Length);

            if (info.HasSkinning)
            {
                SetInfluences(firstAppearanceArray.Select(x => vertices[x].Influence).ToArray());
            }

            for (int i = 0; i < info.MorphCount + 1; ++i)
            {
                var data = firstAppearanceArray.Select(x => vertices[x].Position).ToList();
                AddBuffer(data, EBufferType.Position);
            }
            if (info.HasNormals)
            {
                for (int i = 0; i < info.MorphCount + 1; ++i)
                {
                    var data = firstAppearanceArray.Select(x => vertices[x].Normal).ToList();
                    AddBuffer(data, EBufferType.Normal);
                }
            }
            if (info.HasBinormals)
            {
                for (int i = 0; i < info.MorphCount + 1; ++i)
                {
                    var data = firstAppearanceArray.Select(x => vertices[x].Binormal).ToList();
                    AddBuffer(data, EBufferType.Binormal);
                }
            }
            if (info.HasTangents)
            {
                for (int i = 0; i < info.MorphCount + 1; ++i)
                {
                    var data = firstAppearanceArray.Select(x => vertices[x].Tangent).ToList();
                    AddBuffer(data, EBufferType.Tangent);
                }
            }
            for (int i = 0; i < info.ColorCount; ++i)
            {
                var data = firstAppearanceArray.Select(x => vertices[x].Color).ToList();
                AddBuffer(data, EBufferType.Color);
            }
            for (int i = 0; i < info.TexcoordCount; ++i)
            {
                var data = firstAppearanceArray.Select(x => vertices[x].TexCoord).ToList();
                AddBuffer(data, EBufferType.TexCoord);
            }
        }
Exemplo n.º 2
0
 public static PrimitiveData FromQuads(VertexShaderDesc info, params VertexQuad[] quads)
 => FromQuadList(info, quads);
Exemplo n.º 3
0
 public static PrimitiveData FromLineList(VertexShaderDesc info, IEnumerable <VertexLine> lines)
 => new PrimitiveData(info, lines.SelectMany(x => x.Vertices), EPrimitiveType.Lines);
Exemplo n.º 4
0
 public static PrimitiveData FromPointList(IEnumerable <Vec3> points)
 => new PrimitiveData(VertexShaderDesc.JustPositions(), points.Select(x => new Vertex(x)), EPrimitiveType.Points);
Exemplo n.º 5
0
 public static PrimitiveData FromLineStripList(VertexShaderDesc info, IEnumerable <VertexLineStrip> lines)
 => FromLineList(info, lines.SelectMany(x => x.ToLines()));
Exemplo n.º 6
0
 public static PrimitiveData FromLines(VertexShaderDesc info, params VertexLine[] lines)
 => FromLineList(info, lines);
Exemplo n.º 7
0
 public static PrimitiveData FromTriangles(VertexShaderDesc info, params VertexTriangle[] triangles)
 => FromTriangleList(info, triangles);
Exemplo n.º 8
0
 public static PrimitiveData FromTriangleList(VertexShaderDesc info, IEnumerable <VertexTriangle> triangles)
 {
     //TODO: convert triangles to tristrips and use primitive restart to render them all in one call
     return(new PrimitiveData(info, triangles.SelectMany(x => x.Vertices), EPrimitiveType.Triangles));
 }
Exemplo n.º 9
0
 public static PrimitiveData FromTriangleFanList(VertexShaderDesc info, IEnumerable <VertexTriangleFan> fans)
 => FromTriangleList(info, fans.SelectMany(x => x.ToTriangles()));
Exemplo n.º 10
0
 public static PrimitiveData FromTriangleFans(VertexShaderDesc info, params VertexTriangleFan[] fans)
 => FromTriangleFanList(info, fans);
Exemplo n.º 11
0
 public static PrimitiveData FromTriangleStripList(VertexShaderDesc info, IEnumerable <VertexTriangleStrip> strips)
 => FromTriangleList(info, strips.SelectMany(x => x.ToTriangles()));
Exemplo n.º 12
0
 public static PrimitiveData FromTriangleStrips(VertexShaderDesc info, params VertexTriangleStrip[] strips)
 => FromTriangleStripList(info, strips);
Exemplo n.º 13
0
 public static PrimitiveData FromQuadList(VertexShaderDesc info, IEnumerable <VertexQuad> quads)
 => FromTriangleList(info, quads.SelectMany(x => x.ToTriangles()));