1
を回転させたとき、私はJavaFXの3dにはかなり新しいですし、私はこの単純な3Dの車を回転させたときに、私は遷移の間、これらの白線を見ることがなぜ私が疑問に思って。 私のコードを実行してください。シンプルで、私の問題が何であるか教えてください。 ありがとう!すべてPolygons
とRectangles
ためシンプルjavafx3d白線
public class myCar3DTry extends Application{
private double xCoor=100;
private double yCoor=100;
private int r=5;// radius
private Color color;
private RotateTransition rty;
private RotateTransition rtx;
public void start(Stage primaryStage){
Pane pane=new Pane();
Group group=new Group();
// Draw the car
Polygon polygon1 =
new Polygon(xCoor, yCoor - r, xCoor,
yCoor - 4 * r, xCoor + 2 * r, yCoor - 4 * r,
xCoor + 4 * r, yCoor - 6 * r, xCoor + 6 * r,
yCoor - 6 * r, xCoor + 8 * r, yCoor - 4 * r,
xCoor + 10 * r, yCoor - 4 * r, xCoor + 10 * r,
yCoor - r);
Polygon polygon2 =
new Polygon(xCoor, yCoor - r, xCoor,
yCoor - 4 * r, xCoor + 2 * r, yCoor - 4 * r,
xCoor + 4 * r, yCoor - 6 * r, xCoor + 6 * r,
yCoor - 6 * r, xCoor + 8 * r, yCoor - 4 * r,
xCoor + 10 * r, yCoor - 4 * r, xCoor + 10 * r,
yCoor - r);
polygon2.setTranslateZ(-30);
Rectangle rearBumper=new Rectangle(xCoor-15,yCoor-4*r,30,15);
rearBumper.setTranslateZ(-15);
rearBumper.setRotationAxis(Rotate.Y_AXIS);
rearBumper.setRotate(90);
rearBumper.setFill(Color.BLUE);
rearBumper.setStroke(Color.BLACK);
Rectangle frontBumper=new Rectangle((xCoor + 10 * r)-15,yCoor-4*r,30,15);
frontBumper.setTranslateZ(-15);
frontBumper.setRotationAxis(Rotate.Y_AXIS);
frontBumper.setRotate(90);
frontBumper.setFill(Color.BLUE);
frontBumper.setStroke(Color.BLACK);
Rectangle roof=new Rectangle(xCoor + 4 * r,(yCoor - 6 * r)-15,10,30);
roof.setTranslateZ(-15);
roof.setRotationAxis(Rotate.X_AXIS);
roof.setRotate(90);
roof.setFill(Color.BLUE);
roof.setStroke(Color.BLACK);
Rectangle rearSkirt=new Rectangle(xCoor,(yCoor - 4 * r)-15,10,30);
rearSkirt.setTranslateZ(-15);
rearSkirt.setRotationAxis(Rotate.X_AXIS);
rearSkirt.setRotate(90);
rearSkirt.setFill(Color.BLUE);
rearSkirt.setStroke(Color.BLACK);
Rectangle frontSkirt=new Rectangle(xCoor + 8 * r,(yCoor - 4 * r)-15,10,30);
frontSkirt.setTranslateZ(-15);
frontSkirt.setRotationAxis(Rotate.X_AXIS);
frontSkirt.setRotate(90);
frontSkirt.setFill(Color.BLUE);
frontSkirt.setStroke(Color.BLACK);
Rectangle bottom=new Rectangle(xCoor,(yCoor - r)-15,(xCoor + 10 * r)-xCoor,30);
bottom.setTranslateZ(-15);
bottom.setRotationAxis(Rotate.X_AXIS);
bottom.setRotate(90);
bottom.setFill(Color.BLUE);
bottom.setStroke(Color.BLACK);
Rectangle leftTriangle=new Rectangle((xCoor + 2 * r),(yCoor - 6 * r),
30,Math.sqrt(Math.pow((xCoor + 4 * r)-(xCoor + 2 * r),2)+Math.pow((yCoor - 4 * r)-(yCoor - 6 * r),2)));
leftTriangle.setTranslateZ(-10);
Rotate leftTriangleRZ=new Rotate(45,(xCoor + 4 * r),(yCoor - 6 * r),0, Rotate.Z_AXIS);
Rotate leftTriangleRY=new Rotate(90,(xCoor + 4 * r),(yCoor - 6 * r),0,Rotate.Y_AXIS);
leftTriangle.getTransforms().addAll(leftTriangleRZ,leftTriangleRY);
leftTriangle.setFill(Color.BLACK);
leftTriangle.setStroke(Color.BLACK);
Rectangle rightTriangle=new Rectangle((xCoor + 4 * r),(yCoor - 6 * r),
30,Math.sqrt(Math.pow((xCoor + 4 * r)-(xCoor + 2 * r),2)+Math.pow((yCoor - 4 * r)-(yCoor - 6 * r),2)));
rightTriangle.setTranslateZ(-10);
Rotate rightTriangleRZ=new Rotate(-45,(xCoor + 6 * r),(yCoor - 6 * r),0, Rotate.Z_AXIS);
Rotate rightTriangleRY=new Rotate(90,(xCoor + 6 * r),(yCoor - 6 * r),0,Rotate.Y_AXIS);
rightTriangle.getTransforms().addAll(rightTriangleRZ,rightTriangleRY);
rightTriangle.setFill(Color.BLACK);
rightTriangle.setStroke(Color.BLACK);
polygon1.setFill(Color.BLUE);
polygon1.setStroke(Color.BLACK);
polygon2.setFill(Color.BLUE);
polygon2.setStroke(Color.BLACK);
group.getChildren().clear();
group.getChildren().addAll(polygon1,polygon2,rearBumper,frontBumper,roof,rearSkirt,frontSkirt,bottom,leftTriangle,rightTriangle);
pane.getChildren().clear();
pane.getChildren().add(group);
rty=new RotateTransition(Duration.seconds(7),group);
rty.setCycleCount(Animation.INDEFINITE);
rty.setFromAngle(0);
rty.setToAngle(360);
rty.setNode(group);
rty.setAxis(Rotate.Y_AXIS);
rty.setAutoReverse(false);
//rty.play();
rtx=new RotateTransition(Duration.seconds(7),group);
rtx.setCycleCount(Animation.INDEFINITE);
rtx.setFromAngle(0);
rtx.setToAngle(360);
rtx.setNode(group);
rtx.setAxis(Rotate.X_AXIS);
rtx.setAutoReverse(false);
rtx.play();
Scene scene=new Scene(pane,500,500,true,SceneAntialiasing.BALANCED);
primaryStage.setScene(scene);
primaryStage.show();
primaryStage.setAlwaysOnTop(true);
}
public static void main(String[] args) {
launch(args);
}
ありがとうalot man :-) – demianr