public static float GetValueAt(Vector3 worldPosition, Overworld.ScalarFieldType T) { Vector2 vec = new Vector2(worldPosition.X, worldPosition.Z) / PlayState.WorldScale; return(Overworld.GetValue(Overworld.Map, new Vector2(MathFunctions.Clamp(vec.X, 0, Overworld.Map.GetLength(0) - 1), MathFunctions.Clamp(vec.Y, 0, Overworld.Map.GetLength(1) - 1)), T)); }
public PreviewRenderType(String DisplayType, Overworld.ScalarFieldType Scalar, Func <WorldGenerator, Dictionary <String, Color> > GetColorKeys) { this.DisplayType = DisplayType; this.Scalar = Scalar; this.GetColorKeys = GetColorKeys; }
public static void MinBlend(MapData[,] heightMap, Vector2 pos, float height, Overworld.ScalarFieldType type) { int x = Math.Max(Math.Min((int)pos.X, heightMap.GetLength(0) - 1), 0); int y = Math.Max(Math.Min((int)pos.Y, heightMap.GetLength(1) - 1), 0); float orig = heightMap[x, y].GetValue(type); heightMap[x, y].SetValue(type, Math.Min(orig, height)); }
private static void ScaleMap(Overworld.MapData[,] map, int width, int height, Overworld.ScalarFieldType fieldType) { float min = 99999; float max = -99999; float average = 0; for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { float v = map[x, y].GetValue(fieldType); average += v; if (v < min) { min = v; } if (v > max) { max = v; } } } average /= (width * height); average = ((average - min) / (max - min)); bool tooLow = average < 0.5f; for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { float v = map[x, y].GetValue(fieldType); float newVal = ((v - min) / (max - min)) + 0.001f; if (tooLow) { newVal = 1.0f - newVal; } map[x, y].SetValue(fieldType, newVal); } } }
private static void ScaleMap(Overworld.MapData[,] map, int width, int height, Overworld.ScalarFieldType fieldType) { float min = 99999; float max = -99999; for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { float v = map[x, y].GetValue(fieldType); if (v < min) { min = v; } if (v > max) { max = v; } } } for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { float v = map[x, y].GetValue(fieldType); map[x, y].SetValue(fieldType, ((v - min) / (max - min)) + 0.001f); } } }