SHARE
TWEET

Untitled

a guest Mar 25th, 2014 1,050 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  void Separate() {
  2.         iterations++;
  3.         List<Vector3> vec = new List<Vector3>();
  4.  
  5.          for (int i = 0; i < rooms.Count; i++) {
  6.              int n = 0;
  7.              vec.Add(new Vector3());
  8.              for (int j = 0; j < rooms.Count; j++) {
  9.                 float dist = Vector3.Distance(rooms[i].position, rooms[j].position);
  10.                 if (dist > 0 && dist < neighbourDistance) {
  11.                     vec[i] += (rooms[j].position - rooms[i].position);
  12.                     n++;
  13.                 }
  14.             }
  15.              if (n > 0) {
  16.                  Vector3 v = vec[i];
  17.                  v.x /= n;
  18.                  v.y /= n;
  19.                  v.z /= n;
  20.                  vec[i] = v;
  21.                  vec[i].Normalize();
  22.              }
  23.         }
  24.  
  25.          for (int i = 0; i < rooms.Count; i++) {
  26.              Vector3 p = rooms[i].position;
  27.              p -= vec[i];
  28.              rooms[i].position = p;
  29.          }
  30.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top