Exemple #1
0
            async Task Load(string path)
            {
                if (string.IsNullOrEmpty(path))
                {
                    return;
                }

                Console.WriteLine($"{Thread.CurrentThread.ManagedThreadId} open: {path}");
                var source = await Task.Run(() => AssetSource.Load(path));

                Console.WriteLine($"{Thread.CurrentThread.ManagedThreadId} loaded: {source}");
                var asset = await Task.Run(() => AssetContext.Load(source));

                Console.WriteLine($"{Thread.CurrentThread.ManagedThreadId} build: {source}");
                m_app.SetAsset(asset);
            }
Exemple #2
0
        public Form1()
        {
            InitializeComponent();

            var scene = new Scene();
            var view0 = new DrawableView(new SceneCameraView(scene))
            {
                ClearColor = new Color4(0.4f, 0.2f, 0.2f, 1)
            };
            var view1 = new D2DView()
            {
                ClearColor = new Color4(0.2f, 0.4f, 0.2f, 1)
            };
            var splitter = new VerticalSplitter(view0, view1);

            _disposable.Add(splitter);

            // setup docks
            var hierarchy = new SceneHierarchyContent(node =>
            {
                Logger.Debug("Selected: {0}", node.Name);
                scene.Selected = node;
            });

            AddContent("scene hierarchy", hierarchy, DockState.DockRight);

            var selected = new SelectedNodeContent(scene.SelectedObservable);

            AddContent("selected node", selected, DockState.DockRight);
            selected.DockTo(hierarchy.Pane, DockStyle.Bottom, 1);

            var d3d = new D3DContent(splitter);

            _disposable.Add(d3d);
            AddContent("selected", d3d, DockState.Document);

            var json = new JsonContent();

            AddContent("json", json, DockState.DockLeft);

            var jsonNode = new JsonNodeContent();

            AddContent("jsonnode", jsonNode, DockState.DockLeft);
            jsonNode.Selected.Subscribe(x =>
            {
                if (x.IsValid)
                {
                    var p = x.Pointer();
                    toolStripStatusLabel1.Text = $"{p}";
                }
                else
                {
                    toolStripStatusLabel1.Text = "";
                }
            });

            // setup scene
            _loader.SourceObservableOnCurrent.Subscribe(async source =>
            {
                json.SetAssetSource(source);
                jsonNode.SetAssetSource(source);

                //LoadAsset(x);
                if (source.GLTF == null)
                {
                    this.Text = "";
                    return;
                }

                var path  = Path.GetFileName(source.Path);
                this.Text = $"[{path}] {source.GLTF.TriangleCount} tris";
                var asset = await Task.Run(() => AssetContext.Load(source));

                // update treeview
                hierarchy.SetTreeNode(asset);

                // update scene
                scene.Asset = asset;
            });
            scene.Updated
            .ObserveOn(SynchronizationContext.Current)
            .Subscribe(_ =>
            {
                d3d.Invalidate();
            })
            ;
        }