Java3D中围绕特定点旋转

发布于 2024-08-14 00:05:45 字数 742 浏览 1 评论 0原文

我在 Java3D 中导入 2 个模型,将它们缩小,然后使用 RotationInterpolator 旋转其中一个模型,

但是,这会围绕原点旋转对象。我想围绕它的中心旋转对象,而不是场景的中心。简而言之,我希望它旋转到位。

如何围绕特定点旋转?

    TransformGroup rotateTheBlades = new TransformGroup();
    rotateTheBlades.setCapability(
                  TransformGroup.ALLOW_TRANSFORM_WRITE);

    Alpha rotationAlpha = new Alpha(-1,5000);

    RotationInterpolator rotator =
        new RotationInterpolator(
          rotationAlpha,rotateTheBlades);

    Transform3D abc = new Transform3D();
    abc.rotZ(Math.PI/2);

    rotator.setTransformAxis(abc);

    rotator.setSchedulingBounds(new BoundingSphere());

    rotateTheBlades.addChild(rotator);
    rotateTheBlades.addChild(theBlades);

这是我当前轮换的代码。

I'm importing 2 models in Java3D, scaling them down and then rotating one of them using a RotationInterpolator

However, this rotates the object around the origin. I want to rotate the object around ITS centre, not the scene's. Put simply, I want it to spin in place.

How do I rotate around a specific point?

    TransformGroup rotateTheBlades = new TransformGroup();
    rotateTheBlades.setCapability(
                  TransformGroup.ALLOW_TRANSFORM_WRITE);

    Alpha rotationAlpha = new Alpha(-1,5000);

    RotationInterpolator rotator =
        new RotationInterpolator(
          rotationAlpha,rotateTheBlades);

    Transform3D abc = new Transform3D();
    abc.rotZ(Math.PI/2);

    rotator.setTransformAxis(abc);

    rotator.setSchedulingBounds(new BoundingSphere());

    rotateTheBlades.addChild(rotator);
    rotateTheBlades.addChild(theBlades);

This is my code for doing my current rotation.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你与清晨阳光 2024-08-21 00:05:45

DR 的答案是将对象平移到原点,执行旋转,然后将对象平移回其位置。这有效。

我的实际解决方案是简单地将模型置于我加载到 Java3D 中的 .obj 文件中的原点中心,执行旋转,然后将对象转换到正确的位置。

DR answered with translating the object to the origin, performing the rotation, then translating the object back to its position. Which worked.

My actual solution was to simply centre the model at the origin in the .obj file I was loading into Java3D, perform my rotation, and then translate the objects to their proper position.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文