public void rotate(Direction dir)
  {
    if (dir == Direction.EAST)
    {
      Log.i("Rotating model right");
      for (Level l : levels)
      {
        for (Piece p : l.pieces)
        {
          int oldY = p.y;
          p.y = p.x;
          p.x = getHeight()*2 - oldY- 1; // height pre swap
          p.type = PieceType.getRotation(p.type);
          p.x -= p.type.width*2 - 1;
        }
        
        l.resortPieces();
      }
    }
    else if (dir == Direction.WEST)
    {
      Log.i("Rotating model left");
      for (Level l : levels)
      {
        for (Piece p : l.pieces)
        {
          int oldX = p.x;
          p.x = p.y;
          p.y = getWidth()*2 - oldX - 1; // height pre swap
          p.type = PieceType.getRotation(p.type);
          p.y -= p.type.height*2 - 1;
        }
        
        l.resortPieces();
      }
    }
    
    //TODO: manage swapping model width/height
  }