The problem is the lines:
u.getCanvas().getView().setBackClipDistance(100.);
u.getCanvas().getView().setFrontClipDistance(.000001);
Change your clipping planes so that the back/front ratio is smaller than 3000
(i.e. u.getCanvas().getView().setFrontClipDistance(0.1)) and your problem will
go away.
Doug Gehringer
Sun Microsystems
> Date: Fri, 19 Nov 1999 13:32:53 -0800
> From: Blaine Bell <[EMAIL PROTECTED]>
> Subject: [JAVA3D] Test Case!!! Re: Render Order
> To: [EMAIL PROTECTED]
>
> Here is a simple test case. Two cubes, the view that you see when the
> program is loaded shows the far cube rendered BEFORE the close one.
> Please let me know what is going on.
> There are two files: RenderProblem.java and cubes.wrl.
> Sorry for the weird manipulators.
>
> RenderProblem.java
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> import java.applet.Applet;
> import java.awt.*;
> import java.awt.event.*;
> import java.awt.GraphicsConfiguration;
> import com.sun.j3d.utils.applet.MainFrame;
> import com.sun.j3d.utils.geometry.ColorCube;
> import com.sun.j3d.utils.universe.*;
> import javax.media.j3d.*;
> import javax.vecmath.*;
> import java.io.*;
> import java.util.*;
> import javax.swing.*;
>
> import com.sun.j3d.loaders.ParsingErrorException;
> import com.sun.j3d.loaders.IncorrectFormatException;
> import com.sun.j3d.loaders.Scene;
>
> import com.sun.j3d.utils.behaviors.mouse.*;
> //import com.sun.j3d.loaders.*;
> import com.sun.j3d.loaders.vrml97.*;
> //import com.sun.j3d.loaders.vrml97.impl.*;
>
> // Java3dTree:
> // import the package
> // place the j3dtree.jar file in the classpath
> import com.tornadolabs.j3dtree.*;
>
> import java.net.*;
>
> public class RenderProblem extends JPanel {
> Canvas3D c;
> Java3dTree m_J3dTree = null;
>
> SimpleUniverse u;
> public BranchGroup createSceneGraph()
> {
> m_J3dTree = new Java3dTree();
>
> // Create the root of the branch graph
> BranchGroup objRoot = new BranchGroup();
>
> TransformGroup objTrans = new TransformGroup();
> objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
> objRoot.addChild(objTrans);
>
> VrmlLoader vrmlloader = new VrmlLoader(VrmlLoader.LOAD_ALL);
>
> Scene s = null;
> try {
> s = vrmlloader.load("cubes.wrl");
> BranchGroup sbg = s.getSceneGroup();
> Hashtable hash = s.getNamedObjects();
> sbg.setCapability(Group.ALLOW_CHILDREN_READ);
> objTrans.addChild(sbg);
> }
> catch (FileNotFoundException e) {
> System.err.println(e);
> System.exit(1);
> }
> catch (ParsingErrorException e) {
> System.err.println(e);
> System.exit(1);
> }
> catch (IncorrectFormatException e) {
> System.err.println(e);
> System.exit(1);
> }
> BoundingSphere bounds =
> new BoundingSphere(new Point3d(0.0,0.0,0.0), 500.0);
>
> TransformGroup btg =
u.getViewingPlatform().getViewPlatformTransform();
> MouseRotate behavior = new MouseRotate();//MouseBehavior.INVERT_INPUT);
> behavior.setTransformGroup(objTrans);
> objTrans.addChild(behavior);
> behavior.setSchedulingBounds(bounds);
>
> MouseZoom behavior2 = new MouseZoom(MouseBehavior.INVERT_INPUT);
> behavior2.setTransformGroup(btg);
>
> objTrans.addChild(behavior2);
> behavior2.setSchedulingBounds(bounds);
>
> MouseTranslate behavior3 = new MouseTranslate(MouseBehavior.INVERT_INPUT);
> behavior3.setTransformGroup(btg);
> objTrans.addChild(behavior3);
> behavior3.setSchedulingBounds(bounds);
>
> objRoot.setCapability(Group.ALLOW_CHILDREN_READ);
> m_J3dTree.recursiveApplyCapability( objRoot );
>
> Background background = new Background(1.f,1.f,1.f);
> background.setApplicationBounds(bounds);
> objRoot.addChild(background);
>
> DirectionalLight dl = new DirectionalLight(new Color3f(1.f,1.f,1.f),new
Vector3f(0.f,0.f,-1.f));
> dl.setInfluencingBounds(bounds);
> BranchGroup newbg = new BranchGroup();
> newbg.addChild(dl);
> u.getViewingPlatform().getViewPlatformTransform().addChild(newbg);
> objRoot.compile();
>
> return objRoot;
> }
>
> public RenderProblem(int w, int h) {
> setLayout(new BorderLayout());
> // BoxLayout boxlayout=new BoxLayout(this,BoxLayout.Y_AXIS);
> // setLayout(boxlayout);
> GraphicsConfiguration config =
> SimpleUniverse.getPreferredConfiguration();
>
> c = new Canvas3D(config);
> c.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
>
> add("Center",c);
> ViewingPlatform vp = new ViewingPlatform();
> vp.setCapability(Group.ALLOW_CHILDREN_READ);
> vp.getViewPlatformTransform().setCapability(Group.ALLOW_CHILDREN_READ);
> u = new SimpleUniverse(vp, new Viewer(c));
> u.getCanvas().getView().setBackClipDistance(100.);
> u.getCanvas().getView().setFrontClipDistance(.000001);
> Transform3D trans = new Transform3D();
> trans.lookAt(new Point3d(8.,1.,-1.),new Point3d(0.,0.,0.), new
Vector3d(0.,1.,0.));
> trans.invert();
> u.getViewingPlatform().getViewPlatformTransform().setTransform(trans);
> BranchGroup scene = createSceneGraph();
> u.addBranchGraph(scene);
> m_J3dTree.updateNodes( u );
> }
>
> public static void main(String[] args) {
> JPopupMenu.setDefaultLightWeightPopupEnabled(false);
> JFrame frame = new JFrame("Structure Diagram");
> frame.setSize(new Dimension(256, 512));
> final JPanel panel = new RenderProblem(256,512);
> frame.getContentPane().add(panel);
> frame.show();
> }
> }
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Cubes.wrl
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> #VRML V2.0 utf8
>
> WorldInfo {
> title "crazy_cube"
> }
>
> DEF BKG Background
> {
> skyColor [ 0.490 0.690 0.000 ]
> }
>
>
> Viewpoint {
> position 0 0 8
> orientation 0 1 0 0
> fieldOfView 0.4
> }
>
> Transform {
> children [
> DEF CUBE_TRANSFORM Transform {
> children [
> DEF blaine Shape {
> appearance Appearance {
> material DEF CUBE_COLOR Material {
> diffuseColor 1.0 0.0 0.0
> specularColor 0.3 0.3 0.3
>
> }
> }
> geometry Box {
> size 1.5 1.5 1.5
> }
> }
> ]
> }
> Transform {
> translation 5 0 0
> children [
> USE blaine
> ]
> }
> ]
> }
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> ===========================================================================
> 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".
===========================================================================
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".