====== matrix4x4使用の移動サンプル ====== matrix4x4で変換行列を使用してSubItemのオブジェクトを移動させるサンプルスクリプトです。\\ サンプルではZ軸周りで毎フレーム1度回転するようになっています。 === サンプルデータ === https://virtualcast.jp/products/93ab24411da7edf1bdbf503c30d82fee0b1117c0d87536101d2944eae7a4fdd0 === Unitypackage === {{ :vci:sample:sample_advanced:tutorial_matrix4x4.unitypackage |}} ===== VCIスクリプト ===== local m = Matrix4x4.zero local sub = vci.assets.GetTransform("sub") local baseposition local baserotation local basescale local rotq local rotation = Quaternion.Euler(0, 0, 1)--ローカル回転量 local translation = Vector3.__new(0,0,0)--ローカル移動量 local scale = Vector3.__new(1,1,1)--ローカルスケール量 function updateAll() baseposition = sub.GetLocalPosition()--Vector3 baserotation = sub.GetLocalRotation()--Quaternion basescale = sub.GetLocalScale()--Vector3 m.setTRS(translation,rotation,scale)--mに変換行列を設定 rotq = m.rotation --変換行列から求めた回転 Quaternion baserotation = rotq*baserotation baseposition = m.MultiplyPoint3x4(baseposition)--平行移動の場合使用できる basescale = Vector3.__new(scale.x*basescale.x,scale.y*basescale.y,scale.z*basescale.z) sub.SetLocalRotation(baserotation)--回転を適用 sub.SetLocalPosition(baseposition)--移動を適用 sub.SetLocalScale(basescale)--スケールを適用 end