Beispiel #1
0
        public static PlotlyScene ToPlotly(this Schema2.Mesh mesh)
        {
            var dstScene = new PlotlyScene();

            dstScene.AppendTriangles(mesh.EvaluateTriangles(), GetMaterialColor);
            return(dstScene);
        }
Beispiel #2
0
        public static void AddMesh <TMaterial, TvG, TvM, TvS>(this MeshBuilder <TMaterial, TvG, TvM, TvS> meshBuilder, Mesh srcMesh, Converter <Material, TMaterial> materialFunc)
            where TvG : struct, IVertexGeometry
            where TvM : struct, IVertexMaterial
            where TvS : struct, IVertexSkinning
        {
            Guard.NotNull(meshBuilder, nameof(meshBuilder));
            Guard.NotNull(materialFunc, nameof(materialFunc));

            if (srcMesh == null)
            {
                return;
            }

            var materialMap = srcMesh.Primitives
                              .Select(prim => prim.Material)
                              .Distinct()
                              .ToDictionary(mat => mat, mat => materialFunc(mat));

            Material currMat = null;
            PrimitiveBuilder <TMaterial, TvG, TvM, TvS> currPrim = null;

            foreach (var tri in srcMesh.EvaluateTriangles <TvG, TvM, TvS>())
            {
                if (currMat != tri.Material)
                {
                    currMat  = tri.Material;
                    currPrim = meshBuilder.UsePrimitive(materialMap[currMat]);
                }

                currPrim.AddTriangle(tri.A, tri.B, tri.C);
            }
        }