Fermion generations, masses and mixing angles from extra dimensions