エッジ中間の EPoly 頂点を削除する方法はありますか。

MAXScript に関する質問と回答 > 編集可能ポリゴンの操作 > エッジ中間の EPoly 頂点を削除する方法はありますか。

質問:

エッジ選択にフィルタ処理を行って、「エッジ選択要素」のような、接続されたエッジを含む配列を作成したいと考えています。2 つの配列のエッジは決して接続されません。 つまり、頂点を共有しません。

回答:

次の疑似コードは、実行可能な手段を記述したものです。

スクリプト:

macroScript KillMidEdgeVerts category: "MXS Help"
(
--make sure a single EPoly object is selected
on isEnabled return
 selection.count == 1 and classof selection[1].baseobject == Editable_Poly
on execute do
(
 thePoly = selection[1] --get the selected object
 select thePoly --select it
 max modify mode --switch to modify panel
 --set the base object as current level:
 modPanel.setCurrentObject selection[1].baseobject
 subObjectLevel = 1 --set sub-*object level to vertex level
 numVerts = (polyop.getNumVerts thePoly) --get the total vertex count
 undo on "KillMidEdgeVerts" --enable undo context
 (
  --loop backwards from the last to the first vertex
  for v = numVerts to 1 by -1 do
  (
   --get the edges using the vertex to check the count
   nVerts = (polyop.getEdgesUsingVert thePoly v) as array
   if nVerts.count == 2 do --if only two edges found, then
   (
    --get the verts of the first egde
    edge1verts = (polyop.getVertsUsingEdge thePoly nVerts[1]) as array
    --calculate the vector defined by the two vertices in the first edge
    vector1 = (polyop.getVert thePoly edge1verts[1]) - (polyop.getVert thePoly edge1verts[2])
    --get the verts of the second edge
    edge2verts = (polyop.getVertsUsingEdge thePoly nVerts[2] as array)
    --calculate the vector defined by the two vertices in the second edge
    vector2 = (polyop.getVert thePoly edge2verts[1]) - (polyop.getVert thePoly edge2verts[2])
    --calculate the angle between the two normalized vectors
    angle = acos (dot (normalize vector1) (normalize vector2))
    --if the angle is less than the threashold (change 0.01 to whatever threashold you want!)
    if angle < 0.01 do
    (
     select thePoly.verts[v]--then select the current vertex
     thePoly.EditablePoly.buttonOp #Remove--and hit the remove button
    )
   )--end if
  )--end v loop
 )--end undo
)--end on
)--end macro

関連事項