[maxScript] オブジェクトのボリュームを計算する方法はありますか。
maxでvolume求められるんですね。知らなかった。Houdiniみたく、objectの大きさで判定処理がかけられる。
http://help.autodesk.com/view/3DSMAX/2015/JPN/?guid=__files_GUID_B94A1094_002C_4A7D_B5DD_AF5AB3435041_htm
fn CalculateVolumeAndCenterOfMass obj =
(
local Volume= 0.0
local Center= [0.0, 0.0, 0.0]
local theMesh = snapshotasmesh obj
local numFaces = theMesh.numfaces
for i = 1 to numFaces do
(
local Face= getFace theMesh i
local vert2 = getVert theMesh Face.z
local vert1 = getVert theMesh Face.y
local vert0 = getVert theMesh Face.x
local dV = Dot (Cross (vert1 - vert0) (vert2 - vert0)) vert0
Volume+= dV
Center+= (vert0 + vert1 + vert2) * dV
)
delete theMesh
Volume /= 6
Center /= 24
Center /= Volume
#(Volume,Center)
)
CalculateVolumeAndCenterOfMass $sphere001
http://help.autodesk.com/view/3DSMAX/2015/JPN/?guid=__files_GUID_B94A1094_002C_4A7D_B5DD_AF5AB3435041_htm
fn CalculateVolumeAndCenterOfMass obj =
(
local Volume= 0.0
local Center= [0.0, 0.0, 0.0]
local theMesh = snapshotasmesh obj
local numFaces = theMesh.numfaces
for i = 1 to numFaces do
(
local Face= getFace theMesh i
local vert2 = getVert theMesh Face.z
local vert1 = getVert theMesh Face.y
local vert0 = getVert theMesh Face.x
local dV = Dot (Cross (vert1 - vert0) (vert2 - vert0)) vert0
Volume+= dV
Center+= (vert0 + vert1 + vert2) * dV
)
delete theMesh
Volume /= 6
Center /= 24
Center /= Volume
#(Volume,Center)
)
CalculateVolumeAndCenterOfMass $sphere001
0 コメント:
コメントを投稿