3 次元空間を定義している 3 ポイント ヘルパーがあり、それらすべてをランダムにアニメートしました。
平面オブジェクトを、常にポイントで定義された平面に正確に向けておく方法はありますか。
この場合には、変換スクリプト コントローラが向いています。 変換スクリプト コントローラでは平面の回転 (方向) と位置の両方を制御できるためです。
以下のスクリプトは、次の処理を行います。
平面プリミティブを作成します。
3 ポイント ヘルパーを作成します。
変換スクリプトを割り当てて、この平面を 3 つの点で定義される平面に保持し、ヘルパー間の中央のポイントに位置付ける Matrix3 値を計算します。
ポイントを移動またはアニメートする場合、平面が伴います。
スクリプト:
--Create a plane and 3 point helper thePlane = Plane() p1 = point pos:[40,-10,30] p2 = point pos:[20,30,40] p3 = point pos:[-10,-20,30] --Create a Transform Script and assign it to the Plane ctrl = transform_script() thePlane.transform.controller = ctrl --Create three Node variables and assign the Helpers to them ctrl.addNode"p1" p1 ctrl.addNode"p2" p2 ctrl.addNode"p3" p3 --We create a variable to hold the expression --We calculate the vector from Point01 to Point02 txt ="v1 = normalize (p2.pos-p1.pos)\n" --and the vector from Point01 to Point03 txt +="v2 = normalize (p3.pos-p1.pos)\n" --The cross productof the two vectors is the normal to the plane txt +="nv1 = normalize (cross v1 v2)\n" --Thecross product ofthenormal and vector 1gives us a third axis txt +="nv2=normalize(cross nv1 v1)\n" --We create a matrix3 value using he first vector, --and the two cross products which are all orthogonal to each-other. --The translation part .row4 is the middle point --of the 3 points' positions: txt +="matrix3 v1 nv2 nv1 ((p1.pos+p2.pos+p3.pos)/3)" --Assign the expression to the script controller ctrl.setExpression txt