【发布时间】:2020-01-30 10:27:10
【问题描述】:
所以我正在构建一个应用程序,其中所有用户放置的对象都应该面向相同的方向。为此,我需要从放置对象的锚点上移除所有旋转。这是从锚点读取姿势并放置对象的代码:
for (ColoredAnchor coloredAnchor : anchors) {
if (coloredAnchor.anchor.getTrackingState() != TrackingState.TRACKING) {
continue;
}
// Get the current pose of an Anchor in world space. The Anchor pose is updated
// during calls to session.update() as ARCore refines its estimate of the world.
coloredAnchor.anchor.getPose().toMatrix(anchorMatrix, 0);
// Update and draw the model and its shadow.
virtualObject.updateModelMatrix(anchorMatrix, scaleFactor / 12f);
virtualObject.draw(viewmtx, projmtx, colorCorrectionRgba, arrowColor);
}
如何从矩阵中移除旋转但保持锚点的本地位置?
我知道你可以使用
coloredAnchor.anchor.getPose().getRotationQuaternion();
提取旋转和
Matrix.rotateM();
旋转锚矩阵。但是rotateM 以度为单位的角度作为输入,而getRotationQuaternion() 输出不同的格式。也许 on 可以将四元数的输出转换为度数,然后逆向旋转矩阵?
总而言之,3D 模型在现实世界中应该始终面向同一个方向。
【问题讨论】:
标签: java android matrix arcore