예제 #1
0
        public MeshTreeViewModel()
        {
            RootLevel = new ObservableCollection <MeshViewModel>();
            MeshList  = new ObservableCollection <MeshViewModel>();


            Scene = new OGLScene();

            AddMeshCommand    = new DelegateCommand(AddMesh);
            RemoveMeshCommand = new DelegateCommand <MeshViewModel>(RemoveMesh);
        }
예제 #2
0
        public MeshTreeViewModel(MeshCollection meshList)
        {
            _meshList = meshList;
            MeshList  = new ObservableCollection <MeshViewModel>();
            RootLevel = new ObservableCollection <MeshViewModel>();


            AddMeshCommand    = new DelegateCommand(AddMesh);
            RemoveMeshCommand = new DelegateCommand <MeshViewModel>(RemoveMesh);

            // Instantiate meshes
            foreach (Mesh mesh in _meshList.meshes)
            {
                MeshViewModel mv = new MeshViewModel(mesh);
                MeshList.Add(mv);
                mv.PropertyChanged += new PropertyChangedEventHandler(Mesh_PropertyChanged);
            }


            // Linking Tree
            foreach (MeshViewModel mv in MeshList)
            {
                mv.Model.LinkToParent(_meshList.meshes);
                MeshViewModel parent = MeshList.FirstOrDefault(x => (x.Model == mv.Model.parent));
                mv.Parent = parent;
                if (mv.Parent != null)
                {
                    if (!parent.Children.Contains(mv))
                    {
                        parent.Children.Add(mv);
                    }
                }
                mv.PropertyChanged += Mv_PropertyChanged;
            }

            // Create Scene
            Scene = new OGLScene(_meshList.meshes);
        }