static void Init() { GrassPlacement window = (GrassPlacement)GetWindow(typeof(GrassPlacement)); window.Show(); window.titleContent = new GUIContent("Grass Creator"); window.Focus(); window.ShowUtility(); if (Selection.activeGameObject && Selection.activeGameObject.GetComponent <Terrain>()) { window.terrain = Selection.activeGameObject.GetComponent <Terrain>(); } }
void Start() { noise = new PerlinNoise (); noise.baseOctave = noiseBaseOctave; noise.weights = noiseWeights; noise.Init (); chunkResolution = (int)Math.Pow (2, chunkExponent) + 1; chunkWidth = chunkResolution * chunkScale; chunks = new Hashtable (); heightmapQueue = Queue.Synchronized (new Queue ()); reverseThermalEroder = new ThermalTerrainErosion (); reverseThermalEroder.talus = this.reverseErosionTalus; reverseThermalEroder.strength = this.reverseErosionStrength; reverseThermalEroder.reverse = true; reverseThermalEroder.reverseTalusCutoff = this.reverseErosionReverseTalusCutoff; reverseThermalEroder.iterations = this.reverseErosionIterations; hydraulicEroder = new HydraulicTerrainErosion (); hydraulicEroder.rainfallAmount = hydraulicErosionRainfallAmount; // kr hydraulicEroder.evaporationRatio = hydraulicErosionEvaporationRatio; // ke hydraulicEroder.sedimentCapacity = hydraulicErosionSedimentCapacity; // kc hydraulicEroder.soilSolubility = hydraulicErosionSoilSolubility; // ks hydraulicEroder.rainAltitude = hydraulicErosionRainAltitude; hydraulicEroder.rainFalloff = hydraulicErosionRainFalloff; hydraulicEroder.iterations = hydraulicErosionIterations; thermalEroder = new ThermalTerrainErosion (); thermalEroder.talus = this.thermalErosionTalus; thermalEroder.strength = this.thermalErosionStrength; thermalEroder.reverse = false; thermalEroder.iterations = this.thermalErosionIterations; texturer = new Texturer(); texturer.Init(); texturer.slopeValue = slopeValue; texturer.mountainPeekStart = mountainPeekStart; texturer.mountainPeekHeight = mountainPeekHeight; texturer.waterHeight = waterHeight; texturer.shoreHeight = shoreHeight; splats = new SplatPrototype[diffuses.Length]; texturer.treeHeightFactor = treeHeightFactor; texturer.treeStrength = treeStrength; treeProto = new TreePrototype[treePrefab.Length]; for (var i = 0; i < treePrefab.Length; i++) { treeProto[i] = new TreePrototype(); treeProto[i].bendFactor = 0; treeProto[i].prefab = treePrefab[i]; } grassPlacer = new GrassPlacement(); grassPlacer.grassType = grassType; grassPlacer.texturesToAffect = texturesToAffect; for (var i = 0; i < diffuses.Length; i++) { splats[i] = new SplatPrototype(); splats[i].texture = diffuses[i]; splats[i].normalMap = normals[i]; splats[i].tileSize = new Vector2(5, 5); } grassProto = new DetailPrototype[1]; grassProto[0] = new DetailPrototype(); grassProto[0].prototypeTexture = grass; grassProto[0].bendFactor = 0.1f; grassProto[0].dryColor = new Color(0.804f, 0.737f, 0.102f, 1.000f); grassProto[0].healthyColor = new Color(0.263f, 0.976f, 0.165f, 1.000f); grassProto[0].maxHeight = 0.5f; grassProto[0].minHeight = 0.2f; grassProto[0].maxWidth = 1f; grassProto[0].minWidth = 0.5f; grassProto[0].noiseSpread = 0.1f; grassProto[0].prototype = null; grassProto[0].renderMode = DetailRenderMode.GrassBillboard; grassProto[0].usePrototypeMesh = false; ensureChunk(new ChunkCoord(0, 0), false); ensureChunk(new ChunkCoord(-1, -1), true); ensureChunk(new ChunkCoord(0, -1), true); ensureChunk(new ChunkCoord(-1, 0), true); }