public static void AddVeins(MyWeightDictionary<MyMwcVoxelMaterialsEnum> secondaryMaterials, Random rnd, Vector3 positionInSector, int veinCount, int voxelAsteroidSize, MyMwcObjectBuilder_VoxelMap builder, float veinAngleDev, int maxLevel, float baseThickness) { MyMwcVoxelMaterialsEnum material = MyMwcVoxelMaterialsEnum.Magnesium_01; if (secondaryMaterials.Count > 0) { material = secondaryMaterials.GetRandomItem(rnd); } for (int i = 0; i < veinCount; i++) { Vector3 position = positionInSector + new Vector3(voxelAsteroidSize / 2); position += rnd.Vector(voxelAsteroidSize / 3); AddVein(builder, baseThickness, position, rnd, material, veinAngleDev, maxLevel); } }
public static void AddVein(MyMwcObjectBuilder_VoxelMap builder, float thickness, Vector3 position, Random rnd, MyMwcVoxelMaterialsEnum material, float veinAngleDev, int maxLevel, int level = 0) { int numSplits = 2;// rnd.Next(2, 4); List<Vector3> targets = new List<Vector3>(numSplits); float handDist = thickness * 1.5f; for (int iSplit = 0; iSplit < numSplits; iSplit++) { // Hands per line int numHands = rnd.Next(8, 12); Vector3 direction = rnd.Direction(); Vector3 target = position; for (int i = 0; i < numHands; i++) { direction = rnd.Direction(direction, veinAngleDev); target += direction * handDist; // TODO: uncomment this to see material better (shown as tunnels, not only as voxel material) //var voxelHand = new MyMwcObjectBuilder_VoxelHand_Sphere(target, thickness - 1, MyMwcVoxelHandModeTypeEnum.SUBTRACT); //voxelHand.VoxelHandMaterial = material; //builder.VoxelHandShapes.Add(voxelHand); var voxelHand2 = new MyMwcObjectBuilder_VoxelHand_Sphere(new MyMwcPositionAndOrientation(target, Vector3.Forward, Vector3.Up), thickness, MyMwcVoxelHandModeTypeEnum.SET_MATERIAL); voxelHand2.VoxelHandMaterial = material; builder.VoxelHandShapes.Add(voxelHand2); } targets.Add(target); } if (level < maxLevel) { foreach (var t in targets) { AddVein(builder, thickness * 0.7f, t, rnd, material, veinAngleDev, maxLevel, level + 1); } } }
public static void AddMergeContent(Random rnd, List<MyMwcVoxelFilesEnum> voxelAsteroids, int voxelAsteroidSize, MyMwcObjectBuilder_VoxelMap builder) { if (voxelAsteroidSize > (int)(64 * MyVoxelConstants.VOXEL_SIZE_IN_METRES)) { int mergeSize = voxelAsteroidSize / 2; int numMerges = rnd.Next(0, 3); //numMerges = 1; for (int i = 0; i < numMerges; i++) { voxelAsteroids.Clear(); MyMwcVoxelMapMergeTypeEnum mergeType; int maxPos = (int)(mergeSize / MyVoxelConstants.VOXEL_SIZE_IN_METRES) / 2; int mergeTypeIndex = rnd.Next(0, 2); //mergeTypeIndex = 0; if (mergeTypeIndex == 0) { mergeType = MyMwcVoxelMapMergeTypeEnum.ADD; MyVoxelMap.GetAsteroidsBySizeInMeters(mergeSize, voxelAsteroids, true); maxPos /= 2; } else { // Subtract merge works with bigger asteroids mergeType = MyMwcVoxelMapMergeTypeEnum.INVERSE_AND_SUBTRACT; MyVoxelMap.GetAsteroidsBySizeInMeters(mergeSize, voxelAsteroids, false); MyVoxelMap.GetAsteroidsBySizeInMeters(mergeSize * 2, voxelAsteroids, false); } int mergeIndex = rnd.Next(0, voxelAsteroids.Count); MyMwcVector3Short offset = new MyMwcVector3Short((short)rnd.Next(0, maxPos), (short)rnd.Next(0, maxPos), (short)rnd.Next(0, maxPos)); builder.MergeContents.Add(new MyMwcObjectBuilder_VoxelMap_MergeContent(offset, voxelAsteroids[mergeIndex], mergeType)); } } }