Hi,
Can anyone please help. I am working on Java 3D Cylinders. I cannot color the different faces of the Cylinder differently. TOP, BOTTOM, BODY. All should have different colors. I tried it with different appearances but to no avail.
Cylinder c=new Cylinder();
BranchGroup contentBranch = new BranchGroup();
Transform3D rotateCube = new Transform3D();
Appearance ap = new Appearance();
Appearance ap1=new Appearance();
Appearance ap2=new Appearance();
ap.setColoringAttributes(new ColoringAttributes(new Color3f(Color.YELLOW), ColoringAttributes.SHADE_FLAT));
ap1.setColoringAttributes(new ColoringAttributes(new Color3f(Color.BLUE), ColoringAttributes.SHADE_FLAT));
ap2.setColoringAttributes(new ColoringAttributes(new Color3f(Color.GREEN), ColoringAttributes.SHADE_FLAT));
rotateCube.rotZ(12);
//rotateCube.set(new AxisAngle4d(0, 0, 0, Math.PI / 32.0));
TransformGroup rotationGroup = new TransformGroup(rotateCube);
contentBranch.addChild(rotationGroup);
//appearance.setColoringAttributes( colorAttributes );
Shape3D sh[]=new Shape3D[3];
sh[0]=c.getShape(Cylinder.TOP);
sh[1]=c.getShape(Cylinder.BODY);
sh[2]=c.getShape(Cylinder.BOTTOM);
sh[0].setAppearance(ap);
sh[1].setAppearance(ap1);
sh[2].setAppearance(ap2);
//Create the shape and add it to the branch
rotationGroup.addChild(c);
Thanks.