Question

Is there any way through which I can change the color/appearance of the cube. I tried to use the setAppearance() function but it makes no change.

A quick view of what I am doing:

Appearance polygon1Appearance = new Appearance();    
Color3f color1 = new Color3f (1.0f, 1.0f, 0.0f); 
ColoringAttributes color1ca = new ColoringAttributes (color1, 1);
Color3f color2 = new Color3f (1.0f, 0.0f, 0.0f); 
ColoringAttributes color2ca = new ColoringAttributes (color2, 1);

Then before adding the cubes to the transform group I use cube.setAppearance(polygon1Appearance);

Later in a mouse event(using pick canvas) cube.setAppearance(polygon1Appearance); does not make any change.

I wanted to ask if is it even possible to change appearance(color in my case) of a ColorCube? Please let me know if I can provide some other information related to the question.

Was it helpful?

Solution

The colors are "hardcoded" in this class: https://github.com/hharrison/java3d-utils/blob/master/src/classes/share/com/sun/j3d/utils/geometry/ColorCube.java

You can call ColorCube.getGeometry(), cast it as it is a QuadArray and call setColor or setColors().

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top