PDA

View Full Version : Rounding all Vertices of a Mesh by nearest number?

 CronoC04-30-2008, 06:34 PMHi 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
thatoneguy
04-30-2008, 06:49 PM
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? :D

thatoneguy
04-30-2008, 07:21 PM
As expected... Bobo has a more elegant solution I just found in the Scrolls of the Ages(tm) aka the archives.

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

CronoC
04-30-2008, 07:36 PM
It's just something for work. Having geometry without floats... Thank you very much it works! :)

ZeBoxx2
05-02-2008, 02:07 PM
Keep in mind that this is a biased rounding method. It's faster than a proper round (e.g. round-to-even), though.

JHaywood
05-02-2008, 04:38 PM
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.

CGTalk Moderation
05-02-2008, 04:38 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.