문제
Java 3D에서 투명한 평면 (x [0..100], y [0..100], z = 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와 관련이없는 오래된 라이브러리가 없습니다).
다른 팁
이 코드를 시도하십시오 ...
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.
제휴하지 않습니다 StackOverflow