Frage

Ich versuche, eine transparente Ebene zu ziehen (X [0..100], Y [0..100], Z = 0) in Java 3D, kann aber nicht herausfinden, wie. Ich habe auf der Tutorial-Seite geschaut und noch keine Beispielprogramme finden kann.

Ich bin versucht, eine „Ebene“ Objekt als Branch zu finden, um meine bestehenden Transform hinzuzufügen, aber es ist nicht so ein Flugzeug-Objekt; was soll ich verwenden? Und wie kann ich es transparent machen?

War es hilfreich?

Lösung

Dies ist ein Code-Snippet ich auf einem Histogramm verwendet - dies auf einer flachen Ebene funktionieren könnte

.
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);
}

Der Schlüssel ist die TransparencyAttributes, wenn ich mich richtig erinnere. Ich wünschte, ich könnte Ihnen mehr sagen, aber ich kann das jetzt nicht zu kompilieren (einige alte Bibliotheken fehlen, die nicht auf 3D beziehen).

Andere Tipps

Mit diesem Code Versuche ...

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.
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top