改变形状Java3D的颜色
Changing color of shape Java3D
我只是想将我用 Java3D 创建的圆柱体的颜色改为黄色而不是标准 grey/black。我的代码似乎是正确的,但形状始终保持黑色,这里是:
protected BranchGroup createSphere(/*Color color*/) {
BranchGroup bg = new BranchGroup();
bg.setCapability(BranchGroup.ALLOW_DETACH);
Appearance app = new Appearance();
Color3f color = new Color3f(Color.yellow);
Color3f black = new Color3f(0.0f, 0.0f, 0.0f);
Color3f white = new Color3f(1.0f, 1.0f, 1.0f);
app.setMaterial(new Material(color, black, color, white, 70f));
bg.addChild(new com.sun.j3d.utils.geometry.Cylinder());
bg.setUserData("Sphere");
return bg;
}
你从来没有把你的外表应用到圆柱体上
Cylinder myCylinder = new com.sun.j3d.utils.geometry.Cylinder();
myCylinder.setAppearance(app);
bg.addChild(myCylinder);
我只是想将我用 Java3D 创建的圆柱体的颜色改为黄色而不是标准 grey/black。我的代码似乎是正确的,但形状始终保持黑色,这里是:
protected BranchGroup createSphere(/*Color color*/) {
BranchGroup bg = new BranchGroup();
bg.setCapability(BranchGroup.ALLOW_DETACH);
Appearance app = new Appearance();
Color3f color = new Color3f(Color.yellow);
Color3f black = new Color3f(0.0f, 0.0f, 0.0f);
Color3f white = new Color3f(1.0f, 1.0f, 1.0f);
app.setMaterial(new Material(color, black, color, white, 70f));
bg.addChild(new com.sun.j3d.utils.geometry.Cylinder());
bg.setUserData("Sphere");
return bg;
}
你从来没有把你的外表应用到圆柱体上
Cylinder myCylinder = new com.sun.j3d.utils.geometry.Cylinder();
myCylinder.setAppearance(app);
bg.addChild(myCylinder);