We propose a mechanism to obtain the generation of matter in the standard model. We start from the analysis of the T2/ZN shifted orbifold with magnetic flux, which imposes a ZN symmetry on torus. We also consider several orbifolds such as (T2×T2)/ZN, (T2×T2×T2)/ (ZN×ZN') and (T2×T2×T2)/(Z N×ZN'×ZN'). On such orbifolds, we study the behavior of fermions in two different means - the operator formalism and the explicit analysis of wave functions. For an interesting result, it is found that the number of zero-mode fermions is related to N of the ZN symmetry. In other words, the generation of matter relates to the type of orbifolds. Moreover, we find that shifted orbifold models are severely restricted from realizing three generations. For example, the three-generation model on the type of M4×(T2×T2)/ZN is unique. One can also construct other types of three-generation orbifold models with rich flavor structure. Those results may bring us a realistic model with desired Yukawa structure. © 2013 American Physical Society.