Well, from the picture it seems that both your cylinder and the cone are
somehow created in a wrong way. They are not transparent, but you are seing
the "inside" of them, not the "outside". Apparently, it looks like your
entire axis group labeled DN, although is pointing in the correct direction,
is mirrored against the plane defined by the other two axes, so the outside
is inside and vice-versa. The resulting pseudo-transparency is because of
the face culling. You can see the interior of both the cone and the
cylinder. Check your transforms!

Cheers,

Florin

-----Urspr�ngliche Nachricht-----
Von: Mingtian Ni [mailto:mni@;CSE.UNL.EDU]
Gesendet: Sonntag, 27. Oktober 2002 06:04
An: [EMAIL PROTECTED]
Betreff: [JAVA3D] Geometry looks transparent


Hi there,
I am developing an application with java3d.
It worked very good so far. However, I found that
whatever I created in the scene graph looked transparent.
An example is given in the attached image where the cone
is supposed to block the cylinder. But we can still see
the cylinder through the top cone.
What happens there? I didn't turn on the transparency attribute.
I has been struggling with this for quite a few days.
Some body can tell me?
Any response is appreciated! To make the question clearer, I attach
the code I am using here. Sorry for the long email.

Mingtian Ni

This function for creating the 3d axises is as follows:
   private TransformGroup createAxises(float width, float height, float
depth)
   {
           TransformGroup root = new TransformGroup();

           // Create appearence.
           Appearance app = new Appearance();
           Material mm = new Material();
           mm.setLightingEnable(true);
           mm.setAmbientColor(0.0f, 1.0f, 0.0f);
           mm.setDiffuseColor(0.0f, 1.0f, 0.0f);
           mm.setSpecularColor(0.0f, 1.0f, 0.0f);
           mm.setShininess(100.0f);
           app.setMaterial(mm);
           TransparencyAttributes ta = new TransparencyAttributes();
           app.setTransparencyAttributes(ta);
           RenderingAttributes ra = new RenderingAttributes();
           ra.setAlphaTestFunction(RenderingAttributes.GREATER);
           app.setRenderingAttributes(ra);

           Cylinder cy;
           Cone arrow;
           TransformGroup axisGroup, cyGroup, arrowGroup, labelGroup;
           Transform3D t;
           Shape3D sh;

           // Create y axis.
           axisGroup = new TransformGroup();

           cyGroup = new TransformGroup();
           t = new Transform3D();
           t.setTranslation(new Vector3f(0.0f, height/2.0f, 0.0f));
           cyGroup.setTransform(t);

           cy = new Cylinder(m_AXISRADIUS, height, app);
           cyGroup.addChild(cy);
           axisGroup.addChild(cyGroup);

           arrowGroup = new TransformGroup();
           arrowGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
           t = new Transform3D();
           t.setTranslation(new Vector3f(0.0f, height + m_ARROWLEN/2.0f,
0.0f));
           arrowGroup.setTransform(t);

           arrow = new Cone(m_ARROWRADIUS, m_ARROWLEN, app);
           arrowGroup.addChild(arrow);
           axisGroup.addChild(arrowGroup);

           labelGroup = new TransformGroup();
           labelGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
           t = new Transform3D();
           t.setTranslation(new Vector3f(0.0f, height + m_ARROWLEN,
0.0f));
           labelGroup.setTransform(t);

           sh = new Shape3D(getRaster("2nd Col"));
           labelGroup.addChild(sh);

           axisGroup.addChild(labelGroup);

           root.addChild(axisGroup);

           // Create x axis.
           axisGroup = new TransformGroup();
           axisGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
           t = new Transform3D();
           t.setRotation(new AxisAngle4d(0.0, 0.0, 1.0, -Math.PI/2.0));
           axisGroup.setTransform(t);

           cyGroup = new TransformGroup();
           t = new Transform3D();
           t.setTranslation(new Vector3f(0.0f, width/2.0f, 0.0f));
           cyGroup.setTransform(t);

           cy = new Cylinder(m_AXISRADIUS, width, app);
           cyGroup.addChild(cy);
           axisGroup.addChild(cyGroup);

           arrowGroup = new TransformGroup();
           arrowGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
           t = new Transform3D();
           t.setTranslation(new Vector3f(0.0f, width + m_ARROWLEN/2.0f,
0.0f));
           arrowGroup.setTransform(t);

           arrow = new Cone(m_ARROWRADIUS, m_ARROWLEN, app);
           arrowGroup.addChild(arrow);

           axisGroup.addChild(arrowGroup);

           labelGroup = new TransformGroup();
           labelGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
           t = new Transform3D();
           t.setTranslation(new Vector3f(0.0f, width + m_ARROWLEN, 0.0f));
           labelGroup.setTransform(t);

           sh = new Shape3D(getRaster("1st Col"));
           labelGroup.addChild(sh);

           axisGroup.addChild(labelGroup);

           root.addChild(axisGroup);

           // Create z axis.
           axisGroup = new TransformGroup();
           axisGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
           t = new Transform3D();
           t.setRotation(new AxisAngle4d(1.0, 0.0, 0.0, Math.PI/2.0));
           axisGroup.setTransform(t);

           cyGroup = new TransformGroup();
           t = new Transform3D();
           t.setTranslation(new Vector3f(0.0f, depth/2.0f, 0.0f));
           cyGroup.setTransform(t);

           cy = new Cylinder(m_AXISRADIUS, depth, app);
           cyGroup.addChild(cy);
           axisGroup.addChild(cyGroup);

           arrowGroup = new TransformGroup();
           arrowGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
           t = new Transform3D();
           t.setTranslation(new Vector3f(0.0f, depth + m_ARROWLEN/2.0f,
0.0f));
           arrowGroup.setTransform(t);

           arrow = new Cone(m_ARROWRADIUS, m_ARROWLEN, app);
           arrowGroup.addChild(arrow);

           axisGroup.addChild(arrowGroup);

           labelGroup = new TransformGroup();
           labelGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
           t = new Transform3D();
           t.setTranslation(new Vector3f(0.0f, depth + m_ARROWLEN, 0.0f));
           labelGroup.setTransform(t);

           sh = new Shape3D(getRaster("DN"));
           labelGroup.addChild(sh);

           axisGroup.addChild(labelGroup);

           root.addChild(axisGroup);

           // Create the view box.
           app = new Appearance();
           ColoringAttributes ca = new ColoringAttributes(1.0f, 1.0f,
1.0f, ColoringAttributes.SHADE_FLAT);
           app.setColoringAttributes(ca);
           ra = new RenderingAttributes();
           ra.setAlphaTestFunction(RenderingAttributes.GREATER);
           app.setRenderingAttributes(ra);

           float[] vts =
                        { 0.0f, 0.0f, 0.0f,
                          width, 0.0f, 0.0f,
                          width, height, 0.0f,
                          0.0f, height, 0.0f,
                          0.0f, 0.0f, depth,
                          width, 0.0f, depth,
                          width, height, depth,
                          0.0f, height, depth
                        };
                int[] indices =
                        { 0, 1, 2, 3, 0,
                          4, 5, 6, 7, 4,
                          0, 4,
                          1, 5,
                          2, 6,
                          3, 7
                        };
                int[] strips = {5, 5, 2, 2, 2, 2};

                IndexedLineStripArray box = new IndexedLineStripArray(8,

IndexedLineStripArray.COORDINATES|IndexedTriangleStripArray.BY_REFERENCE,
                           indices.length,
                           strips);
                box.setCoordRefFloat(vts);
                box.setCoordinateIndices(0, indices);

                sh = new Shape3D(box, app);
                root.addChild(sh);

                return root;
        }

The function for creating universe is as follows:
   private SimpleUniverse createUniverse()
   {
           // Create a Canvas3D.
           GraphicsConfigTemplate3D gct3D = new
GraphicsConfigTemplate3D();
           gct3D.setSceneAntialiasing(GraphicsConfigTemplate.PREFERRED);
           GraphicsConfiguration gc =
GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().g
etBestConfiguration(gct3D);
           Canvas3D canvas3D = new Canvas3D(gc);
           add(canvas3D, BorderLayout.CENTER);

           // Create a Universe.
           SimpleUniverse universe = new SimpleUniverse(canvas3D);

           // Set initial transform to the ViewingPlatform.
           ViewingPlatform viewingPlatform =
universe.getViewingPlatform();
           viewingPlatform.setNominalViewingTransform();

viewingPlatform.getViewPlatform().setViewAttachPolicy(View.NOMINAL_HEAD);
           Transform3D transform = new Transform3D();

viewingPlatform.getMultiTransformGroup().getTransformGroup(0).getTransform(t
ransform);
           Transform3D t = new Transform3D();
           t.setTranslation(new Vector3f(0.0f, 0.0f, m_viewWidth/2.0f));
           transform.mul(t);
           t.setRotation(new AxisAngle4d(1.0, 0.0, 0.0, Math.PI/4.0));
           transform.mul(t);

viewingPlatform.getMultiTransformGroup().getTransformGroup(0).setTransform(t
ransform);

           // add orbit behavior to ViewingPlatform
           m_orbitBehavior = new OrbitBehavior(canvas3D,
OrbitBehavior.REVERSE_ALL|OrbitBehavior.STOP_ZOOM);
           BoundingSphere bounds =  new BoundingSphere(new Point3d(0.0,
0.0, 0.0), Double.MAX_VALUE);
           m_orbitBehavior.setSchedulingBounds(bounds);
           m_orbitBehavior.setRotationCenter(new Point3d(m_viewWidth/2.0,
m_viewHeight/2.0, m_viewDepth/2.0));
           viewingPlatform.setViewPlatformBehavior(m_orbitBehavior);

           View view = universe.getViewer().getView();
           view.setFrontClipPolicy(View.VIRTUAL_EYE);
           view.setBackClipPolicy(View.VIRTUAL_EYE);
           view.setBackClipDistance(2 * (m_viewWidth + m_viewHeight +
m_viewDepth));
           view.setFrontClipDistance(1.0e-5);

           view.setWindowEyepointPolicy(View.RELATIVE_TO_WINDOW);
           view.setWindowResizePolicy(View.VIRTUAL_WORLD);
           view.setWindowMovementPolicy(View.PHYSICAL_WORLD);
//         view.setSceneAntialiasingEnable(true);
//         view.setLocalEyeLightingEnable(true);
//System.out.println("window resize policy = " +
universe.getViewer().getView().getWindowResizePolicy());
           return universe;
   }

==========================================================================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".

Reply via email to