Пример #1
0
	void finalizeHeightmap(RenderedHeightmap rh) {
		TerrainData tData = new TerrainData();

		tData.heightmapResolution = chunkResolution;
		tData.alphamapResolution = chunkResolution;
		tData.size = new Vector3(chunkWidth, terrainHeight, chunkWidth);

		tData.splatPrototypes = splats;
    	tData.RefreshPrototypes();

		/* Create and position the terrain */
		GameObject terrain = Terrain.CreateTerrainGameObject(tData);
		terrain.transform.position = new Vector3(
				chunkWidth * rh.coord.x,
				0.0f,
				chunkWidth * rh.coord.z);

		/* Set the heightmap data from the background thread. */
		tData.SetHeights(0, 0, rh.heightmap);

		stitchTerrain(tData, rh.coord);

		chunks[rh.coord] = tData;

		// texturing
		tData.SetAlphamaps(0, 0, rh.splatmap);
	}
Пример #2
0
    void finalizeHeightmap(RenderedHeightmap rh)
    {
        TerrainData tData = new TerrainData();

        tData.heightmapResolution = chunkResolution;
        tData.alphamapResolution  = chunkResolution;
        tData.SetDetailResolution(chunkResolution*2, 1);
        tData.size = new Vector3(chunkWidth, terrainHeight, chunkWidth);

        tData.splatPrototypes  = splats;
        tData.detailPrototypes = grassProto;
        tData.treePrototypes   = treeProto;
        tData.RefreshPrototypes();

        // tree placement
        tData.treeInstances = rh.treeInstances.ToArray();

        /* Create and position the terrain */
        GameObject terrain = Terrain.CreateTerrainGameObject(tData);
        terrain.transform.position = new Vector3 (
            chunkWidth * rh.coord.x,
            0.0f,
            chunkWidth * rh.coord.z);

        /* Set the heightmap data from the background thread. */
        tData.SetHeights(0, 0, rh.heightmap);

        stitchTerrain(tData, rh.coord);

        chunks[rh.coord] = tData;

        // texturing
        tData.SetAlphamaps(0, 0, rh.splatmap);

        // grass placement
        /*if (texturesToAffect.Length != 0) {
            var detailedLayer = grassPlacement (tData.detailResolution, tData.GetAlphamaps (0, 0,
                                   tData.alphamapWidth,
                                   tData.alphamapHeight));
            tData.SetDetailLayer (0, 0, grassType, detailedLayer);
        }*/
    }