예제 #1
0
        //--------------------------------------------------------------------
        //
        //--------------------------------------------------------------------

        void AddQuery(string resourceKey)
        {
            if (renderQueryPool.ContainsKey(resourceKey))
            {
                Console.WriteLine("D&D: " + resourceKey);
                var _q = renderQueryPool[resourceKey];
                var q  = new RenderQuery(PatchSkeletalMesh.Copy(_q.patch), _q.patchTree, _q.patchKeys);
                resources.DuplicateResources(_q.patch.Mesh, q.patch.Mesh);

                // 初めて登録される場合、ARAP変形を有効にしてスケルトにフィットさせる
                if (!renderQueries.Contains(q))
                {
                    q.patch.Mesh.BeginDeformation();
                    PatchSkeletonFitting.Fitting(q.patch, refSkeleton);
                }

                if (renderQueries.Contains(q))
                {
                    renderQueries.Remove(q);
                }
                renderQueries.Add(q);

                // 追加したパッチを選択モードにする
                selectingQueries.Add(q);

                UpdateConnectablePatchView(renderQueryPool, selectingQueries, refSkeleton);
            }
        }
예제 #2
0
        //Render an image
        public async Task <Stream> RenderAsync(string sceneId, string query, string options)
        {
            RenderQuery    renderQuery = JsonConvert.DeserializeObject <RenderQuery>(query);
            CommandOptions option      = JsonConvert.DeserializeObject <CommandOptions>(options);

            string requestUrl = sceneId + "/render";

            if (option.command == null)
            {
                renderQuery.setupCommand = "";
            }
            else
            {
                renderQuery.setupCommand = option.command;
            }

            renderQuery.data = option.data;

            var    jsonSerializer = new Method.NewtonsoftJsonSerializer();
            string json           = jsonSerializer.Serialize(renderQuery);

            StringContent content = new StringContent(json, Encoding.UTF8, "application/json");

            Task <HttpResponseMessage> getResponse = method.RequestAsync("post", requestUrl, content, true);

            HttpResponseMessage resp = await getResponse;

            return(await resp.Content.ReadAsStreamAsync());
        }
예제 #3
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;
        }