void Awake()
    {
        ds         = terrainG.GetComponent <DiamondSquareV2>();
        mapScalar  = ds.GetGridSize();
        water      = new Mesh();
        water.name = "waterMesh";
        GenerateMesh();
        MeshFilter meshFilter = this.gameObject.AddComponent <MeshFilter>();

        meshFilter.mesh       = water;
        meshrenderer          = this.gameObject.AddComponent <MeshRenderer>();
        meshrenderer.material = new Material(Shader.Find("Unlit/WaterShader"));
        // renderer.material.SetTexture("_BumpMap", normalMap);
    }
Example #2
0
 void Start()
 {
     //Get the transform and DiamondSquareV2 of the terraingenerator and transform and WaterGenerator components of the water.
     camT = cam.GetComponent <Transform>();
     wT   = water.GetComponent <Transform>();
     tT   = terrainGenerator.GetComponent <Transform>();
     ds   = terrainGenerator.GetComponent <DiamondSquareV2>();
     wv   = water.GetComponent <Waves>();
     //Generate the terrain mesh
     ds.GenerateMesh();
     avgHeight   = ds.GetAvgHeight();
     tT.position = new Vector3(0f, -avgHeight, 0f);
     //Set the water height to the average terrain height
     wT.position = new Vector3(0f, 0f, 0f);
     //Generate the water mesh
     wv.GenerateMesh();
     //Set player starting position and rotation
     player.position      = new Vector3(playerStartingPos.x, playerStartingPos.y, playerStartingPos.z);
     player.localRotation = Quaternion.Euler(playerStartingRot);
     camT.localRotation   = Quaternion.Euler(playerStartingPos);
     isLoading            = false;
 }
Example #3
0
 // Start is called before the first frame update
 void Start()
 {
     dq       = terrainGenerator.GetComponent <DiamondSquareV2>();
     gridsize = dq.GetGridSize();
 }