简体   繁体   English

JavaFX- CubeSystem3D将立方体转换为球体

[英]JavaFX- CubeSystem3D Convert cubes to spheres

In netbeans, there is an option under samples called CubeSystem3D. 在netbeans中,在名为CubeSystem3D的样本下有一个选项。 I was wondering if there was a way to convert all of the cubes to spheres so I can eventually create a solar system type of thing. 我想知道是否有办法将所有立方体转换为球体,这样我最终可以创建一个太阳系类型的东西。 I can send the actual code if you are unable to retrieve it off netbeans because I can not put the code of this post as it says there will be too much code compared with text. 如果你无法从netbeans中检索它,我可以发送实际的代码因为我不能把这篇文章的代码放在一起,因为它说与文本相比会有太多的代码。

Use below Ellipse class instead of Cube class in that neabeans sample code. 在neabeans示例代码中使用Ellipse类而不是Cube类。

public class Ellipse extends Group {

    final Rotate rx = new Rotate(0, Rotate.X_AXIS);
    final Rotate ry = new Rotate(0, Rotate.Y_AXIS);
    final Rotate rz = new Rotate(0, Rotate.Z_AXIS);

    public Ellipse(double size, Color color, double shade) {
        PhongMaterial material = new PhongMaterial();
        material.setDiffuseColor(color);
        material.setSpecularColor(Color.BLACK);

        getTransforms().addAll(rz, ry, rx);
        Sphere s = new Sphere(size);
        s.setMaterial(material);
        getChildren().addAll(s);
    }
}

You will get something like this, 你会得到这样的东西,

在此输入图像描述

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

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