围绕Java3D中的特定点旋转

时间:2009-12-07 15:37:42

标签: java rotation java-3d

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

旋转其中一个模型

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

如何围绕特定点旋转?

    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);

这是我执行当前轮换的代码。

1 个答案:

答案 0 :(得分:1)

DR通过将对象平移到原点,执行旋转,然后将对象平移回其位置来回答。哪个有效。

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

相关问题