Can anyone help me ?
I have written a function to set all the shape3Ds of a BranchGroup transparent, but it don’t display transparent.
Here is the source code :
// Fonction activant ou désactivant l'affichage transparent
void setAffTrans(Group group,boolean param) {
TransparencyAttributes ta = new TransparencyAttributes();
if( param ) {
System.out.println("Met transparency à 0.5");
ta.setTransparency(0.5f);
}
else {
System.out.println("Met transparency à 0");
ta.setTransparency(0);
}
//ta.setTransparencyMode(TransparencyAttributes.BLENDED);
//ta.setMode(TransparencyAttributes.BLENDED);
Enumeration e = group.getAllChildren();
while(e.hasMoreElements()) {
Node node = (Node) e.nextElement();
if(node instanceof Group) {
System.out.println("Transparence : c'est un group");
setAffTrans((Group)node,param);
}
else {
if(node instanceof Shape3D) {
System.out.println("Transparence : c'est un Shape3D");
Shape3D shp = (Shape3D)node;
shp.getAppearance().setTransparencyAttributes(ta);
shp.getAppearance().setChanged(true);
}
}
}
};
