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

标签 android model augmented-reality arcore sceneform

我正在使用 Sceneform SDK在 Android 项目中。

我的项目中有 sfbsfa 对象,我希望对象的初始旋转旋转 90 度。 我怎样才能实现它?

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

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

model: {
  attributes: [
     "Position",
     "TexCoord",
     "Orientation",
  ],
  collision: {},
  file: "sampledata/models/redmixer.obj",
  name: "redmixer",
  scale: 0.010015,
},

最佳答案

我已经使用 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();

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

但基本上最后一个参数是以度为单位的角度。在本例中为 90deg -> 90f。通过矢量指定旋转方向。在示例中,我在 x 方向 (x,y,z) -> (1f, 0, 0) 上旋转。希望对您有所帮助。

关于android - 使用 Sceneform 生态系统有问题地旋转 3D 模型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51526039/

相关文章:

android - 如何清除 Android 上 SingleTop SingleInstance MainActivity 上的堆栈?

r - 如何在一个循环中拟合多个交互模型?

php - 调用未定义的方法 Illuminate\Database\Query\Builder::has_many()

angularjs - 我可以防止/延迟更新模型时AngularJS $ digest的发生吗

unity-game-engine - 团结-Vuforia : Detect the loss of a ground plane?

android - Google 登录错误状态 {statusCode=DEVELOPER_ERROR, resolution=null} 来自同一个 Play 商店应用而不是来自同一个签名的 apk

c# - 在 Android 上启用 AccessibilityService 后触摸屏事件停止工作

java - 让 Android 选择下一个 SQLITE _ID

java - 如何在 ARCore Sceneform 中为节点创建动画(更改缩放、旋转或位置)?

javascript - 带设备摄像头的 A 型框架 : how to see video behind the a-scene?