在netbeans中,有一个名为CubeSystem3D的样本下的选项。我想知道是否有办法将所有立方体转换为球体,这样我最终可以创建一个太阳系类型的东西。我可以发送实际代码,如果你无法从netbeans中检索它,因为我不能把这篇文章的代码放在一起,因为它会说与文本相比会有太多的代码。
答案 0 :(得分:1)
在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);
}
}
你会得到这样的东西,