Exemple #1
0
        public void VoxelGenerateBoxSmallMultiThread()
        {
            SpaceEngineersCore.LoadDefinitions();
            var materials = SpaceEngineersCore.Resources.GetMaterialList();

            Assert.IsTrue(materials.Count > 0, "Materials should exist. Has the developer got Space Engineers installed?");

            var stoneMaterial = materials.FirstOrDefault(m => m.Id.SubtypeId.Contains("Stone_02"));

            Assert.IsNotNull(stoneMaterial, "Stone material should exist.");

            var goldMaterial = materials.FirstOrDefault(m => m.Id.SubtypeId.Contains("Gold"));

            Assert.IsNotNull(goldMaterial, "Gold material should exist.");

            const string fileNew = @".\TestOutput\test_cube_solid_8x8x8_gold.vx2";

            var voxelMap = MyVoxelBuilder.BuildAsteroidCube(true, 8, 8, 8, goldMaterial.Id.SubtypeId, stoneMaterial.Id.SubtypeId, false, 0);

            voxelMap.Save(fileNew);

            var lengthNew = new FileInfo(fileNew).Length;

            Assert.AreEqual(2085, lengthNew, "New file size must match.");

            Assert.AreEqual(64, voxelMap.Size.X, "Voxel Bounding size must match.");
            Assert.AreEqual(64, voxelMap.Size.Y, "Voxel Bounding size must match.");
            Assert.AreEqual(64, voxelMap.Size.Z, "Voxel Bounding size must match.");

            Assert.AreEqual(8, voxelMap.BoundingContent.SizeInt().X + 1, "Voxel Content size must match.");
            Assert.AreEqual(8, voxelMap.BoundingContent.SizeInt().Y + 1, "Voxel Content size must match.");
            Assert.AreEqual(8, voxelMap.BoundingContent.SizeInt().Z + 1, "Voxel Content size must match.");

            // Centered in the middle of 1 and 8.   1234-(4.5)-5678
            Assert.AreEqual(4.5, voxelMap.BoundingContent.Center.X, "Voxel Center must match.");
            Assert.AreEqual(4.5, voxelMap.BoundingContent.Center.Y, "Voxel Center must match.");
            Assert.AreEqual(4.5, voxelMap.BoundingContent.Center.Z, "Voxel Center must match.");
        }
Exemple #2
0
        public void SeedFillVoxelFile()
        {
            SpaceEngineersCore.LoadDefinitions();

            var materials = SpaceEngineersCore.Resources.GetMaterialList();

            Assert.IsTrue(materials.Count > 0, "Materials should exist. Has the developer got Space Engineers installed?");

            var stoneMaterial = materials.FirstOrDefault(m => m.Id.SubtypeId.Contains("Stone_01"));

            Assert.IsNotNull(stoneMaterial, "Stone material should exist.");

            var ironMaterial = materials.FirstOrDefault(m => m.Id.SubtypeId.Contains("Iron_02"));

            Assert.IsNotNull(ironMaterial, "Iron material should exist.");

            var goldMaterial = materials.FirstOrDefault(m => m.Id.SubtypeId.Contains("Gold"));

            Assert.IsNotNull(goldMaterial, "Gold material should exist.");

            var voxelMap = MyVoxelBuilder.BuildAsteroidCube(false, 64, 64, 64, stoneMaterial.Id.SubtypeId, stoneMaterial.Id.SubtypeId, false, 0);
            //var voxelMap = MyVoxelBuilder.BuildAsteroidSphere(true, 64, stoneMaterial.Id.SubtypeId, stoneMaterial.Id.SubtypeId, false, 0);

            var filler         = new AsteroidSeedFiller();
            var fillProperties = new AsteroidSeedFillProperties
            {
                MainMaterial = new SEToolbox.Models.MaterialSelectionModel {
                    Value = stoneMaterial.Id.SubtypeId
                },
                FirstMaterial = new SEToolbox.Models.MaterialSelectionModel {
                    Value = ironMaterial.Id.SubtypeId
                },
                FirstRadius    = 3,
                FirstVeins     = 2,
                SecondMaterial = new SEToolbox.Models.MaterialSelectionModel {
                    Value = goldMaterial.Id.SubtypeId
                },
                SecondRadius = 1,
                SecondVeins  = 1,
            };

            filler.FillAsteroid(voxelMap, fillProperties);

            Assert.AreEqual(128, voxelMap.Size.X, "Voxel Bounding size must match.");
            Assert.AreEqual(128, voxelMap.Size.Y, "Voxel Bounding size must match.");
            Assert.AreEqual(128, voxelMap.Size.Z, "Voxel Bounding size must match.");

            Assert.AreEqual(64, voxelMap.BoundingContent.SizeInt().X + 1, "Voxel Content size must match.");
            Assert.AreEqual(64, voxelMap.BoundingContent.SizeInt().Y + 1, "Voxel Content size must match.");
            Assert.AreEqual(64, voxelMap.BoundingContent.SizeInt().Z + 1, "Voxel Content size must match.");

            var voxCells = voxelMap.SumVoxelCells();

            Assert.AreEqual(66846720, voxCells, "Voxel cells must match.");

            IList <byte>            materialAssets;
            Dictionary <byte, long> materialVoxelCells;

            voxelMap.CalculateMaterialCellAssets(out materialAssets, out materialVoxelCells);

            var stoneAssets = materialAssets.Where(c => c == SpaceEngineersCore.Resources.GetMaterialIndex(stoneMaterial.Id.SubtypeId)).ToList();
            var ironAssets  = materialAssets.Where(c => c == SpaceEngineersCore.Resources.GetMaterialIndex(ironMaterial.Id.SubtypeId)).ToList();
            var goldAssets  = materialAssets.Where(c => c == SpaceEngineersCore.Resources.GetMaterialIndex(goldMaterial.Id.SubtypeId)).ToList();

            var sumAssets = (stoneAssets.Count + ironAssets.Count + goldAssets.Count) * 255;  // A cube should produce full voxcells, so all of them are 255.

            Assert.AreEqual(voxCells, sumAssets, "Assets sum should equal cells");

            // Seeder is too random to provide stable values.
            //Assert.AreEqual(236032, stoneAssets.Count, "Stone assets should equal.");
            //Assert.AreEqual(23040,  ironAssets.Count , "Iron assets should equal.");
            //Assert.AreEqual(3072,  goldAssets.Count, "Gold assets should equal.");

            // Strip the original material.
            //voxelMap.RemoveMaterial(stoneMaterial.Id.SubtypeId, null);
            //const string fileNew = @".\TestOutput\randomSeedMaterialCube.vx2";
            //voxelMap.Save(fileNew);
            //var lengthNew = new FileInfo(fileNew).Length;
        }