public MyCompositeLayeredOreDeposit(MyCsgShapeBase shape, MyMaterialLayer[] materialLayers, IMyModule noise, MyCompositeOrePlanetDeposit oresDeposits) :
     base(shape, null)
 {
     m_materialLayers = materialLayers;
     m_noise          = noise;
     m_oreDeposits    = oresDeposits;
 }
        public MyCompositeOrePlanetDeposit(MyCsgShapeBase baseShape, int seed, float minDepth, float maxDepth, MyOreProbability[] oreProbabilties, MyVoxelMaterialDefinition material) :
            base(baseShape, material)
        {
            m_minDepth = minDepth;
            double outherSphereVolume = (4.0 * MathHelper.Pi * Math.Pow(minDepth, 3.0f)) / 3.0;
            double innerSphereVolume  = (4.0 * MathHelper.Pi * Math.Pow(maxDepth, 3.0f)) / 3.0;

            double depositVolume = (4.0 * MathHelper.Pi * Math.Pow(DEPOSIT_MAX_SIZE, 3.0f)) / 3.0;
            double volume        = outherSphereVolume - innerSphereVolume;

            m_numDeposits = oreProbabilties.Length > 0 ? (int)Math.Floor((volume * 0.4f) / depositVolume) : 0;

            int numSectors = (int)(minDepth / DEPOSIT_MAX_SIZE);

            MyRandom random = MyRandom.Instance;

            FillMaterialCollections();
            Vector3D offset = -new Vector3D(DEPOSIT_MAX_SIZE / 2.0);

            using (var stateToken = random.PushSeed(seed))
            {
                for (int i = 0; i < m_numDeposits; ++i)
                {
                    Vector3D direction          = MyProceduralWorldGenerator.GetRandomDirection(random);
                    float    distanceFromCenter = random.NextFloat(maxDepth, minDepth);
                    Vector3D position           = direction * distanceFromCenter;

                    Vector3I cellPos = Vector3I.Ceiling((Shape.Center() + position) / DEPOSIT_MAX_SIZE);

                    MyCompositeShapeOreDeposit deposit;
                    if (m_deposits.TryGetValue(cellPos, out deposit) == false)
                    {
                        var oreDefinition      = GetOre(random.NextFloat(0, 1), oreProbabilties);
                        var materialDefinition = m_materialsByOreType[oreDefinition.OreName][random.Next() % m_materialsByOreType[oreDefinition.OreName].Count];
                        deposit             = new MyCompositeShapeOreDeposit(new MyCsgSimpleSphere(cellPos * DEPOSIT_MAX_SIZE + offset, random.NextFloat(64, DEPOSIT_MAX_SIZE / 2.0f)), materialDefinition);
                        m_deposits[cellPos] = deposit;
                    }
                }
            }

            m_materialsByOreType.Clear();
        }
示例#3
0
        public MyCompositePrecomputedOreDeposit(MyCsgShapeBase shape, string path, MyCompositeOrePlanetDeposit oresDeposits, MyCsgShapePrecomputed planetShape) :
            base(shape, null)
        {
            m_planetShape = planetShape;
            m_oreDeposits = oresDeposits;
            m_file        = new MemoryMappedFile[MyCsgPrecomputedHelpres.NUM_MAPS];
            m_reader      = new MemoryMappedViewAccessor[MyCsgPrecomputedHelpres.NUM_MAPS];

            for (int i = 0; i < MyCsgPrecomputedHelpres.NUM_MAPS; ++i)
            {
                string name = null;
                MyCsgPrecomputedHelpres.GetNameForFace(i, ref name);

                name = Path.Combine(path, name + "_material.bin");
                FileInfo fi     = new FileInfo(name);
                int      length = (int)fi.Length;
                m_file[i]   = MemoryMappedFile.CreateFromFile(name, FileMode.Open);
                m_reader[i] = m_file[i].CreateViewAccessor(0, length);
                m_reader[i].Read(0, out m_resolution);
            }
        }
示例#4
0
 public MyBoxOreDeposit(MyCsgShapeBase baseShape, MyVoxelMaterialDefinition material) :
     base(baseShape, material)
 {
     m_boxShape = (MyCsgBox)baseShape;
 }
 public MyCompositeShapeOreDeposit(MyCsgShapeBase shape, MyVoxelMaterialDefinition material)
 {
     System.Diagnostics.Debug.Assert(material != null, "Shape must have material");
     Shape      = shape;
     m_material = material;
 }
示例#6
0
 public MyCompositeShapeOreDeposit(MyCsgShapeBase shape, MyVoxelMaterialDefinition material)
 {
     Shape      = shape;
     m_material = material;
 }
示例#7
0
 public MyCompositeLayeredOreDeposit(MyCsgShapeBase shape, MyMaterialLayer[] materialLayers, IMyModule noise) :
     base(shape, null)
 {
     m_materialLayers = materialLayers;
     m_noise          = noise;
 }