public Import3DModelViewModel(BaseViewModel parentViewModel, Import3DModelModel dataModel, IDialogService dialogService, Func<IOpenFileDialog> openFileDialogFactory) : base(parentViewModel) { Contract.Requires(dialogService != null); Contract.Requires(openFileDialogFactory != null); _dialogService = dialogService; _openFileDialogFactory = openFileDialogFactory; _dataModel = dataModel; // Will bubble property change events from the Model to the ViewModel. _dataModel.PropertyChanged += (sender, e) => OnPropertyChanged(e.PropertyName); IsMultipleScale = true; MultipleScale = 1; MaxLengthScale = 100; ClassType = ImportModelClassType.SmallShip; ArmorType = ImportArmorType.Light; }
public Import3DModelViewModel(BaseViewModel parentViewModel, Import3DModelModel dataModel) : this(parentViewModel, dataModel, ServiceLocator.Resolve<IDialogService>(), ServiceLocator.Resolve<IOpenFileDialog>) { }
public void Test3Executed() { var model = new Import3DModelModel(); var position = ThePlayerCharacter != null ? ThePlayerCharacter.PositionAndOrientation.Value : new MyPositionAndOrientation(Vector3D.Zero, Vector3.Forward, Vector3.Up); model.Load(position); var loadVm = new Import3DModelViewModel(this, model); loadVm.ArmorType = ImportArmorType.Light; loadVm.BuildDistance = 10; loadVm.ClassType = ImportModelClassType.SmallShip; loadVm.Filename = @"D:\Development\SpaceEngineers\building 3D\models\algos.obj"; loadVm.Forward = new BindableVector3DModel(Vector3.Forward); loadVm.IsMaxLengthScale = false; loadVm.IsMultipleScale = true; loadVm.IsValidModel = true; loadVm.MultipleScale = 1; loadVm.Up = new BindableVector3DModel(Vector3.Up); IsBusy = true; var newEntity = loadVm.BuildEntity(); // Split object where X=28|29. ((MyObjectBuilder_CubeGrid)newEntity).CubeBlocks.RemoveAll(c => c.Min.X <= 28); _selectNewStructure = true; _dataModel.CollisionCorrectEntity(newEntity); _dataModel.AddEntity(newEntity); _selectNewStructure = false; IsBusy = false; }
public void ImportModelExecuted() { var model = new Import3DModelModel(); var position = ThePlayerCharacter != null ? ThePlayerCharacter.PositionAndOrientation.Value : new MyPositionAndOrientation(Vector3D.Zero, Vector3.Forward, Vector3.Up); model.Load(position); var loadVm = new Import3DModelViewModel(this, model); var result = _dialogService.ShowDialog<WindowImportModel>(this, loadVm); if (result == true) { IsBusy = true; var newEntity = loadVm.BuildEntity(); if (loadVm.IsValidModel) { _dataModel.CollisionCorrectEntity(newEntity); var structure = _dataModel.AddEntity(newEntity); if (structure is StructureVoxelModel) { ((StructureVoxelModel)structure).SourceVoxelFilepath = loadVm.SourceFile; // Set the temporary file location of the Source Voxel, as it hasn't been written yet. } if (_preSelectedStructure != null) SelectedStructure = _preSelectedStructure; } IsBusy = false; } }
public void Test1Executed() { var model = new Import3DModelModel(); var position = ThePlayerCharacter != null ? ThePlayerCharacter.PositionAndOrientation.Value : new MyPositionAndOrientation(Vector3D.Zero, Vector3.Forward, Vector3.Up); model.Load(position); var loadVm = new Import3DModelViewModel(this, model); IsBusy = true; var newEntity = loadVm.BuildTestEntity(); // Split object where X=28|29. //newEntity.CubeBlocks.RemoveAll(c => c.Min.X <= 3); //newEntity.CubeBlocks.RemoveAll(c => c.Min.X > 4); _selectNewStructure = true; _dataModel.CollisionCorrectEntity(newEntity); _dataModel.AddEntity(newEntity); _selectNewStructure = false; IsBusy = false; }