0

我试图在 Java 3D 中绘制一个透明平面 (X[0..100],Y[0..100],Z=0),但不知道如何。我查看了教程页面,但仍然找不到任何示例程序。

我试图找到一个“平面”对象作为 BranchGroup 添加到我现有的 TransformGroup 中,但没有这样的平面对象;我应该用什么?以及如何使其透明?

4

2 回答 2

0

这是我在直方图上使用的一段代码——这可能适用于平面。

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 无关的旧库)。

于 2009-09-22T21:30:55.223 回答
0

试试这个代码...

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.
于 2011-11-01T10:10:41.040 回答