Does anyone know if there is a quick way to round the positions of all verts? They're off by a few micrometers atm and it's causing issues. I need them to be rounded to the nearest millimetre.
Don't think there's that much precision in max but do you really need that much? Would like to see some context if you can.
sel = selection
for obj in selection do (
num_verts = obj.GetNumVertices()
for id = 1 to num_verts do (
v_coords = polyOp.getVert obj id
ss = stringStream ""
format "Vertex ID: % | Vertex Pos: % | Object: % " id (v_coords as String) (obj as String) to:ss
print(ss as String)
)
)
It's work related so I can't really discuss it unfortunately. The problem is that when I snap things to the grid or even manually type it in, the verts are off by a few micrometers. Which causes problems in the engine.
If it's two separate objects that you're trying to snap together, even if the verts are in exactly the same position in Max there is no guarantee you won't get a seam in the engine (or in Max). Just a result of floating point impreicision.
The simplest way to fix that is to add a little lip to the border edges in your meshes.
decimals = 4
sel = selection
for obj in selection do (
num_verts = obj.GetNumVertices()
for id = 1 to num_verts do (
v_coords = polyOp.getVert obj id
for i = 1 to 3 do (
case i of
(
1 :
(
num = dotNetObject "System.Double" v_coords.x
v_coords.x = ((dotNetClass "System.Math").round num decimals) as float
)
2 :
(
num = dotNetObject "System.Double" v_coords.y
v_coords.y = ((dotNetClass "System.Math").round num decimals) as float
)
3 :
(
num = dotNetObject "System.Double" v_coords.z
v_coords.z = ((dotNetClass "System.Math").round num decimals) as float
)
)
)
polyop.setVert obj id v_coords -- Set the vertex
ss = stringStream ""
format "Vertex ID: % | Vertex Pos: % | Object: % " id (v_coords as String) (obj as String) to:ss
print(ss as String)
)
)
You can control the decimal rounding at the top. Right now set to nearest mm. Also to my knowledge when you type something in to the transform box at the bottom its automatically rounded to the 3 decimal places but that might just be format print doing its job to prettify the value. If its what Farfarer is talking about then yeah there will usually be a seam there.
Replies
The simplest way to fix that is to add a little lip to the border edges in your meshes.
You can control the decimal rounding at the top. Right now set to nearest mm. Also to my knowledge when you type something in to the transform box at the bottom its automatically rounded to the 3 decimal places but that might just be format print doing its job to prettify the value. If its what Farfarer is talking about then yeah there will usually be a seam there.