Align to poly center

I have a poly terrain mesh:

The polys are all .. ngons. This is intentional, it was created with a voroni script and displace modifier. See lowpolyterraina.png

I want to cycle through each poly, round it's height to X number of places and then flatten that poly in the z axis, at that height (so all vertices end up at 0, 4, 8, 12, for example).

I would like to be able to enter a number for the number of levels, and a distance, for the separation of the levels, so if I say 4 levels at 4m each, model will be 12m tall. lowpolyterrainb.png shows the basic idea using 3 levels at, i think it was 8m (i moved polys manually).

I know a little about coding in c#, but havent been able to find information on how to tackle this so I thought I would ask here.


lowpolyterraina.png163.22 KB
lowpolyterrainb.png44.25 KB