我正在使用带有标记AR的Vuforia将物体垂直放置在标记上。我希望标记始终面对相机,并且其发生在以下代码中。问题在于它也绕X和Y轴旋转。我要删除这些轮播。
val oldMatrixArray = firstMatrix44F!!.data
val oldQuaternion = Quaternion.fromMatrix(oldMatrixArray, 0, 4)
val quaternion = Quaternion.fromMatrix(matrixData, 0, 4)
val quaternionLib = QuaternionLib(quaternion.x, quaternion.y, quaternion.z, quaternion.w)
val oldQuaternionLib =
QuaternionLib(oldQuaternion.x, oldQuaternion.y, oldQuaternion.z, oldQuaternion.w)
Log.d(
"QuaternionLibRad",
" X:" + quaternion.x + " Y:" + quaternion.y + " Z:" + quaternion.z + " W:" + quaternion.w
)
Log.d(
"QuaternionLibRad",
" Yaw:" + oldQuaternionLib.yawRad + " Pitch:" + quaternionLib.pitchRad + " Roll:" + oldQuaternionLib.rollRad
)
quaternionLib.setEulerAnglesRad(
oldQuaternionLib.yawRad,
quaternionLib.pitchRad,
oldQuaternionLib.rollRad
)
Quaternion.toMatrix(
matrixData,
quaternionLib.x,
quaternionLib.y /*quaternion.y()*/,
quaternionLib.z,
quaternionLib.w,
0,
4
)
val modelViewProjectionVideo = FloatArray(16)
Matrix.translateM(
matrixData, 0, 0.0f, 0.0f,
targetPositiveDimensions.data[0]
)
// Here we use the aspect ratio of the video frame
Matrix.scaleM(
matrixData, 0,
targetPositiveDimensions.data[0],
targetPositiveDimensions.data[0] * videoQuadAspectRatio,
targetPositiveDimensions.data[0]
)
Matrix.multiplyMM(
modelViewProjectionVideo, 0,
projectionMatrix, 0, matrixData, 0
)
任何帮助将不胜感激。