我想在Java 3D中繪製透明平面(X [0..100],Y [0..100],Z = 0),但無法弄清楚。我查看了教程頁面,仍然找不到任何示例程序。如何在Java 3D中繪製透明平面?
我試圖找到一個「平面」對象作爲BranchGroup添加到我現有的TransformGroup,但沒有這樣一個平面對象;我應該使用什麼?我如何使它透明?
我想在Java 3D中繪製透明平面(X [0..100],Y [0..100],Z = 0),但無法弄清楚。我查看了教程頁面,仍然找不到任何示例程序。如何在Java 3D中繪製透明平面?
我試圖找到一個「平面」對象作爲BranchGroup添加到我現有的TransformGroup,但沒有這樣一個平面對象;我應該使用什麼?我如何使它透明?
這是我在直方圖上使用的一段代碼 - 這可能在平面上工作。
private static void createAppearances() {
normalAppearance = new Appearance();
normalAppearance.setMaterial(normalMaterial);
selectedAppearance = new Appearance();
selectedAppearance.setMaterial(selectedMaterial);
TransparencyAttributes ta = new TransparencyAttributes();
ta.setTransparencyMode (TransparencyAttributes.BLENDED);
ta.setTransparency (DEFAULT_HISTOGRAM_ALPHA);
normalAppearance.setTransparencyAttributes (ta);
selectedAppearance.setTransparencyAttributes(ta);
}
如果我沒記錯,關鍵是TransparencyAttributes
。我希望我能告訴你更多,但我現在無法得到它(缺少一些與3D無關的舊圖書館)。
試試這個代碼...
BranchGroup group = new BranchGroup(); //Content branch.
PolygonAttributes p = new PolygonAttributes(); //Not sure how to make it transparent/try code above.
Appearance planeAppearance = new Appearance();
planeAppearance.setPolygonAttributes (p);
Color3f planeColor = new Color3f (1.0f, 1.0f, 1.0f); //This makes it white.
ColoringAttributes planeCA = new ColoringAttributes (planeColor, 1);
planeAppearance.setColoringAttributes(planeCA);
QuadArray plane = new QuadArray (4, QuadArray.COORDINATES); //This makes the plane.
plane.setCoordinate(0, new Point3f(-5f, -5f, -15f)); //You specify your own cornerpoints...
plane.setCoordinate(1, new Point3f(5f, -5f, -15f));
plane.setCoordinate(2, new Point3f(5f, 5f, -15f));
plane.setCoordinate(3, new Point3f(-5f, 5f, -15f));
group.addChild(new Shape3D(plane, planeAppearance)); //Add plane to content branch.
如果它是透明的,你怎麼能肯定它的不存在? :-)對不起,沒有冒犯。 (你確定它被稱爲飛機?)提供更多信息。 – zoidbeck 2009-07-31 19:09:17