Пример #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            //            FLib.FileManager.OpenExplorer("output");

            canvas.AllowDrop = true;

            renderer = new PatchMeshRenderer(canvas.Handle, canvas.ClientSize, true);

            // Magic2Dで作ったセグメントをロードしてパッチに変換
            Dictionary <string, PatchSkeletalMesh> dict;
            Dictionary <string, Bitmap>            bitmaps = new Dictionary <string, Bitmap>();

//            dict = Magic2D.SegmentToPatch.LoadPatches("../../../../..", "Patchwork_resources/GJ_ED3/3_segmentation", bitmaps, 2);
            // dict = Magic2D.SegmentToPatch.LoadPatches(@"C:\Users\furaga\Documents\Research\Patchwork\gj_kirara2", "3_segmentation", bitmaps, 4);
            dict = Magic2D.SegmentToPatch.LoadPatches("./settings", "3_segmentation", bitmaps, 4);

            System.Diagnostics.Debug.Assert(dict.Count == bitmaps.Count);


            // テクスチャをアセットに登録
            foreach (var kv in bitmaps)
            {
                var tex = SharpDXHelper.BitmapToTexture(kv.Value);
                resources.Add(kv.Key, tex);
                tex2bmp[tex] = kv.Value;
            }
            // パッチをキューに入れる
            for (int i = 0; i < dict.Count; i++)
            {
                string            resourceKey = bitmaps.Keys.ElementAt(i);
                string            textureKey  = dict.Keys.ElementAt(i);
                PatchSkeletalMesh patch       = dict.Values.ElementAt(i);
                renderQueryPool[resourceKey] = new RenderQuery(patch, new PatchTree(resourceKey), new List <string>()
                {
                    textureKey
                });
            }


            // パッチをリストに表示する
            foreach (var kv in bitmaps)
            {
                var patch = dict[kv.Key.Split(':')[1]];
                var skl   = patch.CopySkeleton();
                var bmp   = kv.Value;
                var bmp2  = DrawSkeltonOnBmp(skl, bmp);
                patchImageList.Images.Add(kv.Key, bmp2);
                patchView.Items.Add(kv.Key, kv.Key, kv.Key);
            }

            refSkeleton = PatchSkeleton.Load("./settings/refSkeleton.skl");

            canvas.MouseWheel += canvas_MouseWheel;
        }