An invariance principle for a class of $d$-dimensional polygonal random functions