Face coloring in java3d

前端 未结 2 1822
Happy的楠姐
Happy的楠姐 2021-01-22 06:43

Using java3d, how can I colorize not on a per vertex base but on a per face base?

I try to learn about java3d but what Shape3d I did produce does not look as expected. I

2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-22 07:36

    You will have to draw each face separately, assigning a color to each. For example:

    Appearance polygon1Appearance = new Appearance();
    // set your color here
    
    QuadArray polygon1 = new QuadArray (4, QuadArray.COORDINATES);
    polygon1.setCoordinate(0, new Point3f (0f, 0f, 0f));
    polygon1.setCoordinate(1, new Point3f (2f, 0f, 0f));
    polygon1.setCoordinate(2, new Point3f (2f, 3f, 0f));
    polygon1.setCoordinate(3, new Point3f (0f, 3f, 0f));
    
    objRoot.addChild(new Shape3D(polygon1, polygon1Appearance));
    

提交回复
热议问题