/// 視線方向を向く(upベクトルがY軸プラス方向に固定版) static public void LookTrgVec(ref Matrix4 mtx, Vector3 lookVec) { Vector3 upVec = new Vector3(0.0f, 1.0f, 0.0f); if (lookVec.X == 0.0f && lookVec.Z == 0.0f) { lookVec.Z = 1.0f; } // Z軸のセット lookVec = lookVec.Normalize(); mtx.M31 = lookVec.X; mtx.M32 = lookVec.Y; mtx.M33 = lookVec.Z; mtx.M34 = 0; // X軸のセット Vector3 calVecX = Common.VectorUtil.Cross2(upVec, lookVec); calVecX = calVecX.Normalize(); mtx.M11 = calVecX.X; mtx.M12 = calVecX.Y; mtx.M13 = calVecX.Z; mtx.M14 = 0; // Y軸のセット Vector3 calVecY = VectorUtil.Cross2(lookVec, calVecX); calVecY = calVecY.Normalize(); mtx.M21 = calVecY.X; mtx.M22 = calVecY.Y; mtx.M23 = calVecY.Z; mtx.M24 = 0; }