Notifications
Clear all

[Closed] Rounding all Vertices of a Mesh by nearest number?

Hi guys,

Is there a way to round all vertices of a mesh to the nearest numbers? E.g. If a vertex is at 3.24 then round it down to 3 for example.

Crono

5 Replies
fn roundfloat floatvar =
(
 if floatvar-(floatvar as integer) >= 0.5 then (return ceil floatvar as integer) else (return floor floatvar as integer)
)
for i = 1 to $.numverts do
(
 positionvar = (polyop.getvert $ i)
 positionvar.x = roundfloat positionvar.x
 positionvar.y = roundfloat positionvar.y
 positionvar.z = roundfloat positionvar.z
 polyop.setvert $ i positionvar
)

Out of curiosity… why do you want to do this? Or am I not understanding the question correctly?

As expected… Bobo has a more elegant solution I just found in the Scrolls of the Ages™ aka the archives.

 
fn RoundFloat valfloat = 
(
   floor (valfloat + 0.5) as integer 
)

It’s just something for work. Having geometry without floats… Thank you very much it works!

Keep in mind that this is a biased rounding method. It’s faster than a proper round (e.g. round-to-even), though.

You might want to check out this script also:
http://www.scriptspot.com/3ds-max/gridified

I’ve found it very useful for straightening up verts in a mesh and for fixing small offset errors in object positions.