I am having a problem with transparency and object the intersect.
http://www.cs.cmu.edu/~jaharris/j3d/transparency.html has some images.
If I make 3 spheres and line them up so each intersect the previous one. Then change
the transparency of the front most sphere(blue)assuming there are on the z axis. I
can just see the other 2 spheres fine. Now if I change the 2nd sphere's(red)
transparency from 0 to .01, then the part of the sphere that was covered by sphere 1
has disappeared. But, if I rotate it, then the 2nd sphere is rendered like I exepect.
I also use an OrderedGroup to assure that the spheres are drawn in the correct
order. If I do not, the transparency problem is ok, but the z buffer is incorrect. I
also tried using u.getViewer().getView().setDepthBufferFreezeTransparent(false), but
this did not accomplish what I wanted.
I use NT 4 with FireGL pro 1000 8Mb, jdk1.2.2
I am doing something wrong or is this a bug?
Code:
public class Test extends Applet {
.
.
.
public TransformGroup createSceneGraph() {
// Create the root of the branch graph
TransformGroup objRoot = new TransformGroup();
objRoot.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
objRoot.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
OrderedGroup objOG = new OrderedGroup();
Sphere s1 = new Sphere(.5f);
s1.setAppearance(S1Appear);
Sphere s2 = new Sphere(.5f);
s2.setAppearance(s2Appear);
Sphere s3 = new Sphere(.5f);
s3.setAppearance(s3Appear);
objOG.addChild(s1);
Transform3D t3d = new Transform3D();
t3d.set(new Vector3f(0f,0f,.1f));
TransformGroup tg = new TransformGroup(t3d);
tg.addChild(s2);
objOG.addChild(tg);
t3d = new Transform3D();
t3d.set(new Vector3f(0f,0f,.2f));
TransformGroup tg2 = new TransformGroup(t3d);
tg2.addChild(s3);
objOG.addChild(tg2);
objRoot.addChild(objOG);
return objRoot;
}
public Test() {
Material greenm = new Material();
greenm.setDiffuseColor(GREEN);
Material redm = new Material();
redm.setDiffuseColor(RED);
Material bluem = new Material();
bluem.setDiffuseColor(BLUE);
s1Appear = new Appearance();
s1Appear.setMaterial(greenm);
S1Appear.setCapability(Appearance.ALLOW_TRANSPARENCY_ATTRIBUTES_READ);
TransparencyAttributes ta = new
TransparencyAttributes(TransparencyAttributes.NICEST,0f);
ta.setCapability(TransparencyAttributes.ALLOW_VALUE_WRITE);
s1Appear.setTransparencyAttributes(ta);
s2Appear = new Appearance();
s2Appear.setMaterial(red);
ta = new TransparencyAttributes(TransparencyAttributes.NICEST,0f);
ta.setCapability(TransparencyAttributes.ALLOW_VALUE_WRITE);
s2Appear.setTransparencyAttributes(ta);
s2Appear.setCapability(Appearance.ALLOW_TRANSPARENCY_ATTRIBUTES_READ);
s3Appear = new Appearance();
s3Appear.setMaterial(bluem);
s3Appear.setCapability(Appearance.ALLOW_TRANSPARENCY_ATTRIBUTES_READ);
ta = new TransparencyAttributes(TransparencyAttributes.NICEST,0f);
ta.setCapability(TransparencyAttributes.ALLOW_VALUE_WRITE);
s3Appear.setTransparencyAttributes(ta);
setLayout(new BorderLayout());
GraphicsConfiguration config =
SimpleUniverse.getPreferredConfiguration();
Canvas3D c = new Canvas3D(config);
add("Center", c);
// Create a simple scene and attach it to the virtual universe
TransformGroup tg = createSceneGraph();
BranchGroup scene = new BranchGroup();
scene.addChild(tg);
SimpleUniverse u = new SimpleUniverse(c);
u.getViewingPlatform().setNominalViewingTransform();
.
.
.
.
.
.
BoundingSphere lightBounds =
new BoundingSphere(new Point3d(), Double.MAX_VALUE);
ambLight = new AmbientLight(true, new Color3f(1.0f, 1.0f, 1.0f));
ambLight.setInfluencingBounds(lightBounds);
ambLight.setCapability(Light.ALLOW_STATE_WRITE);
scene.addChild(ambLight);
headLight = new DirectionalLight();
headLight.setCapability(Light.ALLOW_STATE_WRITE);
headLight.setInfluencingBounds(lightBounds);
scene.addChild(headLight);
u.addBranchGraph(scene);
}
//
// The following allows HelloUniverse to be run as an application
// as well as an applet
//
public static void main(String[] args) {
new MainFrame(new Test(), 256, 256);
}
}
===========================================================================
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".