private void Init() { UseOpenSimplex = RbOpenSimplex.IsChecked.Value; UseFastSimplex = RbFastSimplex.IsChecked.Value; double h; for (int I = 0; I < XSize; I++) { for (int J = 0; J < ZSize - 1; J++) { if (UseFastSimplex) { h = PeakHeight * FastSimplexNoise.WideNoise2D(I * Scale * CellSize / 2, J * Scale * CellSize / 2 + ZOff / 2, Roughness, 0.5, 1) - 0.3; } else if (UseOpenSimplex) { h = PeakHeight * OpenSimplexNoise.WideNoise2D(I * Scale * CellSize, J * Scale * CellSize + ZOff, Roughness, 0.5, 1) - 0.3; } else { h = PeakHeight * PerlinNoise.WideNoise2D(I * Scale * CellSize, J * Scale * CellSize + ZOff, Roughness, 0.5, 1) - 0.3; } if (h < 0) { h = 0.05; } Elevations[I, J] = h; } Elevations[I, ZSize - 1] = 0.8 * PeakHeight; } }
private void CompositionTarget_Rendering(Object sender, EventArgs e) { if (!Rendering) { return; } double h; for (int I = 0; I < XSize; I++) { if (UseFastSimplex) { h = PeakHeight * FastSimplexNoise.WideNoise2D(I * Scale * CellSize / 2, ZOff / 2, Roughness, 0.5, 1) - 0.3; } else if (UseOpenSimplex) { h = PeakHeight * OpenSimplexNoise.WideNoise2D(I * Scale * CellSize, ZOff, Roughness, 0.5, 1) - 0.3; } else { h = PeakHeight * PerlinNoise.WideNoise2D(I * Scale * CellSize, ZOff, Roughness, 0.5, 1) - 0.3; } if (h < 0) { h = 0.05; } Elevations[I, 0] = h; for (int J = ZSize - 1; J > 0; J--) { Elevations[I, J] = Elevations[I, J - 1]; } } ZOff -= Scale * CellSize; Mesh.Heights = Elevations; GC.Collect(); Mesh.GenerateGeometry(Scene1); //Render the scene. Scene1.Render(); }