gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:58:50 25 4
gpt4 key购买 nike

我正在使用 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com