先放着,空了再整理。。。。
fn getModeUvVolumetric mode chang= ----得到UV使用率
(
--global facesNumSum = meshop.getnumfaces mode
local facesUvVerts_Array = #()
local facesUvVertsPos_Array = #()
local A_T_S = 0----所有三角形面积
local uvFaceNum = meshop.getnummapfaces mode chang --得到指定通道UV面数
local uvVertsPos = #()
-- meshop.getmapface $ 2 1 --得带指定UV面得UV顶点
for i in 1 to uvFaceNum do
(
append facesUvVerts_Array (meshop.getmapface mode chang i)
)
for x in 1 to facesUvVerts_Array.count do
(
uvVertsPos = #() --数据还原
for y in 1 to 3 do
(
append uvVertsPos (meshop.getmapvert mode chang (facesUvVerts_Array[x][y]as integer))
)
append facesUvVertsPos_Array uvVertsPos
)
--facesUvVerts_Array = #() --数据还原
for i in 1 to facesUvVertsPos_Array.count do -----坐标转换到距离
(
uvPos_A = distance facesUvVertsPos_Array[i][1] facesUvVertsPos_Array[i][2]
uvPos_B = distance facesUvVertsPos_Array[i][1] facesUvVertsPos_Array[i][3]
uvPos_C = distance facesUvVertsPos_Array[i][3] facesUvVertsPos_Array[i][2]
facesUvVertsPos_Array[i][1] = uvPos_A
facesUvVertsPos_Array[i][2] = uvPos_B
facesUvVertsPos_Array[i][3] = uvPos_C
)
for i in 1 to facesUvVertsPos_Array.count do ----三角形面积
(
local T_P_A
local T_P_B
local T_P_C
local T_S
local T_p =0 --三角形周长/2
for j in 1 to facesUvVertsPos_Array[i].count do ---海伦公式
(
T_p = T_p + facesUvVertsPos_Array[i][j]
)
T_p = T_p/2 --半周长
T_P_A = T_p - facesUvVertsPos_Array[i][1]
T_P_B = T_p - facesUvVertsPos_Array[i][2]
T_P_C = T_p - facesUvVertsPos_Array[i][3]
T_S = sqrt (T_p*T_P_A*T_P_B*T_P_C) ---海伦公式
facesUvVertsPos_Array[i] = T_S
A_T_S = A_T_S + T_S
)
return A_T_S
--print facesUvVertsPos_Array
)