2 Replies Latest reply on Apr 29, 2010 10:50 PM by 794459

    Scene disappears

      I've loaded a 3DS file using [this loader|http://sourceforge.net/projects/java3dsloader/], and added it to the scene. I've added a MouseRotate and KeyNavigatorBehavior to test out everything, but when I start moving away from the scene, it begins to disappear. I've been trying different lights and haven't solved my problem. Is there a way to broaden the view or is there something that I am doing incorrectly?
      package building3d;
      import com.microcrowd.loader.java3d.max3ds.Loader3DS;
      import com.sun.j3d.loaders.Scene;
      import com.sun.j3d.utils.applet.MainFrame;
      import com.sun.j3d.utils.behaviors.keyboard.KeyNavigatorBehavior;
      import com.sun.j3d.utils.behaviors.mouse.MouseRotate;
      import com.sun.j3d.utils.universe.SimpleUniverse;
      import java.applet.Applet;
      import java.awt.BorderLayout;
      import java.awt.GraphicsConfiguration;
      import java.io.FileNotFoundException;
      import javax.media.j3d.BoundingSphere;
      import javax.media.j3d.BranchGroup;
      import javax.media.j3d.Canvas3D;
      import javax.media.j3d.TransformGroup;
      import javax.vecmath.Point3d;
      public class Building3D extends Applet {
          public Building3D() {
              setLayout(new BorderLayout());
              GraphicsConfiguration config =
              Canvas3D canvas3D = new Canvas3D(config);
              add("Center", canvas3D);
              SimpleUniverse simpleU = new SimpleUniverse(canvas3D);
          public BranchGroup createSceneGraph(SimpleUniverse su) {
              BranchGroup objRoot = new BranchGroup();
              TransformGroup vpTrans = su.getViewingPlatform().getViewPlatformTransform();
              KeyNavigatorBehavior keyNavBeh = new KeyNavigatorBehavior(vpTrans);
              keyNavBeh.setSchedulingBounds(new BoundingSphere(new Point3d(), 1000.0));
              MouseRotate mouseRotBeh = new MouseRotate(vpTrans);
              mouseRotBeh.setSchedulingBounds(new BoundingSphere(new Point3d(), 1000.0));
              return objRoot;
          public BranchGroup load3DS(String filename) {
              Loader3DS l3ds = new Loader3DS();
              Scene s = null;
              try {
                  s = l3ds.load(filename);
              } catch (FileNotFoundException e) {
              return s.getSceneGroup();
          public static void main(String[] args) {
              new MainFrame(new Building3D(), 256, 256);
      Also, I've had to use a 3DS loader because I haven't been able to load objects with textures using the ObjectFile class. Can it load textures, or am I doing something wrong on the model making end?

      Thank you.
        • 1. Re: Scene disappears
          I've figured out a way around it, by calling [View.setBackClipDistance(double)|http://java.sun.com/javase/technologies/desktop/java3d/forDevelopers/J3D_1_3_API/j3dapi/javax/media/j3d/View.html#setBackClipDistance(double)] from the Viewer of SimpleUniverse. If there is a better way around it, I'd like to hear it, thanks.
          • 2. Re: Scene disappears
            It's not a way around it. Clipping distances are a "feature." Such a feature prevents you from spending time drawing objects that are too far away to care about.