Beispiel #1
0
 public MMDModel(Vert[] vertex, IEnumerable <Material> material, string path)
 {
     DirPath     = path;
     Vertice     = vertex;
     OrigVertice = new Vert[Vertice.Length];
     Vertice.ArrayFullCopy(OrigVertice);
     Materials     = material.ToList();
     GpuData       = new GPUData( );
     GpuData.Alpha = 1;
     Cast          = new SphereCast(Matrix.Zero);
 }
Beispiel #2
0
        public MMDModel(string path)
        {
            DirPath = Directory.GetParent(path).FullName;
            string[] lines = File.ReadAllLines(path);
            //;Face,親材質名,面Index,頂点Index1,頂点Index2,頂点Index3
            //Face,"スカート腕ヘドフォン",0,858,840,855
            // のように最初の文字列がVertexだと頂点 Faceだと面になる ;が最初に来るものは説明用のものなので弾く
            var gr = lines.GroupBy(l => l.Split(',')[0]);
            var gs = gr.Where(g => !g.Key.Contains(";")).ToDictionary(s => s.Key, g => g.ToList( ));

            Vertice     = ParseCSV(gs["Vertex"]).ToArray( );
            OrigVertice = new Vert[Vertice.Length];
            Vertice.ArrayFullCopy(OrigVertice);
            // 次の文字列は材質名になるので、材質名のグループを作る
            var faceGr = gs["Face"].GroupBy(s => s.Split(',')[1]).ToDictionary(s => s.Key, g => g.ToList( ));

            Materials = Material.MakeFromCSV(gs["Material"], faceGr, Vertice).ToList();

            GpuData       = new GPUData( );
            GpuData.Alpha = 1;
            Cast          = new SphereCast(Matrix.Zero);
        }