使用Sceneform生态系统有问题地旋转3D模型

Dav*_*vid 8 android model augmented-reality arcore sceneform

我正在Android Project中使用Sceneform SDK

我的项目中有sfbsfa对象,并且我希望对象的初始旋转被旋转90度。我该如何实现?

我在这些文件中找到了下一个代码,并更改了比例。

但是我没有找到轮换的方法。

model: {
  attributes: [
     "Position",
     "TexCoord",
     "Orientation",
  ],
  collision: {},
  file: "sampledata/models/redmixer.obj",
  name: "redmixer",
  scale: 0.010015,
},
Run Code Online (Sandbox Code Playgroud)

Lad*_*odi 5

我已经使用setLocalRotation成功地将对象旋转了90度。

      // Create the Anchor.
      Anchor anchor = hitResult.createAnchor();
      AnchorNode anchorNode = new AnchorNode(anchor);
      anchorNode.setParent(arFragment.getArSceneView().getScene());

      // Create the transformable andy and add it to the anchor.
      TransformableNode node = new TransformableNode(arFragment.getTransformationSystem());

      //set rotation in direction (x,y,z) in degrees 90
      node.setLocalRotation(Quaternion.axisAngle(new Vector3(1f, 0, 0), 90f));

      node.setParent(anchorNode);
      node.setRenderable(renderable);
      node.select();
Run Code Online (Sandbox Code Playgroud)

如果您对有关四元数的更多信息感兴趣,我建议:https : //proandroiddev.com/arcore-cupcakes-4-understanding-quaternion-rotations-f90703f3966e

但是基本上最后一个参数是角度(以度为单位)。在这种情况下90deg-> 90f。通过矢量可以指定旋转方向。在示例中,我沿x方向(x,y,z)->(1f,0,0)旋转。希望能帮助到你。