在 ArCore 中旋转和移动静态对象

Rotating and moving static object in ArCore

我正在使用 ArCore 中的相机锚点在场景中创建静态对象。

float scaleFactor = 1.0f;

camera.getPose().toMatrix(cameraAnchorMatrix, 0);
// Update and draw the model and its shadow.
Matrix.rotateM(cameraAnchorMatrix, 0, 110, 0f, 1f, 0f);

virtualObject.updateModelMatrix(cameraAnchorMatrix, scaleFactor / 10);
virtualObject.draw(viewmtx, projmtx, colorCorrectionRgba);

但是旋转对象有时会使它不可见,而且平移它似乎也不起作用。我也在猜测旋转的值。从顶部也可以看到物体,我怎样才能让它看起来更自然? (这是一个应该显示方向的箭头。) 如何将对象移动到屏幕左下角并从左向右旋转?

这是目前的样子。我想将箭头向下和向左移动并向前倾斜。然后它应该可以左右旋转。感谢您的帮助。

用下面的代码解决了:

camera.getPose().compose(Pose.makeTranslation(0.37f, -0.17f, -1f)).extractTranslation().toMatrix(cameraAnchorMatrix, 0);           

这会使对象出现 'behind' 相机并将其移动到左下角。然后你可以用角度值旋转对象:

 Matrix.rotateM(cameraAnchorMatrix, 0, 230 - directionChange, 0f, 1f, 0f);