예제 #1
0
    // Use this for initialization
    void Start()
    {
        this.gameObject.AddComponent(typeof(MeshFilter));
        Gradient terrainColor = makeGradient();

        GetComponent <MeshFilter>().mesh = LowPolyTerrainGenerator.TerrainDraft(
            new Vector3(200, 200, 20), 5.0f, 10.0f, terrainColor).ToMesh();
    }
예제 #2
0
        public void Generate()
        {
            targetPalette = RandomE.TetradicPalette(0.25f, 0.75f);
            targetPalette.Add(ColorHSV.Lerp(targetPalette[0], targetPalette[1], 0.5f));

            config.gradient = ColorE.Gradient(from: targetPalette[2].WithSV(0.8f, 0.8f),
                                              to: targetPalette[3].WithSV(0.8f, 0.8f));

            var draft = LowPolyTerrainGenerator.TerrainDraft(config);

            draft.Move(Vector3.left * config.terrainSize.x / 2 + Vector3.back * config.terrainSize.z / 2);
            meshFilter.mesh = draft.ToMesh();
        }
예제 #3
0
        public void Generate()
        {
            Vector3 terrainSize = new Vector3(terrainSizeX, terrainSizeY, terrainSizeZ);

            targetPalette = RandomE.TetradicPalette(0.25f, 0.75f);
            targetPalette.Add(ColorHSV.Lerp(targetPalette[0], targetPalette[1], 0.5f));

            var gradient = ColorE.Gradient(targetPalette[2].WithS(0.8f).WithV(0.8f),
                                           targetPalette[3].WithS(0.8f).WithV(0.8f));

            var draft = LowPolyTerrainGenerator.TerrainDraft(terrainSize, cellSize, noiseScale, gradient);

            draft.Move(Vector3.left * terrainSizeX / 2 + Vector3.back * terrainSizeZ / 2);
            meshFilter.mesh = draft.ToMesh();
        }
예제 #4
0
        public void Generate()
        {
            Vector3 terrainSize = new Vector3(terrainSizeX, terrainSizeY, terrainSizeZ);

            var draft = LowPolyTerrainGenerator.TerrainDraft(terrainSize, cellSize, noiseScale, grad);

            vert_x = (int)(terrainSizeX / cellSize);
            vert_z = (int)(terrainSizeZ / cellSize);

            for (int i = 0; i < 9; i++)
            {
                MeshDraft temp = LowPolyTerrainGenerator.TerrainDraft(terrainSize, cellSize, noiseScale, grad);
                temp.Move(Vector3.left * terrainSizeX / 2 + Vector3.back * terrainSizeZ / 2);
                drafts.Add(temp);
            }
            draft.Move(Vector3.left * terrainSizeX / 2 + Vector3.back * terrainSizeZ / 2);


            meshFilter.mesh         = draft.ToMesh();
            meshCollider.sharedMesh = draft.ToMesh();
            //meshCollider2.sharedMesh = draft.ToMesh();

            MorphFitRight(drafts[1], drafts[0]);
            MorphFitRight(drafts[2], drafts[1]);
            MorphFitRight(drafts[5], drafts[4]);
            MorphFitRight(drafts[7], drafts[6]);
            MorphFitRight(drafts[4], drafts[3]);
            MorphFitRight(drafts[8], drafts[7]);


            MorphFitDown(drafts[3], drafts[0]);
            MorphFitDown(drafts[4], drafts[1]);
            MorphFitDown(drafts[5], drafts[2]);
            MorphFitDown(drafts[6], drafts[3]);
            MorphFitDown(drafts[7], drafts[4]);
            MorphFitDown(drafts[8], drafts[5]);

            for (int i = 0; i < 9; i++)
            {
                meshes.Add(drafts[i].ToMesh());
            }
        }
예제 #5
0
        private void Awake()
        {
            RenderSettings.skybox = new Material(RenderSettings.skybox);
            meshCollider          = terrain.GetComponents <MeshCollider>()[0];

            //Generate Gradient for scene
            targetPalette = RandomE.TetradicPalette(0.25f, 0.75f);
            targetPalette.Add(ColorHSV.Lerp(targetPalette[0], targetPalette[1], 0.5f));
            var gradient = ColorE.Gradient(from: targetPalette[2].WithSV(0.8f, 0.8f),
                                           to: targetPalette[3].WithSV(0.8f, 0.8f));

            grad = gradient;

            targetPalette = RandomE.TetradicPalette(0.25f, 0.75f);
            targetPalette.Add(ColorHSV.Lerp(targetPalette[0], targetPalette[1], 0.5f));
            var gradient2 = ColorE.Gradient(from: targetPalette[2].WithSV(0.8f, 0.8f),
                                            to: targetPalette[3].WithSV(0.8f, 0.8f));

            grad2 = gradient2;


            Generate();
            currentPalette.AddRange(targetPalette);

            for (int i = 0; i < 10; i++)
            {
                Vector3 terrainSize = new Vector3(terrainSizeX, terrainSizeY, terrainSizeZ);
                var     temp_draft  = LowPolyTerrainGenerator.TerrainDraft(terrainSize, cellSize, noiseScale, grad);
                temp_draft.Move(Vector3.left * terrainSizeX / 2 + Vector3.back * terrainSizeZ / 2);
                pregen_graphs.Add(temp_draft);
                GameObject temp = (GameObject)Instantiate(terrain, new Vector3(0, -100, 0), terrain.transform.rotation);
                UpdateDraft(temp, temp_draft);
                pre_terrains.Add(temp);
                // temp.GetComponent<BoxCollider>().
            }
            foreach (GameObject g in pre_terrains)
            {
                g.GetComponent <ObjectSpawner>().gradient1 = grad;
                g.GetComponent <ObjectSpawner>().gradient2 = grad2;
            }
        }