有什么方法可以改变立方体的颜色/外观。我尝试使用setAppearance()函数,但它没有任何变化。
快速了解我在做什么:
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);
然后在将立方体添加到变换组之前,我使用cube.setAppearance(polygon1Appearance);
稍后在鼠标事件中(使用pick canvas)cube.setAppearance(polygon1Appearance);没有做任何改变。
我想问一下,甚至可以改变ColorCube的外观(我的颜色)? 如果我能提供与该问题相关的其他信息,请告诉我。
答案 0 :(得分:2)
此类中的颜色为“硬编码”: https://github.com/hharrison/java3d-utils/blob/master/src/classes/share/com/sun/j3d/utils/geometry/ColorCube.java
您可以调用ColorCube.getGeometry(),将其转换为QuadArray并调用setColor或setColors()。