How to create hollow cylinder and truncated cone with JavaFX?

前端 未结 3 708
既然无缘
既然无缘 2021-01-26 07:20

I\'m learning JavaFX 3D. So far I have not found a way how I can create the following objects:

  • Hollow cylinder
  • Truncated cone

Can someone p

3条回答
  •  说谎
    说谎 (楼主)
    2021-01-26 07:58

    I know it's an old question but I've been trying to solve similar problem so here is my solution for truncated cone:

    public class Cone extends Group{
    
    int rounds = 360;
    int r1 = 100;
    int r2 = 50;
    int h = 100;
    
    public Cone() {
        Group cone = new Group();
        PhongMaterial material = new PhongMaterial(Color.BLUE);
    
        float[] points = new float[rounds *12];
        float[] textCoords = {
                0.5f, 0,
                0, 1,
                1, 1
        };
        int[] faces = new int[rounds *12];
    
        for(int i= 0; i

    Hope this helps someone in the future!

提交回复
热议问题