简体   繁体   English

javafx 3d Meshview旋转

[英]javafx 3d Meshview rotation

i want to rotate the shaft of the motor , but have not managed to get the desired behavior. 我想旋转电动机的轴,但尚未设法获得所需的性能。

motor model

the rotation i am getting is this one. 我得到的旋转就是这个。

motor model

this is the code i am using where shaft is the MeshView i want to rotate: 这是我使用的代码,其中是我要旋转的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);

this managed to show the effect i wanted. 这设法显示出我想要的效果。

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

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