public MyProceduralDataView(MyProceduralEnvironmentProvider provider, int lod, ref Vector2I start, ref Vector2I end) { m_provider = provider; Start = start; End = end; Lod = lod; }
public MyProceduralLogicalSector(MyProceduralEnvironmentProvider provider, int x, int y, int localLod, MyObjectBuilder_ProceduralEnvironmentSector moduleData) { Provider = provider; Owner = provider.Owner; X = x; Y = y; Lod = localLod; provider.GeSectorWorldParameters(x, y, localLod * provider.LodFactor, out WorldPos, out BasisX, out BasisY); m_environment = (MyProceduralEnvironmentDefinition)provider.Owner.EnvironmentDefinition; m_seed = provider.GetSeed() ^ ((x * 377 + y) * 377 + Lod); m_itemPositionRng = new MyRandom(m_seed); // Area of the scanning surface: // We know that the norm of the cross product of two vectors is the are of the parallelogram delimited by them. // Since the basis surface is the union of the parallelograms delimited by basis and it's sign permutations // we have that the are is 4 times the norm of the cross product. double area = Vector3.Cross(BasisX, BasisY).Length() * 4; m_itemCountTotal = (int)(area * m_environment.ItemDensity); //if (localLod != 0) m_itemCountTotal = m_itemCountTotal; m_scanHelper = new ProgressiveScanHelper(m_itemCountTotal, localLod * provider.LodFactor); Bounds = Owner.GetBoundingShape(ref WorldPos, ref BasisX, ref BasisY); m_items = new List <ItemInfo>(); m_totalSpawned = 0; UpdateModuleBuilders(moduleData); }
public void InitEnvironment() { EnvironmentDefinition = Planet.Generator.EnvironmentDefinition; PlanetTranslation = Planet.WorldMatrix.Translation; m_InstanceHash = Planet.GetInstanceHash(); double radius = Planet.AverageRadius; double faceSize = radius * Math.Sqrt(2); double faceSize2 = faceSize / 2; double sectorSize = EnvironmentDefinition.SectorSize; // Prepare each clipmap for (int i = 0; i < 6; ++i) { // get forward and up Vector3D forward, up; MyPlanetCubemapHelper.GetForwardUp((Base6Directions.Direction)i, out forward, out up); var translation = forward * faceSize2 + PlanetTranslation; forward = -forward; // prepare matrix MatrixD worldMatrix; MatrixD.CreateWorld(ref translation, ref forward, ref up, out worldMatrix); // Setup origins Vector3D origin = new Vector3D(-faceSize2, -faceSize2, 0); Vector3D.Transform(ref origin, ref worldMatrix, out origin); // Basis vectors Vector3D basisX = new Vector3D(1, 0, 0), basisY = new Vector3D(0, 1, 0); Vector3D.RotateAndScale(ref basisX, ref worldMatrix, out basisX); Vector3D.RotateAndScale(ref basisY, ref worldMatrix, out basisY); // Create and init the clipmap. m_clipmaps[i] = new My2DClipmap<MyPlanetEnvironmentClipmapProxy>(); ActiveClipmap = m_clipmaps[i]; ActiveFace = i; m_clipmaps[i].Init(this, ref worldMatrix, sectorSize, faceSize); ActiveFace = -1; // Prepare the provider for the face var provider = new MyProceduralEnvironmentProvider { ProviderId = i }; provider.Init(this, ref origin, ref basisX, ref basisY, ActiveClipmap.LeafSize, m_providerData[i]); Providers[i] = provider; } }