简体   繁体   English

围绕Java3D中的特定点旋转

[英]Rotate around a specific point in Java3D

I'm importing 2 models in Java3D, scaling them down and then rotating one of them using a RotationInterpolator 我正在Java3D中导入2个模型,将它们缩小比例,然后使用RotationInterpolator旋转其中一个模型

However, this rotates the object around the origin. 但是,这使对象绕原点旋转。 I want to rotate the object around ITS centre, not the scene's. 我想围绕ITS中心而不是场景的中心旋转对象。 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. 这是我当前轮换的代码。

DR answered with translating the object to the origin, performing the rotation, then translating the object back to its position. DR回答是将对象平移到原点,执行旋转,然后将对象平移回其位置。 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. 我的实际解决方案是将模型简单地定位在要加载到Java3D的.obj文件中的原点上,执行旋转,然后将对象平移到正确的位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM