gpt4 book ai didi

javafx 3d Meshview旋转

转载 作者:行者123 更新时间:2023-12-01 10:16:40 25 4
gpt4 key购买 nike

我想旋转电机的轴,但未能获得所需的行为。

motor model

我得到的轮换就是这个。

motor model

这是我正在使用的代码,其中shaft是我想要旋转的MeshView:

    Model3D motor = new Model3D("motor.obj");

Map<String, MeshView> meshMapMotor = motor.getMapMeshes();
Pane gpMotor = new Pane();

for (Map.Entry<String, MeshView> entry : meshMapMotor.entrySet()) {
String key = entry.getKey();
MeshView value = entry.getValue();
Rotate rot = new Rotate(180);
rot.axisProperty().set(Rotate.Y_AXIS);
value.getTransforms().add(rot);
gpMotor.getChildren().add(value);
System.out.println("name: " + key);

if (key.equals("default (3)")) {
shaft = value;
}
}
gpMotor.setTranslateZ(7);
Rotate rot = new Rotate(1);
rot.axisProperty().set(new Point3D(0, 0, 1));
shaft.getTransforms().add(rot);

if (shaft != null) {
KeyFrame shaftFrame = new KeyFrame(Duration.millis(100), new KeyValue(rot.angleProperty(), 360));
motorRunning = new Timeline(shaftFrame);
motorRunning.setCycleCount(Timeline.INDEFINITE);
motorRunning.play();

}

最佳答案

   Rotate rot = new Rotate(1);
//rot.axisProperty().set(new Point3D(0, 0, 0));
rot.setPivotX(0);
rot.setPivotY(1.4);
rot.setPivotZ(0);

这成功地显示了我想要的效果。

关于javafx 3d Meshview旋转,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35852007/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com