为了账号安全,请及时绑定邮箱和手机立即绑定

ARCore – 模型旋转

ARCore – 模型旋转

白衣非少年 2023-09-20 15:20:17
我正在 ARCore Android 中工作,我想在单击按钮时旋转 3D 模型。我已经完成了旋转,但问题是它不会在当前位置旋转,即如果模型移动到平面上的其他位置,它会回到模型投影的初始位置,在这里我们可以看到旋转。我想将我的模型旋转到平面上的任何位置,并且它保留在那里。这是我的代码 private void rotateRight(TransformableNode node, AxisClass objAxis, Vector3 pos) {     node.getRotationController().setEnabled(true);     node.getScaleController().setEnabled(true);     node.getTranslationController().setEnabled(false);     Quaternion rightMoveVector = new Quaternion();     rightMoveVector = tNode.getLocalRotation();     Quaternion orientations = new Quaternion();     Quaternion orientation = Quaternion.axisAngle(new Vector3(pos.x, 1.0f, pos.z), rotateAngle);     node.setLocalRotation(Quaternion.axisAngle(new Vector3(0.0f, 1.0f, 0.0f), rotateAngle));     rotateAngle = rotateAngle + 30;     objAxis.setRotateRight(String.valueOf(rotateAngle));     objAxis.setY_axis(String.valueOf(Math.toRadians(rotateAngle)));}
查看完整描述

1 回答

?
慕桂英3389331

TA贡献2036条经验 获得超8个赞

对于模型旋转,您必须重写 sceneform android 中的 onupdate 方法。

执行旋转后,您必须设置模型位置,使其保持在原来的位置。

Quaternion q1 = tNode.getLocalRotation();
        Quaternion q2 = Quaternion.axisAngle(new Vector3(0f, 1f, 0f), -2f);
        tNode.setLocalRotation(Quaternion.multiply(q1, q2));
        tNode.setLocalPosition(localPosition);


查看完整回答
反对 回复 2023-09-20
  • 1 回答
  • 0 关注
  • 51 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信