法線が現在のビューポートの外側を示す面を取得する方法はありますか。
ビュー スペースで面法線を取得することができます。 あとは、Z コンポーネントの記号を確認するだけです。 負の値の場合は、カメラから離れています。
スクリプト:
( theObj = Teapot segs:10 --create ateapot convertToMesh theObj --convert to EMesh theMeshCount = theObj.numfaces --get the number of faces in the object selArray = #() --init. an array to collect faces for f = 1 to theMeshCount do --loop through all faces ( in coordsys (inverse (viewport.GetTM())) theFN = getFaceNormal theObj f if theFN.z < 0 then append selArray f -- if Z is negative, add to array ) setFaceSelection theObj selArray --set the face selection in the EMesh max modify mode --go to modify mode select theObj --select the mesh subObjectLevel = 3 --go to Face SO level modPanel.addModToSelection (deleteMesh()) --add a delete mesh, preserving the SO selection )
結果: カメラから離れたところにある三角形は削除されます。
左側の画像には、カメラ ビューポートから見えるように背面を削除したティーポットが示されています。右側の画像には、側面から見えるようにティーポットとカメラが示されています。スクリーンショットでは、背面非表示が無効になっている場合でも、右側の画像で背面が表示されます。 一方、左側の画像では背面表示を有効にしたのと同じように背面が表示されます。これは、ビュー ポートの背面非表示でスキップされた面がスクリプトで削除されるためです。