public new void Awake() { m_supportRayMask = LayerMask.GetMask("Default", "static_solid", "Default_small", "piece"); Heightmap.GetHeight(transform.position, out highestFloor); m_body = GetComponent <Rigidbody>(); InvokeRepeating("UpdateHeightMap", 10f, 10f); }
private bool IsCorrectBiome(Vector3 p, Heightmap.Biome biome) { Heightmap heightmap = Heightmap.FindHeightmap(p); return(heightmap && (heightmap.GetBiome(p) & biome) != 0); }
private Heightmap CombineAll() { if (_items.Count == 0) { return(new Heightmap(2, 2)); } var result = new Heightmap(_items[0].HeightmapModified.Width, _items[0].HeightmapModified.Height); foreach (var heightmap in _items) { if (!heightmap.IsVisible) { continue; } if (heightmap.CurrentMode == HeightmapBrowserItem.Mode.Add) { result.Add(heightmap.HeightmapModified); } else { result.Substract(heightmap.HeightmapModified); } } return(result); }
private void Generate() { heightmaps = new Heightmap[heightmapsParameters.Length]; for(int i = 0 ; i < heightmapsParameters.Length ; i++){ switch(heightmapsParameters[i].GetType()) { case HeightmapType.NONE: heightmapsParameters[i].SetHeightParams(); heightmaps[i] = new Heightmap(heightmapsParameters[i].GetHeightParams()); break; case HeightmapType.PANGEA: heightmapsParameters[i].SetHeightParams(); heightmaps[i] = new HM_Pangea(heightmapsParameters[i].GetHeightParams()); break; case HeightmapType.MOUNTAINS: heightmapsParameters[i].SetHeightParams(); heightmaps[i] = new HM_Mountains(heightmapsParameters[i].GetHeightParams(), heightmaps[0]); break; } } heightmap = heightmaps[0].GetFloatMap(); //heightmap = SumHeighMaps(heightmaps[0], heightmaps[1]); }
static private DepthSlice MakeBaseDepthSlice(Heightmap heightmap) { RawDepthData rawDepthData = GetRawDepthData(heightmap, 0, heightmap.StartX - 1, heightmap.Width + 2); // <- Guarantuee missing ranges on each end (for extrapolation) if (rawDepthData.IsBlank) { return(DepthSlice.CreateBlank(heightmap.StartX, heightmap.StartZ)); } // Fill in missing data and do extrapolation: rawDepthData.RepairMissingRanges(); int dataStart = rawDepthData.missingDataRanges[0].index + rawDepthData.missingDataRanges[0].count; int dataEnd = rawDepthData.missingDataRanges[rawDepthData.missingDataRanges.Count - 1].index; // Bring extrapolations into the legitimate data range: if (rawDepthData.depthFront[dataStart - 1] == rawDepthData.depthBack[dataStart - 1]) { dataStart--; } if (rawDepthData.depthFront[dataEnd] == rawDepthData.depthBack[dataEnd]) { dataEnd++; } return(PackDepthSlice(ref rawDepthData, dataStart, dataEnd)); }
internal static bool DebugToggle(out int count) { count = 0; if (EnvMan.instance != null) { debugTerrain = !debugTerrain; foreach (TerrainModifier mod in TerrainModifier.GetAllInstances().Where(x => x != null && x.m_playerModifiction)) { Light light = SetupLight(mod); count++; } EnvMan.instance.m_dirLight.enabled = !debugTerrain; foreach (Heightmap map in Heightmap.GetAllHeightmaps().Where(x => x != null)) { Material mat = m_materialInstance(map); if (mat != null) { if (debugTerrain) { mat.SetTexture("_DiffuseTex0", Texture2D.whiteTexture); } else { mat.SetTexture("_DiffuseTex0", map.m_material.GetTexture("_DiffuseTex0")); } } } return(true); } else { return(false); } }
public Heightmap generateMap(int xSize, int ySize) { Heightmap map = new Heightmap(xSize, ySize, 0.5f); seed = Random.Range(int.MinValue, int.MaxValue); //Debug.Log (seed); //seed = -1949366325; map = new Heightmap(xSize, ySize, 0.5f); LayerManager lm = new LayerManager(xSize, ySize, seed); map.addLayer(lm.voronoiLayer(180, 1.5f, 1.3f, 16)); //1.5 1.3 map.addLayer(lm.perlinLayer(1, 1.1f, 4)); map.stretch(1.5f); map.smoothBetween(3, 6, 2, -1); map.addLayer(lm.perlinLayer(8, 1.1f, 4)); map.addLayer(lm.whiteNoiseLayer(8, 2)); map.stretch(1.2f); map.smoothBetween(2, 4, 2, -1); map.addLayer(lm.whiteNoiseLayer(2, 1)); map.addLayer(lm.whiteNoiseLayer(1, 1)); map.addLayer(lm.whiteNoiseLayer(2, 2), 0.4f, 0.6f); map.smoothBetween(1, 2, 2, -1); map.stretch(1.2f); map.smoothBetween(7, 4, 0.525f, 0.49f); map.smoothBetween(1, 1, 2, -1); return(map); }
/// <summary> /// Initializes a new instance of the <see cref="HeightDepthUVVertexData"/> class. /// </summary> /// <param name="data">The binary data.</param> /// <param name="width">The width of the vertex block.</param> /// <param name="height">The height of the vertex block.</param> public HeightDepthUVVertexData(byte[] data, byte width, byte height) { using (MemoryStream ms = new MemoryStream(data)) { using (BinaryReader br = new BinaryReader(ms)) { int arrayEntryCount = (width + 1) * (height + 1); for (int i = 0; i < arrayEntryCount; ++i) { Heightmap.Add(br.ReadSingle()); } for (int i = 0; i < arrayEntryCount; ++i) { Tuple <ushort, ushort> uvEntry = new Tuple <ushort, ushort>(br.ReadUInt16(), br.ReadUInt16()); UVMap.Add(uvEntry); } for (int i = 0; i < arrayEntryCount; ++i) { Depthmap.Add(br.ReadByte()); } } } }
/// <summary> /// Process a G-code that should be interpreted by the control server /// </summary> /// <param name="code">Code to process</param> /// <returns>Result of the code if the code completed, else null</returns> public static async Task <CodeResult> Process(Code code) { switch (code.MajorNumber) { // Load heightmap // FIXME Obtain the movement lock before sending the heightmap case 29: if (code.Parameter('S', 0) == 1) { string file = await FilePath.ToPhysicalAsync(code.Parameter('P', FilePath.DefaultHeightmapFile), "sys"); try { Heightmap map = new Heightmap(); await map.Load(file); await SPI.Interface.SetHeightmap(map); return(new CodeResult()); } catch (AggregateException ae) { return(new CodeResult(DuetAPI.MessageType.Error, $"Failed to load height map from file {file}: {ae.InnerException.Message}")); } catch (Exception e) { return(new CodeResult(DuetAPI.MessageType.Error, $"Failed to load height map from file {file}: {e.Message}")); } } break; } return(null); }
// Executing the raycast to find the object public static Boolean ExecuteRayCast(Player playerInstance) { int layerMask = playerInstance.m_placeRayMask; RaycastHit raycastHit; if (Physics.Raycast( GameCamera.instance.transform.position, GameCamera.instance.transform.forward, out raycastHit, 50f, layerMask ) && raycastHit.collider && !raycastHit.collider.attachedRigidbody && Vector3.Distance(Helper.getPlayerCharacter(playerInstance).m_eye.position, raycastHit.point) < playerInstance.m_maxPlaceDistance) { HitPoint = raycastHit.point; HitNormal = raycastHit.normal; HitPiece = raycastHit.collider.GetComponentInParent <Piece>(); HitObject = raycastHit.collider.gameObject; HitHeightmap = raycastHit.collider.GetComponent <Heightmap>(); InitialRotation = HitPiece.transform.rotation; InitialPosition = HitPiece.transform.position; return(isValidRayCastTarget()); } else { resetObjectInfo(); return(false); } }
private void GenerateButton_Click(object sender, RoutedEventArgs e) { (GenProperties gp, string r) = ValidateInput(); OutputBox.Text = r; System.Windows.Forms.Application.DoEvents(); if (gp == null) { return; // Error during validation } System.Windows.Forms.Application.DoEvents(); MF.Reseed(); Heightmap heightmap = new Heightmap(gp.hm_width, gp.hm_height); MaterialList matlist = new MaterialList(gp.mat_list); List <CFFKernel> CFFkernels = CFFKernel.InitKernals(gp); List <MesaAgent1> masI = new List <MesaAgent1>(); for (int i = 0; i < gp.m_origins; i++) { MesaAgent1 magent = new MesaAgent1(gp); magent.Run(heightmap, CFFkernels); masI.Add(magent); } MesaAgent2 masII = new MesaAgent2(heightmap, gp); masII.Run(); OutputBox.Text = "Finished generating! Rendering now..."; System.Windows.Forms.Application.DoEvents(); RenderHeightmap(heightmap, gp.hm_cellsize); OutputBox.Text = "Rendered!"; System.Windows.Forms.Application.DoEvents(); }
public void generate(ErosionOptions?erosionOptions, int time, float waterAmount) { int chunkSize = size / chunks; modifier.setSize(chunkSize, chunkSize); // Initialize heightmaps terrainHeightmap = new Heightmap(size + 1); waterHeightmap = new Heightmap(size + 1); waterflow = new Heightmap(size + 1); erosion = new Heightmap(size + 1); Heightmap terrainChunkHm, waterChunkHm; for (int x = 0; x < size; x += chunkSize) { for (int y = 0; y < size; y += chunkSize) { modifier.setOffset(x, y); modifier.generate(erosionOptions, time, waterAmount); terrainHeightmap.addOffset(x, y, modifier.getTerrainHeightmap()); waterHeightmap.addOffset(x, y, modifier.getWaterHeightmap()); waterflow.addOffset(x, y, modifier.getWaterflowMap()); erosion.addOffset(x, y, modifier.getErosionMap()); } } }
// Token: 0x06000D96 RID: 3478 RVA: 0x00060FD0 File Offset: 0x0005F1D0 public static bool GetAverageHeight(Vector3 worldPos, float radius, out float height) { List <Heightmap> list = new List <Heightmap>(); Heightmap.FindHeightmap(worldPos, radius, list); float num = 0f; int num2 = 0; using (List <Heightmap> .Enumerator enumerator = list.GetEnumerator()) { while (enumerator.MoveNext()) { float num3; if (enumerator.Current.GetAverageWorldHeight(worldPos, radius, out num3)) { num += num3; num2++; } } } if (num2 > 0) { height = num / (float)num2; return(true); } height = 0f; return(false); }
public WaterMap(Heightmap hm) { List <Point> flooded; this.xSize = hm.xSize; this.ySize = hm.ySize; this.grid = new TerrainType[hm.xSize, hm.ySize]; flagLand(hm); for (int x = 0; x < xSize; x++) { flagCol(x); } for (int y = 0; y < ySize; y++) { flagRow(y); } for (int x = 0; x < xSize; x++) { for (int y = 0; y < ySize; y++) { if (grid [x, y] == 0) { flooded = flood(x, y, TerrainType.undecided); flag(flooded, ocean_flag ? TerrainType.sea : TerrainType.lake); } } } }
public void SetFirstHeightmap(Heightmap heightmap) { //TODO: Rename this method //Set the input node to a new ImageFileNode using map as an input SetInputNode(new ImageFileNode(map, heightmap)); }
/// <summary> /// Generate a 2D texture preview of the heightmap for debugging /// </summary> /// <param name="map"></param> protected void UpdateTexture(Heightmap map) { // TODO: Some sort of prettier "NO TEXTURE" output? if (map == null) { return; } Color high = Color.red; Color mid = Color.yellow; Color low = Color.green; Color[] c = previewTexture.GetPixels(); float size = (float)TEXTURE_SIZE; for (int y = 0; y < TEXTURE_SIZE; y++) { for (int x = 0; x < TEXTURE_SIZE; x++) { float height = map.GetHeightBilinear(x / size, y / size); c[TEXTURE_SIZE * y + x] = height > 0.5f ? Color.Lerp(mid, high, (height - 0.5f) * 2f) : Color.Lerp(low, mid, height * 2f); } } previewTexture.SetPixels(c); previewTexture.Apply(); }
public override void UpdatePreview() { Module m = GetModule(); previewHeightmap = new Heightmap(width, height, false, false); System.DateTime startTime = System.DateTime.UtcNow; int resXh = width / 2; int resYh = height / 2; double divisor = height / 180.0; double lat, lon; Vector3 xyz; float value; for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { lat = (y - resYh) / divisor; lon = (x - resXh) / divisor; xyz = Utils.LatLonToXyz(lat, lon); value = Mathf.Clamp01((m.GetNoise(xyz.x, xyz.y, xyz.z) + 1f) / 2f); //Noise ranges from -1 to 1; texture needs value from 0 to 1 previewHeightmap.SetPixel(x, y, value); } } previewChanged = true; }
public void SetHeightmap() { Span <byte> span = new byte[128]; span.Fill(0xFF); Heightmap map = new Heightmap { XMin = 20, XMax = 180, XSpacing = 40, YMin = 50, YMax = 150, YSpacing = 50, Radius = 0, NumX = 3, NumY = 4, ZCoordinates = new float[] { 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120 } }; int bytesWritten = Writer.WriteHeightMap(span, map); Assert.AreEqual(80, bytesWritten); // Header float xMin = MemoryMarshal.Read <float>(span); Assert.AreEqual(20, xMin, 0.0001); float xMax = MemoryMarshal.Read <float>(span.Slice(4, 4)); Assert.AreEqual(180, xMax, 0.0001); float xSpacing = MemoryMarshal.Read <float>(span.Slice(8, 4)); Assert.AreEqual(40, xSpacing, 0.0001); float yMin = MemoryMarshal.Read <float>(span.Slice(12, 4)); Assert.AreEqual(50, yMin, 0.0001); float yMax = MemoryMarshal.Read <float>(span.Slice(16, 4)); Assert.AreEqual(150, yMax, 0.0001); float ySpacing = MemoryMarshal.Read <float>(span.Slice(20, 4)); Assert.AreEqual(50, ySpacing, 0.0001); float radius = MemoryMarshal.Read <float>(span.Slice(24, 4)); Assert.AreEqual(0, radius, 0.0001); ushort numX = MemoryMarshal.Read <ushort>(span.Slice(28, 2)); Assert.AreEqual(3, numX); ushort numY = MemoryMarshal.Read <ushort>(span.Slice(30, 2)); Assert.AreEqual(4, numY); // Points Span <float> zCoordinates = MemoryMarshal.Cast <byte, float>(span[32..]);
private void InitializeHeightData() { HeightData = new float[Size, Size]; GeomorphData = new float[Size, Size]; if (Heightmap == null) { return; } heights = new Color[Size * Size]; Heightmap.GetData <Color>(heights); HeightOffset = -heights[0].R / 255.0f; for (int i = 0; i < Size; i++) { for (int j = 0; j < Size; j++) { HeightData[i, j] = (heights[GetIndex(i, j)].R / 255.0f) + HeightOffset; AvgHeight += HeightData[i, j]; } } AvgHeight /= Size * Size; }
public void Read() { string path = Path.Combine(Directory.GetCurrentDirectory(), "../../../Utility/heightmap.csv"); Heightmap map = new Heightmap(); map.Load(path).Wait(); Assert.AreEqual(30, map.XMin, 0.0001); Assert.AreEqual(180, map.XMax, 0.0001); Assert.AreEqual(30, map.XSpacing, 0.0001); Assert.AreEqual(30, map.YMin, 0.0001); Assert.AreEqual(180, map.YMax, 0.0001); Assert.AreEqual(30, map.YSpacing, 0.0001); Assert.AreEqual(-1, map.Radius, 0.0001); Assert.AreEqual(6, map.NumX); Assert.AreEqual(6, map.NumY); Assert.AreEqual(36, map.ZCoordinates.Length); Assert.AreEqual(0.088, map.ZCoordinates[0], 0.0001); Assert.AreEqual(0.086, map.ZCoordinates[1], 0.0001); // ... Assert.AreEqual(0.056, map.ZCoordinates[34], 0.0001); Assert.IsNaN(map.ZCoordinates[35]); }
public void Write() { string path = Path.Combine(Directory.GetCurrentDirectory(), "../../../Utility/heightmap.csv"); string tempFile = Path.GetTempFileName(); TestContext.Out.WriteLine(tempFile); Heightmap tempMap = new Heightmap(); tempMap.Load(path).Wait(); tempMap.Save(tempFile).Wait(); Heightmap map = new Heightmap(); map.Load(tempFile).Wait(); Assert.AreEqual(30, map.XMin, 0.0001); Assert.AreEqual(180, map.XMax, 0.0001); Assert.AreEqual(30, map.XSpacing, 0.0001); Assert.AreEqual(30, map.YMin, 0.0001); Assert.AreEqual(180, map.YMax, 0.0001); Assert.AreEqual(30, map.YSpacing, 0.0001); Assert.AreEqual(-1, map.Radius, 0.0001); Assert.AreEqual(6, map.NumX); Assert.AreEqual(6, map.NumY); Assert.AreEqual(36, map.ZCoordinates.Length); for (int i = 0; i < tempMap.ZCoordinates.Length; i++) { Assert.AreEqual(tempMap.ZCoordinates[i], map.ZCoordinates[i], 0.0001); } }
/// <summary> /// Invalidate every resource due to a critical event /// </summary> /// <param name="codeErrorMessage">Message for cancelled codes</param> /// <returns>Asynchronous task</returns> public static async Task InvalidateData(string codeErrorMessage) { // Close every open file. This closes the internal macro files as well await Print.Cancel(); // Resolve pending macros, unbuffered (system) codes and flush requests foreach (CodeChannel channel in CodeChannels) { MacroFile.AbortAllFiles(channel); using (await Channels[channel].LockAsync()) { Channels[channel].Invalidate(codeErrorMessage); } } _bytesReserved = _bufferSpace = 0; // Resolve pending heightmap requests using (await _heightmapLock.LockAsync()) { _getHeightmapRequest?.SetException(new OperationCanceledException(codeErrorMessage)); _heightmapRequested = false; _setHeightmapRequest?.SetException(new OperationCanceledException(codeErrorMessage)); _heightmapToSet = null; } }
public ModelControl(string filename, bool create) { reflection = new Reflection(); heightmap = new Heightmap(1000); heightmap.MinHeight = -5f; heightmap.MaxHeight = 5f; useAileronForRudder = Convert.ToBoolean(Bonsai.Utils.Settings.GetValue("UseAileronChannel")); AircraftParameters parameters = new AircraftParameters(); if (create) { parameters.CreateDefault(filename); } else { parameters.File = filename; } if (parameters.Version == 2) { iFlightModel = new FlightModelWind2(); } else { iFlightModel = new FlightModelWind(); } iFlightModel.AircraftParameters = parameters; iFlightModel.Heightmap = heightmap; iFlightModel.Paused = true; iFlightModel.Initialize(); airplaneModel = new AirplaneModel(iFlightModel); airplaneModel.Position = new Vector3(0, 0, 0); }
public static Heightmap Convert(IExportContainer container, ref Heightmap origin) { Heightmap instance = new Heightmap(); instance.Heights = origin.Heights.ToArray(); if (Heightmap.HasShifts(container.ExportVersion)) { instance.Shifts = GetShifts(container, ref origin); } instance.PrecomputedError = origin.PrecomputedError.ToArray(); instance.MinMaxPatchHeights = origin.MinMaxPatchHeights.ToArray(); if (Heightmap.HasDefaultPhysicMaterial(container.ExportVersion)) { instance.DefaultPhysicMaterial = origin.DefaultPhysicMaterial; } instance.Width = origin.Width; instance.Height = origin.Height; if (Heightmap.HasThickness(container.ExportVersion)) { instance.Thickness = GetThickness(container, ref origin); } instance.Levels = origin.Levels; instance.Scale = origin.Scale; return(instance); }
public static void Postfix(ref Heightmap __instance) { if (Commands.debugTerrain) { Commands.m_materialInstance(__instance).SetTexture("_DiffuseTex0", Texture2D.whiteTexture); } }
/// <summary> /// Write a heightmap as read by G29 S1 /// </summary> /// <param name="to">Destination</param> /// <param name="map">Heightmap to write</param> /// <returns>Number of bytes written</returns> public static int WriteHeightMap(Span <byte> to, Heightmap map) { HeightMap header = new HeightMap { XMin = map.XMin, XMax = map.XMax, XSpacing = map.XSpacing, YMin = map.YMin, YMax = map.YMax, YSpacing = map.YSpacing, Radius = map.Radius, NumX = (ushort)map.NumX, NumY = (ushort)map.NumY }; MemoryMarshal.Write(to, ref header); Span <float> coords = MemoryMarshal.Cast <byte, float>(to.Slice(Marshal.SizeOf(header))); for (int i = 0; i < map.NumX * map.NumY; i++) { coords[i] = map.ZCoordinates[i]; } return(Marshal.SizeOf(header) + Marshal.SizeOf(typeof(float)) * map.NumX * map.NumY); }
/// <summary> /// Read a heightmap report /// </summary> /// <param name="from">Origin</param> /// <param name="map">Deserialized heightmap</param> /// <returns>Number of bytes read</returns> public static int ReadHeightMap(ReadOnlySpan <byte> from, out Heightmap map) { HeightMapHeader header = MemoryMarshal.Cast <byte, HeightMapHeader>(from)[0]; map = new Heightmap { XMin = header.XMin, XMax = header.XMax, XSpacing = header.XSpacing, YMin = header.YMin, YMax = header.YMax, YSpacing = header.YSpacing, Radius = header.Radius, NumX = header.NumX, NumY = header.NumY }; if (from.Length > Marshal.SizeOf(header)) { ReadOnlySpan <byte> zCoordinates = from.Slice(Marshal.SizeOf(header), Marshal.SizeOf <float>() * map.NumX * map.NumY); map.ZCoordinates = MemoryMarshal.Cast <byte, float>(zCoordinates).ToArray(); } else { map.NumX = map.NumY = 0; map.ZCoordinates = Array.Empty <float>(); } return(Marshal.SizeOf(header) + map.ZCoordinates.Length * Marshal.SizeOf <float>()); }
private void SetUpGameWorld() { //Sky dome first (depth buffer will be disabled on draw for this) var skyDome = new GradientSkyDome(Color.MediumBlue, Color.LightCyan); int patchSize = 100; int widthInTerrainPatches = 1; int heightInTerrainPatches = 1; CreateIsland(patchSize, widthInTerrainPatches, heightInTerrainPatches, Vector3.Zero); CreateIsland(patchSize, widthInTerrainPatches, heightInTerrainPatches, new Vector3(100, 0, 100)); CreateIsland(patchSize, widthInTerrainPatches, heightInTerrainPatches, new Vector3(130, 0, 0)); CreateIsland(patchSize, widthInTerrainPatches, heightInTerrainPatches, new Vector3(0, 0, 170)); //temporary water Heightmap seaHeightMap = new Heightmap(patchSize / 4 * widthInTerrainPatches, 1); var seaObject = seaHeightMap.CreateRenderableHeightMap(Color.Blue, EffectLoader.LoadSM5Effect("flatshaded")); seaObject.Transform.SetPosition(new Vector3(-50, 0, -50)); seaObject.Transform.Scale = 20; SystemCore.GameObjectManager.AddAndInitialiseGameObject(seaObject); }
public override IEnumerable <Object> FetchDependencies(ISerializedFile file, bool isLog = false) { foreach (Object @object in base.FetchDependencies(file, isLog)) { yield return(@object); } foreach (Object @object in SplatDatabase.FetchDependencies(file, isLog)) { yield return(@object); } foreach (Object @object in DetailDatabase.FetchDependencies(file, isLog)) { yield return(@object); } foreach (Object @object in Heightmap.FetchDependencies(file, isLog)) { yield return(@object); } if (IsReadLightmap(file.Version)) { yield return(Lightmap.FetchDependency(file, isLog, ToLogString, "m_Lightmap")); } }
// Token: 0x06000E58 RID: 3672 RVA: 0x000669D8 File Offset: 0x00064BD8 private void UpdateHealth(double timeSincePlanted) { if (timeSincePlanted < 10.0) { this.m_status = Plant.Status.Healthy; return; } Heightmap heightmap = Heightmap.FindHeightmap(base.transform.position); if (heightmap) { if ((heightmap.GetBiome(base.transform.position) & this.m_biome) == Heightmap.Biome.None) { this.m_status = Plant.Status.WrongBiome; return; } if (this.m_needCultivatedGround && !heightmap.IsCultivated(base.transform.position)) { this.m_status = Plant.Status.NotCultivated; return; } } if (this.HaveRoof()) { this.m_status = Plant.Status.NoSun; return; } if (!this.HaveGrowSpace()) { this.m_status = Plant.Status.NoSpace; return; } this.m_status = Plant.Status.Healthy; }
public void LoadRoomModels(int userId) { using (ISession session = ApiRoot.DatabaseCallback.GetDatabase().GetSessionFactory().OpenSession()) { foreach (RoomSql data in RoomEngine.GetRoomByOwner(userId)) { model = session.Get <roommodel>(data.id); doorX = model.doorX; doorY = model.doorY; doorZ = model.doorZ; //doorDir = model.doorDir; heightmap = model.heightmap; privateItems = Convert.ToString(model.publicItems); clubOnly = Convert.ToInt32(model.clubOnly); this.roomId = data.id; map = new Heightmap(); map.SetMap(heightmap); //habboObject = new HabboRoomObject(userId, data.id, ); //RoomModels.Add(model.id, this); } } }
public DSSquare(Heightmap heightmap, Point nw, Point ne, Point sw, Point se, float displacement) { this.heightmap = heightmap; this.nw = nw; this.ne = ne; this.sw = sw; this.se = se; this.displacementConstant = displacement; this.mid = new Point(nw.X + (ne.X - nw.X) / 2, nw.Y + (se.Y - ne.Y) / 2); }
private float[] SumHeighMaps(Heightmap h1, Heightmap h2) { int length = h1.GetFloatMap().Length; float[] hm = new float[length]; float[] h1f = h1.GetFloatMap(); float[] h2f = h2.GetFloatMap(); for (int i = 0; i < length; i++){ hm[i] = h1f[i] + h2f[i]; } return hm; }
private void DoLowOrderTerrain(Graphics g, Bitmap Outline, int seed = 0) { Random r = new Random(seed); Terrain.rand = r; if (!KeepCurrentSeed.Checked || Terrain.Map == null) { Heightmap MapSeed; MapSeed = new Heightmap(Outline.Width, Outline.Height); MapSeed.Holds = Terrain.BitmapToHolds(Outline); Terrain.Map = MapSeed; Terrain.Map.MaxValue = 5000; Terrain.Map.MinValue = -5000; } SortedList<double, Action> actions = new SortedList<double, Action>(); actions.Add(0.75, () => Terrain.Hill(r.NextPoint(), 0.0009, 0.5, 5, 10, true)); actions.Add(0.25, () => Terrain.Hill(r.NextPoint(), 0.0009, 0.5, 10, 25, true)); actions.Add(0.07, () => Terrain.MountainSmasher(5, 25, true)); actions.Add(0.04, () => Terrain.ValleyRaiser(5, 25, true)); actions.Add(0.05, () => Terrain.RiverFormation(0.009, 10)); actions.Add(0.01, () => Terrain.FluidSimulation(50)); Heightmap res = Terrain.Arbitrary(actions, 100000, (a) => { if (a % 100 == 0) { bw.ReportProgress(a, Terrain.Map.ToHeatmap((int)LandsPerCell.Value, Outline)); } return !bw.CancellationPending; }); if (ShowBitmap.Checked) { res.ShowHeatmap((int)LandsPerCell.Value, Outline); } FinishMap(); }
public Terrain(Heightmap heightmap, IRunManager manager) : this(heightmap.image, heightmap.minHeight, heightmap.maxHeight, heightmap.pointsPerMeter, manager) { }
public unsafe Terrain(Stream terrainDefFile, IRunManager manager) : base(manager) { var heightmap = new Heightmap(); using (var reader = XmlReader.Create(terrainDefFile)) { while (reader.Read()) { if (!reader.IsStartElement()) continue; switch (reader.Name) { case "heightmap": var file = reader["file"]; if (String.IsNullOrWhiteSpace(file)) { #if DEBUG Console.WriteLine("[Warning] No heightmapfile specified!"); #endif continue; } var filestream = Manager.Files.Get(file, false); heightmap.image = new Bitmap(Image.FromStream(filestream)); filestream.Dispose(); break; case "mapinfo": while (!(reader.NodeType == XmlNodeType.EndElement && reader.Name == "mapinfo")) { reader.Read(); if(!reader.IsStartElement()) continue; switch (reader.Name) { case "minheight": reader.Read(); heightmap.minHeight = reader.ReadContentAsFloat(); break; case "maxheight": reader.Read(); heightmap.maxHeight = reader.ReadContentAsFloat(); break; case "pointspermeter": reader.Read(); heightmap.pointsPerMeter = reader.ReadContentAsFloat(); break; } } break; case "renderinfo": break; } } } PointsX = heightmap.image.Size.Width; PointsZ = heightmap.image.Size.Height; var bitmapData = heightmap.image.LockBits(new Rectangle(0, 0, PointsX, PointsZ), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb); Height = new float[PointsX * PointsZ]; for (int i = 0; i < PointsZ; i++) { uint* row = (uint*)(bitmapData.Scan0 + (i * bitmapData.Stride)); for (int j = 0; j < PointsX; j++) { Height[j * PointsZ + i] = heightmap.minHeight + ((float)((double)(heightmap.maxHeight - heightmap.minHeight) * (double)row[j] / (double)uint.MaxValue)); } } heightmap.image.UnlockBits(bitmapData); }
public Scene() { camera = new Camera(); root = new SceneNode(); heightmap = new Heightmap(); }
private void DoHighOrderTerrain(Graphics g, Bitmap Outline, int seed = 0) { Random r = new Random(seed); Terrain.rand = r; if (!KeepCurrentSeed.Checked || Terrain.Map == null) { Heightmap MapSeed; MapSeed = new Heightmap(Outline.Width, Outline.Height); //MapSeed.Holds = Terrain.BitmapToHolds(Outline); Terrain.Map = MapSeed; } SortedList<double, Action> actions = new SortedList<double, Action>(); actions.Add(0.001, () => Terrain.Map.normalize(-5000, 5000)); actions.Add(0.5, () => Terrain.Mountains(20, 2, 30, 50)); actions.Add(0.49, () => Terrain.Valleys(20, 2, 30, 50)); actions.Add(0.04, () => Terrain.ValleyRaiser(2, 50, true)); actions.Add(0.05, () => Terrain.MountainSmasher(2, 50, true)); actions.Add(0.20, () => Terrain.RiverFormation(0.009, 10)); Heightmap res = Terrain.Arbitrary(actions, 100000, (a) => { if (a % 10 == 0) { bw.ReportProgress(a, Terrain.Map.ToHeatmap((int)LandsPerCell.Value, Outline)); } return !bw.CancellationPending; }); if (ShowBitmap.Checked) { res.ShowHeatmap((int)LandsPerCell.Value, Outline); } FinishMap(); }
public HM_Mountains(HeightmapParams vars, Heightmap hm) : base(vars) { }