Max中UVW的修复脚本

今天发现有时候Max的UVW坐标会出现浮点数越限的情况,就变成了非法的浮点数,显示为 1.#QNAN 。从下面这段脚本的判断也可以明白是什么状况,即坐标既不大于等零也不小于等于零.....。出现此状况后在点级别就完全无法操作,可以用下面这段脚本解决,也可以将模型导成某种格式再导回来,同样可以达到效果。

RepairUVW
Fn RepairUVW targetMesh =
(
sourceClass
= ClassOf targetMesh.Baseobject
ConvertToMesh targetMesh
for fi = 1 to GetNumFaces targetMesh.mesh do
(
ft
= GetTVFace targetMesh.mesh fi

for ni = 1 to 3 do
(
tempUvw
= getTVert targetMesh.mesh ft[ni]
for ui = 1 to 3 do
(
if (not tempUvw[ui] >= 0) and (not tempUvw[ui] <= 0) do tempUvw[ui] = 1
)
SetTVert targetMesh.mesh ft[ni] tempUvw
)
)
Update targetMesh
if sourceClass == Editable_Poly do ConvertTo targetMesh Editable_Poly
AddModifier targetMesh (Unwrap_UVW())
)

for tempObj in Selection as array do RepairUVW tempObj

原文地址:https://www.cnblogs.com/sitt/p/1979810.html