Java3D中围绕特定点旋转
我在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
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.