2

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

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

4

1 回答 1

1

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

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

于 2009-12-07T20:36:56.537 回答