public void ApplyDiamondSquare() { _rock = (float)Convert.ToDouble(RockValue.text.Length > 0 ? RockValue.text : _rock.ToString()); _grain = Convert.ToInt32(GrainValue.text.Length > 0 ? GrainValue.text : _grain.ToString()); var algorithm = new DiamondSquareTerrain(_grain, _rock); var hightMap = algorithm.GetHeightMap(200); _data.SetHeights(0, 0, hightMap); }
void Start() { //get the terrain component and parameters GameObject terrainObject = GameObject.Find("terrain"); //see if the terrain object exists DiamondSquareTerrain terrain = terrainObject.GetComponent <DiamondSquareTerrain>(); // get the script //offset of the sun away from the terrain boundaries float sizeOffset = terrain.size / 2; //the raduis of the sun rotation around the origin transform.position = new Vector3(0.0f, 0.0f, terrain.size / 2 + sizeOffset); }
void RestrictToBoundaries() { // Get boundary of generated Terrain Vector3 pos; DiamondSquareTerrain terrain = GameObject.Find("Terrain").GetComponent <DiamondSquareTerrain>(); float boundary = terrain.mSize / 2.0f; // Restrict movement to boundaries pos = this.transform.position; pos.x = Mathf.Clamp(pos.x, -boundary, boundary); pos.y = Mathf.Clamp(pos.y, -boundary, boundary); pos.z = Mathf.Clamp(pos.z, -boundary, boundary); this.transform.position = pos; }
void Start() { //get the terrain component and parameters GameObject terrainObject = GameObject.Find("terrain"); //see if the terrain object exists DiamondSquareTerrain terrain = terrainObject.GetComponent <DiamondSquareTerrain>(); // get the script boundarySize = terrain.size / 2; //initialise boundarySize to half of the terrain size (since terrain is centered at origin) //cameras rigid body rb = GetComponent <Rigidbody>(); cameraOFFSET = terrain.maxHeight * 2; //Initial camera view - position and rotation transform.position = new Vector3(boundarySize, terrain.maxHeight + cameraOFFSET, boundarySize); transform.LookAt(new Vector3(15, 0, 0)); //make sure that the previous mouse position is initilaised to the current mouse position //ensures that camera view is synced with mouse position prevMousePos = Input.mousePosition; }
protected override void Start() { _algorithm = new DiamondSquareTerrain(); base.Start(); BiomType = EBiomType.Fel; }