通过局部旋转 MaxScript 将对象与法线对齐

问题描述 投票:0回答:1

我的脚本将对象与面对齐,如下所示:https://i.stack.imgur.com/WdkP9.png

但是我需要得到这个:https://i.stack.imgur.com/QNWeT.png

我使用了一个代码:

faces = (polyOp.getFaceSelection $Box001) as array
face = faces[1]
theMatrix = matrixFromNormal(polyOp.getFaceNormal $Box001 face)
theMatrix.row4 = polyOp.getFaceCenter $Box001 face
$object.transform = theMatrix

帮助我,朋友们:)

3d alignment maxscript
1个回答
0
投票

让我们试试这个:

nBOX_TAR = $Box001  -- Get and store object's to variables
nBOX_AL = $object

iFACE_SEL = ( (polyOp.getFaceSelection  nBOX_TAR) as array )[1]

-- Get verts numbers array associated with face
--aiP = polyop.getFaceVerts  nBOX_TAR  iFACE_SEL    -- May be this
aiP = polyop.getFaceEdges  nBOX_TAR  iFACE_SEL      -- Or this

-- Get verts coordinates
aP = polyop.getVerts  nBOX_TAR  aiP

-- Build transform matrix axis by axis
NOR_X = normalize (aP[2] - aP[1])                   -- 1 Get edge direction
NOR_Z = polyOp.getFaceNormal  nBOX_TAR  iFACE_SEL   -- 2 Get face normal
NOR_Y = normalize (cross  NOR_X  NOR_Z)             -- 3 Set Y ortho to X and Z
POS = polyOp.getFaceCenter  nBOX_TAR  iFACE_SEL

nBOX_AL.transform = Matrix3  NOR_X  NOR_Y  NOR_Z  POS
© www.soinside.com 2019 - 2024. All rights reserved.