public void AddRowExecuted()
        {
            if (SelectedRow != null)
            {
                VoxelCollection.Insert(VoxelCollection.IndexOf(SelectedRow) + 1, (AsteroidByteFillProperties)SelectedRow.Clone());
            }
            else
            {
                VoxelCollection.Add(_dataModel.NewDefaultVoxel(VoxelCollection.Count + 1));
            }

            _dataModel.RenumberCollection();
        }
        public void DeleteRowExecuted()
        {
            var index = VoxelCollection.IndexOf(SelectedRow);

            VoxelCollection.Remove(SelectedRow);
            _dataModel.RenumberCollection();

            while (index >= VoxelCollection.Count)
            {
                index--;
            }
            if (index >= 0)
            {
                SelectedRow = VoxelCollection[index];
            }
        }
        public void AddRandomRowExecuted()
        {
            var filler      = new AsteroidByteFiller();
            var randomModel = (AsteroidByteFillProperties)filler.CreateRandom(VoxelCollection.Count + 1, _dataModel.BaseMaterial, MaterialsCollection, VoxelFileList);

            if (SelectedRow != null)
            {
                VoxelCollection.Insert(VoxelCollection.IndexOf(SelectedRow) + 1, randomModel);
            }
            else
            {
                VoxelCollection.Add(randomModel);
            }

            _dataModel.RenumberCollection();
        }
        public void Load(MyPositionAndOrientation characterPosition)
        {
            if (!_isInitialValueSet)
            {
                // only set the position first time opened and cache.
                CenterPositionX    = characterPosition.Position.X;
                CenterPositionY    = characterPosition.Position.Y;
                CenterPositionZ    = characterPosition.Position.Z;
                AsteroidFillType   = AsteroidFillType.ByteFiller;
                _isInitialValueSet = true;
            }

            MaterialsCollection.Clear();
            foreach (var material in SpaceEngineersCore.Resources.VoxelMaterialDefinitions)
            {
                MaterialsCollection.Add(new MaterialSelectionModel {
                    Value = material.Id.SubtypeName, DisplayName = material.Id.SubtypeName, IsRare = material.IsRare, MinedRatio = material.MinedOreRatio
                });
            }

            BaseMaterial = MaterialsCollection.FirstOrDefault(m => m.IsRare == false) ?? MaterialsCollection.FirstOrDefault();

            // Voxel Map Storage, includes stock and mod asteroids.
            var vms         = SpaceEngineersCore.Resources.VoxelMapStorageDefinitions;
            var contentPath = ToolboxUpdater.GetApplicationContentPath();
            var list        = new List <GenerateVoxelDetailModel>();

            foreach (var voxelMap in vms)
            {
                var fileName = SpaceEngineersCore.GetDataPathOrDefault(voxelMap.StorageFile, Path.Combine(contentPath, voxelMap.StorageFile));

                if (!File.Exists(fileName))
                {
                    continue;
                }

                var voxel = new GenerateVoxelDetailModel
                {
                    Name           = Path.GetFileNameWithoutExtension(voxelMap.StorageFile),
                    SourceFilename = fileName,
                    FileSize       = new FileInfo(fileName).Length,
                    Size           = MyVoxelMap.LoadVoxelSize(fileName)
                };
                list.Add(voxel);
            }

            // Custom voxel files directory.
            List <string> files = new List <string>();

            if (!string.IsNullOrEmpty(GlobalSettings.Default.CustomVoxelPath) && Directory.Exists(GlobalSettings.Default.CustomVoxelPath))
            {
                files.AddRange(Directory.GetFiles(GlobalSettings.Default.CustomVoxelPath, "*" + MyVoxelMap.V1FileExtension));
                files.AddRange(Directory.GetFiles(GlobalSettings.Default.CustomVoxelPath, "*" + MyVoxelMap.V2FileExtension));
            }

            list.AddRange(files.Select(file => new GenerateVoxelDetailModel
            {
                Name           = Path.GetFileNameWithoutExtension(file),
                SourceFilename = file,
                FileSize       = new FileInfo(file).Length,
                Size           = MyVoxelMap.LoadVoxelSize(file)
            }));

            VoxelFileList = new ObservableCollection <GenerateVoxelDetailModel>(list.OrderBy(s => s.Name));

            // Set up a default start.
            if (VoxelStore.Count == 0)
            {
                VoxelCollection.Add(NewDefaultVoxel(1));
            }
            else
            {
                foreach (var item in VoxelStore)
                {
                    var v1 = (AsteroidByteFillProperties)item.Clone();
                    v1.VoxelFile       = VoxelFileList.FirstOrDefault(v => v.Name == v1.VoxelFile.Name);
                    v1.MainMaterial    = MaterialsCollection.FirstOrDefault(v => v.DisplayName == v1.MainMaterial.DisplayName);
                    v1.SecondMaterial  = MaterialsCollection.FirstOrDefault(v => v.DisplayName == v1.SecondMaterial.DisplayName);
                    v1.ThirdMaterial   = MaterialsCollection.FirstOrDefault(v => v.DisplayName == v1.ThirdMaterial.DisplayName);
                    v1.FourthMaterial  = MaterialsCollection.FirstOrDefault(v => v.DisplayName == v1.FourthMaterial.DisplayName);
                    v1.FifthMaterial   = MaterialsCollection.FirstOrDefault(v => v.DisplayName == v1.FifthMaterial.DisplayName);
                    v1.SixthMaterial   = MaterialsCollection.FirstOrDefault(v => v.DisplayName == v1.SixthMaterial.DisplayName);
                    v1.SeventhMaterial = MaterialsCollection.FirstOrDefault(v => v.DisplayName == v1.SeventhMaterial.DisplayName);
                    VoxelCollection.Add(v1);
                }
                RenumberCollection();
            }

            for (var i = 0; i < 100; i++)
            {
                PercentList.Add(i);
            }
        }
        public bool CreateCanExecute()
        {
            var valid = VoxelCollection.Count > 0;

            return(VoxelCollection.Aggregate(valid, (current, t) => current));
        }
 public void ClearRowsExecuted()
 {
     VoxelCollection.Clear();
     MinimumRange = 400;
     MaximumRange = 800;
 }
Example #7
0
        public VertexArray Voxelize(VoxelCollection collection, VoxelChunk chunk)
        {
            List <float> verts = new List <float>();

            return(null);
        }
        public VertexArray Voxelize(VoxelCollection collection, VoxelChunk chunk)
        {
            List<float> verts = new List<float>();

            return null;
        }