Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. float Gen_Height(int x, int y, int seed)
  2. {
  3. float height = 0;
  4. float newx;
  5. float newy;
  6. for (float resolution = 128; resolution >= 8; resolution /= 8)
  7. {
  8. newx = (seed / 40f) / resolution + x / resolution;
  9. newy = (seed / 40f) / resolution + y / resolution;
  10. height += (Mathf.PerlinNoise(newx, newy) - 0.5f) * resolution;
  11. }
  12. if (height < 0) height = 0;
  13. return height;
  14. }
  15.  
  16. public List<Vector3> Gen_Vertices(int chunkx, int chunky, int seed)
  17. {
  18. float height;
  19. int x = 101;
  20. List<Vector3> vertices = new List<Vector3>();
  21.  
  22. for (int i = 0; i < x; i++)
  23. {
  24. for (int j = 0; j < x; j++)
  25. {
  26. height = Gen_Height(i + chunkx * (int)x, j + chunky * (int)x, seed) * heightmod;
  27. vertices.Add(new Vector3(2*i, height,2* j));
  28. if (height > maxheight) maxheight = height;
  29. else if (height < minheight) minheight = height;
  30. }
  31. }
  32. return vertices;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement