Hi,
I'm having difficulties getting blending to work properly with the latest
Java3D. Points and lines that used to be blended when antialiasing was turned
on are no longer, so they just appear bigger and blockier.
I discovered that setting the PolygonAttributes of my Shape3D's can help fix
this problem.
I've attached a test program that will display a point antialiased with
blending. Now comment out the line that sets the polygon attributes (6th line
up from the bottom; "point.getAppearance().setPolygonAttributes(pga);") and run
it again. Under 1.2 you won't see any blending, just a blocky point.
I'm fairly new to Java3D so I'm wondering if I'm missing anything or if there is
some kind of trick to get blending working?
Thanks,
Jon McCall
import java.awt.*;
import java.awt.event.*;
import javax.media.j3d.*;
import javax.vecmath.*;
import com.sun.j3d.utils.geometry.*;
import com.sun.j3d.utils.universe.*;
public class example extends Frame {
private Canvas3D mCanvas3D = new Canvas3D(null);
private Dimension mCanvasSize;
public static void main(String args[]) {
new example();
}
public example() {
//create frame and canvas
super("Java 3D test");
setSize(400,300);
add("Center",mCanvas3D);
setVisible(true);
addWindowListener(new WindowAdapter()
{public void windowClosing(WindowEvent e)
{dispose(); System.exit(0);}
}
);
// building our scene graph
BranchGroup contentBranchGroup = constructContentBranch();
SimpleUniverse myUniverse = new SimpleUniverse(mCanvas3D);
myUniverse.getViewingPlatform().setNominalViewingTransform();
myUniverse.addBranchGraph(contentBranchGroup);
mCanvas3D.addComponentListener(new ComponentAdapter(){
public void componenetResized(ActionEvent e){
mCanvasSize = mCanvas3D.getSize();
}
});
}
/** specify the 3D graphics content to be rendered
**/
private BranchGroup constructContentBranch() {
BranchGroup contentBranchGroup = new BranchGroup();
// add points
contentBranchGroup.addChild(createPoint( 0.0f, 0.0f, 0.0f, 15f, true,
PolygonAttributes.POLYGON_POINT, 1.0f, 0.0f, 0.0f));
// contentBranchGroup.addChild(createPoint( -0.2f, 0.0f, 0.0f, 15f, true,
PolygonAttributes.POLYGON_LINE, 0.0f, 1.0f, 0.0f));
return(contentBranchGroup);
}
Shape3D createPoint( float x, float y, float z, float size, boolean
bAntiAlias, int nPolyMode,
float r, float g, float b) {
PointArray parr = new PointArray( 1, GeometryArray.COORDINATES);
float pt[] = new float[3];
pt[0] = x; pt[1] = y; pt[2] = z;
parr.setCoordinate( 0, pt);
Shape3D point = new Shape3D( parr, new Appearance() );
PolygonAttributes pga = new PolygonAttributes();
pga.setPolygonMode(nPolyMode);
point.getAppearance().setPolygonAttributes(pga);
point.getAppearance().setColoringAttributes(new ColoringAttributes());
point.getAppearance().getColoringAttributes().setColor(r, g, b);
point.getAppearance().setPointAttributes( new PointAttributes(size,
bAntiAlias) );
return point;
}
}
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".