Starfire 3DS Loader

Hi, can someone tell me the clear steps for install "StarfireExt.jar"?
I have copy it to both C:\j2sdk1.4.1\jre\lib\ext and C:\Program Files\Java\j2re1.4.1\lib\ext. Is it something missing?
The other problem is when I run the program by using Loader3DS, the error message is "Not Supported 3DS", when I change to Inspector3DS, the error message is "java.lang.NoClassDefFoundError".
Please help me! Thanks!

There is a txt file that comes with it that has instructions on where to place the jar.
import com.mnstarfire.loaders3d.Inspector3DS;
public TransformGroup loadTestObject() {
          if(DEBUG) System.out.print("Import 3ds object...");
          Inspector3DS loader = new Inspector3DS("lyrax.3ds");
          loader.parseIt(); // process the file
          loader.setDetail(9);
          loader.setLogging(true);
          loader.setTextureLightingOn();
          //loader.setCreaseAngle(1.0);
          TransformGroup theModel = loader.getModel();
          theModel.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
          if(DEBUG) System.out.println("done.");
          return theModel;
     }The import obviously at the top and the DEBUG is my own code.
HTH
M

Similar Messages

  • View Problems with Starfire 3ds Loader

    Hi all !!
    I am new on developing 3D Applications with Java (only tryed several DirectX Programing with C).
    I've studied the SUN Tutorial of 3D Programming (first 3 Chapters) and now started to load a complex 3ds Object. I've tested several loaders and now the Starfire loader looks like working, because there is no exception during the loading process.
    But the model isn't shown. I've tryed several 3ds models with differend sizes, but nothing happend i only got the black Applet view. I've tryed both loading Objects types, but i still got the same problem.
    I thougt there is a problem with the view distance. Is there a easy way to change the translation like in C? Or is there an other failure I've make? Can someone help?
    Thanks in advanced !!
    Christian

    Christian,
    we have made very good experience with the starfire 3ds loader. I think there is no better one at this point of time.
    The problem might be one of the one described below, distance, size and lights.
    I can offer you to use AniFun3 (http://www.anifun3.de) at your first steps. It is a visual interface to the 3D api and contains the Starfire3DS loader. You can easy change the size, the point of view, lights etc.. on the fly. The graphical user interface is similar to the api. Therefore after successfully importing a file, you can continue either with AniFun3, or manually transfer the values to your source code.
    Regards,
    Oliver

  • Why can I load only 8 models into a program

    Hi, i have a java progrem , and i work with NCSA portfolio , or Starfire 3DSLoader (i tried them both)
    and the loader , lets me load every time only 8 models simultanitly, when i load more than 8 , it just doesn't show them , until i remove other loaded models (from the 8 loaded)
    what can i do to fix it?
    plz help

    It's like this - I wanted to let the user choose a model , from a variety of 20 models ,
    so i craeted a jframe , and within i added 20 jpanels , and each jpanel , had a model loaded into him (with Canvas3D...)... Now , when i run the program , only 8 models are shown in their jpanels , and all the other jpanels are blacked out (the model is there , but just doesn't show)...
    Now when I remove a working jpanel in runtime (that has a model in it ) , then one blacked jpanel, is now working, and the model inside is shown...
    that's how i figured out, he let me load only 8 models each time....
    How can i solve tshi problem????????
    (I tried to work both with Starfire 3DS loader , and with NCSA porfolio , and in each of the the problem occured)

  • Beating my brains out: How do you move a 3DS object in order to see it?

    Can someone plese explain this to me in nice detailed steps. I just can't seem to get it to work.
    OK,
    I can load (using the StarFire 3DS loader) 3ds images just fine like this:
    Scene theScene = null;
    Loader3DS loader = new Loader3DS();
    theScene = loader.load("D:\\My3dsFile.3ds");
    Some .3ds files I can see just fine. Others look like they need to be scaled/translated. I noticed this by creating a ScaleInterpolator and applying it to the root BranchGroup on one of the .3ds images I could not see like this:
    TransformGroup objTrans = new TransformGroup( );
    objTrans.setCapability( TransformGroup.ALLOW_TRANSFORM_WRITE );
    Transform3D zAxis = new Transform3D( );
    zAxis.set(new Vector3f(0.0f, 0.0f, 10.0f));
    Alpha xAlpha = new Alpha( -1, //Loop
    Alpha.DECREASING_ENABLE |
    Alpha.INCREASING_ENABLE,
    1000, //trigger time
    1000, //phase delay duration
    5000, //increasing alpha duration
    1000, //increaing alpha ramp duration
    1000, //alpha at one duration
    1000, //decreasing alpha duration
    2000, //decreasing alpha ramp duration
    1000 ); //alpha at zero duration
    ScaleInterpolator scale = new ScaleInterpolator(xAlpha,
    objTrans,
    zAxis,
    -6.0f,
    6.0f);
    scale.setSchedulingBounds( getBoundingSphere( ) );
    objTrans.addChild(scale);
    bgRoot.addChild( objTrans );
    objTrans.addChild(theScene.getSceneGroup()); //theScene = .3ds scene
    Doing this, I can catch a glimpse of the .3ds image every now and then.
    How in the world can you scale a scene and move it to the 0,0,0 position?
    All I want to do is load a stinking .3ds image (any .3ds image) and be able to view it! I think if I could scale it and move it to 0, 0, 0 then I should be able to see them.
    Please help.
    Thanks.

    Have you tried to scale the object uniformly at creation, before putting it in a scenegraph? this way at runtime you don't need to worry about objects being to big at runtime...
    for the uniform scale:
    Transform3D transform = new Transform3D();
    transform.setScale(0.02); //try different values here
    3ds_object_transform_group.setTransform(transform);
    Another thing you could do is to use a 3D modelling program (like 3DS)
    and scale the object very very small..
    I had the same problem before, hope this helps

  • Java 3D Application With a Loaded Maya Scene

    How Loaded Maya Scene in to Java 3D Application ?
    when I run the application, I get "com.sun.j3d.loaders.ParsingErrorException: Unrecognized token, line 1" .
    Please help me.
    import com.sun.j3d.loaders.objectfile.ObjectFile;
    import com.sun.j3d.loaders.ParsingErrorException;
    import com.sun.j3d.loaders.IncorrectFormatException;
    import com.sun.j3d.loaders.Scene;
    import java.applet.Applet;
    import java.awt.*;
    import com.sun.j3d.utils.applet.MainFrame;
    import com.sun.j3d.utils.universe.*;
    import com.sun.j3d.utils.geometry.ColorCube;
    import javax.media.j3d.*;
    import javax.vecmath.*;
    import java.io.*;
    public class A extends Applet{
    public A() {
         setLayout(new BorderLayout());
    GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
    Canvas3D canvas3D = new Canvas3D(config);
    add("Center", canvas3D);
    BranchGroup scene = createSceneGraph();
    scene.compile();
    // SimpleUniverse is a Convenience Utility class
    SimpleUniverse simpleU = new SimpleUniverse(canvas3D);
    // This moves the ViewPlatform back a bit so the
    // objects in the scene can be viewed.
    simpleU.getViewingPlatform().setNominalViewingTransform();
    simpleU.addBranchGraph(scene);
    } // end of ObjLoad (constructor)
         public BranchGroup createSceneGraph()
    // Create the root of the branch graph
    BranchGroup objRoot = new BranchGroup();
    String filename = "D:/Maya/13.mb";
    ObjectFile f = new ObjectFile();
    Scene s = null;
    try {
    s = f.load(filename);
    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);
    objRoot.addChild(s.getSceneGroup());
    return objRoot;
    } // end of createSceneGraph method
    * @param args the command line arguments
    public static void main(String[] args) {
    // TODO code application logic here
    Frame frame = new MainFrame(new A(), 500, 500);
    }

    My guess is that you are using the ObjectFile loader, which is for a (don't remember which application) object (.obj) file, rather than using a 3ds loader, which would be for loading a .3ds file.
    You might want to go to this page: http://www.j3d.org/utilities/loaders.html and download the correct loader.

  • Java 3d ...cannot import a 3ds file ..only works with a .obj

    Here is a world i have written in java 3d
    I can import a .obj file into this world but i want to import a file called Flipp.3ds but it keeps giving me an error
    Here is the complete class ..... Can anyone help
    Im pretty new to java 3d
            import java.io.*;
            import com.sun.j3d.utils.behaviors.vp.*;
            import java.net.URL;
            import java.net.MalformedURLException;
            import javax.media.j3d.*;
            import javax.vecmath.*;
            import java.awt.*;
            import java.awt.event.*;
            import com.sun.j3d.utils.behaviors.keyboard.*;
            import com.sun.j3d.utils.geometry.*;
            import java.applet.Applet;
            import java.awt.BorderLayout;
            import java.awt.event.*;
            import java.awt.GraphicsConfiguration;
            import com.sun.j3d.utils.applet.MainFrame;
            import com.sun.j3d.utils.geometry.*;
            import com.sun.j3d.utils.universe.*;
            import com.sun.j3d.utils.image.*;
            import com.sun.j3d.loaders.objectfile.ObjectFile;
            import com.sun.j3d.loaders.ParsingErrorException;
            import com.sun.j3d.loaders.IncorrectFormatException;
            import com.sun.j3d.loaders.Scene;
            import javax.vecmath.*;
            public class Assign2 extends Frame implements ActionListener {
                    protected Canvas3D myCanvas3D = new Canvas3D(null);
                    protected Button exitBt = new Button("Exit");
                    protected BoundingSphere bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0);
                    private boolean spin = true;
                    private double creaseAngle = 60.0;
                    private String filename;
            // Lights
                   * This adds a continuous background sound to the branch group.
                   * @param b BranchGroup to add the sound to.
                   * @param soundFile String that is the name of the sound file.
                  protected void addBackgroundSound (BranchGroup b,String soundFile)
                            //Create a media container to load the file
                            MediaContainer droneContainer = new MediaContainer(soundFile);
                            //Create the background sound from the media container
                            BackgroundSound drone = new BackgroundSound(droneContainer,1.0f);
                            //Activate the sound
                            drone.setSchedulingBounds(bounds);
                            drone.setEnable(true);
                            //Set the sound to loop forever
                            drone.setLoop(BackgroundSound.INFINITE_LOOPS);
                            //Add it to the group
                            b.addChild(drone);
                  protected void addLights(BranchGroup b)
                            Transform3D dirLightsXfm = new Transform3D();
                            dirLightsXfm.set(new Vector3d(-1.5,0.0,0.0));
                            TransformGroup dirLights = new TransformGroup(dirLightsXfm);
                            dirLights.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
                            dirLights.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
                            // Create a bounds for the background and lights
                            // Set up the global lights
                            Color3f ambLightColour = new Color3f(1.0f, 1.0f, 0.4f);
                            AmbientLight ambLight = new AmbientLight(ambLightColour);
                            ambLight.setInfluencingBounds(bounds);
                            Color3f dirLightColour = new Color3f(0.0f, 1.0f, 0.0f);
                            Vector3f dirLightDir  = new Vector3f(-1.0f, -1.0f, -1.0f);
                            DirectionalLight dirLight = new DirectionalLight(dirLightColour, dirLightDir);
                            dirLight.setInfluencingBounds(bounds);
                            dirLights.addChild(ambLight);
                            dirLights.addChild(dirLight);
                            b.addChild(dirLights);
                            if (spin)
                                    Transform3D yAxis = new Transform3D();
                                    Alpha rotationAlpha = new Alpha(-1, Alpha.INCREASING_ENABLE,
                                                                                      0, 0,
                                                                                      1500, 0, 0,
                                                                                      0, 0, 0);
                                    //attach to lights
                                    RotationInterpolator rotator =
                                         new RotationInterpolator(rotationAlpha, dirLights, yAxis,
                                                                                   0.0f, (float) Math.PI*2.0f);
                                    rotator.setSchedulingBounds(bounds);
                                    b.addChild(rotator);
                  // Content Branch
                  protected BranchGroup buildContentBranch()
                            //Create the appearance for the cube
                            Appearance app1 = new Appearance();
                            Appearance app2 = new Appearance();
                            Color3f ambientColour1 = new Color3f(0.0f,0.0f,1.0f);
                            Color3f ambientColour2 = new Color3f(0.0f,0.0f,0.0f);
                            Color3f emissiveColour = new Color3f(0.0f,0.0f,0.0f);
                            Color3f specularColour = new Color3f(1.0f,1.0f,1.0f);
                            Color3f diffuseColour1 = new Color3f(1.0f,1.0f,0.0f);
                            Color3f diffuseColour2 = new Color3f(1.0f,1.0f,0.0f);
                            float shininess = 10.0f;
                            app1.setMaterial(new Material(ambientColour1,emissiveColour,diffuseColour1,specularColour,shininess));
                            app2.setMaterial(new Material(ambientColour2, emissiveColour,diffuseColour2,specularColour,shininess));
                            //import the object...
                            filename = "Flipp.max";
                            int flags = ObjectFile.RESIZE;
                            ObjectFile f = new ObjectFile(flags,
                                      (float)(creaseAngle * Math.PI / 180.0));
                            Scene s = null;
                                    try
                                            s = f.load(filename);
                                    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);
                            BranchGroup contentBranch = new BranchGroup();
                            addLights(contentBranch);
                            //Position the Woman
                            Transform3D groupXfm = new Transform3D();
                            groupXfm.set(new Vector3d(0.0,0.0,0.0));
                            TransformGroup group = new TransformGroup(groupXfm);
                            group.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
                            group.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
                            // Adding to the Content Branch
                            group.addChild(s.getSceneGroup());
                            contentBranch.addChild(group);
                            BoundingSphere movingBounds = new BoundingSphere(new Point3d(0.0,0.0,0.0), 300.0);
                            BoundingLeaf boundLeaf = new BoundingLeaf(movingBounds);
                            KeyNavigatorBehavior keyNav = new KeyNavigatorBehavior(group);
                            keyNav.setSchedulingBounds(movingBounds);
                            group.addChild(keyNav);
                            Transform3D floorXfm = new Transform3D();
                            floorXfm.set(new Vector3d(0.0,-1.5,-1.4));
                            TransformGroup floor = new TransformGroup(floorXfm);
                            floor.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
                            floor.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
                            Box theFloor = new Box(3.0f,0.0f,3.0f,app2);
                            floor.addChild(theFloor);
                            contentBranch.addChild(floor);
                            return contentBranch;
                    // View Branch
                    protected BranchGroup buildViewBranch(Canvas3D c)
                            BranchGroup viewBranch = new BranchGroup();
                            Transform3D viewXfm = new Transform3D();
                            viewXfm.set(new Vector3f(0.0f,0.0f,10.0f));
                            TransformGroup viewXfmGroup = new TransformGroup(viewXfm);
                            viewXfmGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
                            viewXfmGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
                            BoundingSphere movingBounds = new BoundingSphere(new Point3d(0.0,0.0,0.0), 300.0);
                            BoundingLeaf boundLeaf = new BoundingLeaf(movingBounds);
                            ViewPlatform myViewPlatform = new ViewPlatform();
                            viewXfmGroup.addChild(boundLeaf);
                            PhysicalBody myBody = new PhysicalBody();
                            PhysicalEnvironment myEnvironment = new PhysicalEnvironment();
                            viewXfmGroup.addChild(myViewPlatform);
                            viewBranch.addChild(viewXfmGroup);
                            View myView = new View();
                            myView.addCanvas3D(c);
                            myView.attachViewPlatform(myViewPlatform);
                            myView.setPhysicalBody(myBody);
                            myView.setPhysicalEnvironment(myEnvironment);
                            return viewBranch;
                    // Exit Button - dispose of system
                    public void actionPerformed(ActionEvent e)
                                    dispose();
                                    System.exit(0);
                    public Assign2()
                            VirtualUniverse myUniverse = new VirtualUniverse();
                            Locale myLocale = new Locale(myUniverse);
                            myLocale.addBranchGraph(buildViewBranch(myCanvas3D));
                            myLocale.addBranchGraph(buildContentBranch());
                            setTitle("John (Sean) Gleeson 100437719");
                            setSize(600,600);
                            setLayout(new BorderLayout());
                            Panel bottom = new Panel();
                            bottom.add(exitBt);
                            add(BorderLayout.CENTER, myCanvas3D);
                            add(BorderLayout.SOUTH, bottom);
                            exitBt.addActionListener(this);
                            setVisible(true);
                    public static void main(String[] args)
                              Assign2 demo = new Assign2();
            Thanks,
    Sean

    My guess is that you are using the ObjectFile loader, which is for a (don't remember which application) object (.obj) file, rather than using a 3ds loader, which would be for loading a .3ds file.
    You might want to go to this page: http://www.j3d.org/utilities/loaders.html and download the correct loader.

  • Loading models in JOGL

    Are there any complete APIs for loading 3DS models in JOGL? I can't seem to find this anywhere? If not 3DS, is it possible to load any other type of models?

    JOGL is just an OpenGL wrapper. Basically it gives access to OpenGL API methods and fields. You need some kind of a structure above JOGL in order to do more advanced stuff. There are several 3D engines using JOGL to access the OpenGL API. These engines normally come with loaders for different file formats. I don't know all Java 3D-engines, but you could try using AgentFX (http://www.agency9.se/agentfx). It doesn't have a 3DS-loader, but an OBJ loader. Almost all 3D programs can save to OBJ format. You can use Milkshape 3D (http://www.swissquake.ch/chumbalum-soft) or some other program to convert your 3DS file into OBJ.

  • 3D studio max export type

    which export type in 3Ds max 4 can be used in conjunction with java?
    i know this is said in one tutorail, but currently adobe isnt compactible with my O/S so i need someone to help.
    thanks in advance,
    pop n fresh

    i agree with OFH Starfire research loader is quite good. unfortunately it doesn't support some surface/texture features (reflection mapping for exemple) that can be implemented in Java3D and the source code is not given.
    GnG

  • How to use utility jars without -cp

    I am trying to use a 3d loader from starfire research to load .3ds files. I currently have the jar in /lib/ext and netbeans sees this and uses it, and everything works perfectly fine. When I use this on other machines for a test, I put the 3d loader jar in to the client /lib/ext folder, but my program cannot find it. Any suggestions on where to put this jar without me having to use -cp every time?
    Thanks in advance.

    I'll try to explain better. The 3DS Loader I'm using is called StarfireExt.jar. I have two computers that I am using right now: a custom built desktop with Windows XP 32 bit that runs Netbeans, and a Dell laptop that I'm using to test my software. On the desktop, I have JDK1.6u18 with Java3D also installed. StarfireExt.jar is in my C:/Program Files/Java/jdk1.6.0_18/lib/ext/ folder, and Netbeans allows me to import and use StarfireExt. On the laptop, I have JRE1.6u20, Java3D, and StarfireExt in the lib/ext/ folder. When I'm on the desktop in Netbeans and press F6, it runs fine and the 3DS files load and are displayed. When I clean and build the JAR and move all of the models and JAR to my laptop, the program seems not able to find StarfireExt. The models don't load; no error windows that I've coded pop up.
    P.S. I'm sorry if I'm kind of a Java newbie. I don't know all those awesome developer tricks yet.

  • Weird problem with bounds in collsion

    the code
    import java.applet.Applet;
    import java.awt.BorderLayout;
    import java.awt.Font;
    import java.awt.Frame;
    import java.awt.Window;
    import java.awt.event.*;
    import java.awt.GraphicsConfiguration;
    import com.mnstarfire.loaders3d.Inspector3DS;
    import com.sun.j3d.utils.applet.MainFrame;
    import com.sun.j3d.utils.universe.*;
    import com.sun.j3d.utils.geometry.*;
    import javax.imageio.ImageIO;
    import javax.media.j3d.*;
    import javax.vecmath.*;
    import java.awt.event.*;
    import java.awt.image.BufferedImage;
    import java.awt.AWTEvent;
    import java.net.URL;
    import java.util.Enumeration;
    import com.sun.j3d.utils.behaviors.keyboard.*;
    public class Tlo3D extends Applet
         public Tlo3D()
           setLayout(new BorderLayout());
           GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
           Canvas3D canvas3D = new Canvas3D(config);
           add(canvas3D);
           SimpleUniverse simpleUniverse = new SimpleUniverse(canvas3D);
           BranchGroup scene = createSceneGraph(simpleUniverse);
           simpleUniverse.getViewingPlatform().setNominalViewingTransform();
           simpleUniverse.addBranchGraph(scene);
           canvas3D.getView().setBackClipDistance(50);
         public class Podloga extends Shape3D
              Geometry geometria;
             Appearance wyglad;
              public Podloga(float kolor, float przezroczystosc)
                float k = kolor;
                float p = przezroczystosc;
                geometria = createGeometry(k);
                wyglad = createAppearance(p);
                setGeometry(geometria);
                setAppearance(wyglad);
              public Geometry createGeometry(float kolor)
                float k = kolor;
                TriangleFanArray geometria_podlogi = new TriangleFanArray(44, GeometryArray.COORDINATES | GeometryArray.COLOR_3, new int[] {44});
                Point3f punkty[] = new Point3f[44];
                float l = -50.0f;
                for (int c = 0; c < 44; c += 4)
                 geometria_podlogi.setCoordinate(c + 0, new Point3f(-500.0f, 0.0f, l));
                 geometria_podlogi.setCoordinate(c + 1, new Point3f(500.0f, 0.0f, l));
                 geometria_podlogi.setCoordinate(c + 2, new Point3f(l, 0.0f, -500.0f));
                 geometria_podlogi.setCoordinate(c + 3, new Point3f(l, 0.0f, 500.0f));
                l += 10.0f;
               Color3f c = new Color3f(0.1f, k, k);
               for (int i = 0; i < 44; i++) geometria_podlogi.setColor(i, c);
              return geometria_podlogi;
              public Appearance createAppearance(float przezroczystosc)
                   float p = przezroczystosc;
                   Appearance wyglad = new Appearance();
                   PolygonAttributes atrybuty_poligowow ;
                   atrybuty_poligowow = new PolygonAttributes();
                  atrybuty_poligowow.setCullFace(PolygonAttributes.CULL_NONE);
                  atrybuty_poligowow.setPolygonMode(PolygonAttributes.POLYGON_FILL);
                  atrybuty_poligowow.setPolygonOffset(0.1f);
                  atrybuty_poligowow.setBackFaceNormalFlip(false);
                  TransparencyAttributes atrybuty_przezroczystosci = new TransparencyAttributes(1, p);
                  wyglad.setTransparencyAttributes(atrybuty_przezroczystosci);
                   wyglad.setPolygonAttributes(atrybuty_poligowow);
                  return wyglad;
         public BranchGroup createSceneGraph(SimpleUniverse simpleUniverse)
           SimpleUniverse su;
           su = simpleUniverse;
           BranchGroup korzen = new BranchGroup();     
           BoundingLeaf boundingLeaf = new BoundingLeaf(new BoundingBox());
           PlatformGeometry platformGeom = new PlatformGeometry();
           platformGeom.addChild(boundingLeaf);
           platformGeom.compile();
           su.getViewingPlatform().setPlatformGeometry(platformGeom);
           KeyNavigatorBehavior keyNavBeh = new KeyNavigatorBehavior(su.getViewingPlatform().getViewPlatformTransform());
           keyNavBeh.setSchedulingBoundingLeaf(boundingLeaf);
           korzen.addChild(keyNavBeh);
           Background background = new Background(new Color3f(1.0f, 1.0f, 1.0f));
           background.setApplicationBounds(new BoundingSphere(new Point3d(), 100000.0));
           korzen.addChild(background);
           Transform3D t3D_podlogi = new Transform3D();
           t3D_podlogi.set(new Vector3d(0.0f, -1.0f, 0.0f));
           TransformGroup tr_podlogi = new TransformGroup(t3D_podlogi);
           korzen.addChild(tr_podlogi);
           Podloga podloga = new Podloga(0.5f, 0.9f);
           tr_podlogi.addChild(podloga);
           Transform3D t3D_kostki1 = new Transform3D();
           t3D_kostki1.set(new Vector3d(3.0f, 0f, 0f));
           TransformGroup tg_kostki1 = new TransformGroup(t3D_kostki1);
           tg_kostki1.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
           Transform3D t3D_kostki2 = new Transform3D();
           t3D_kostki2.set(new Vector3d(-3.0f, 0f, 0f));
           TransformGroup tg_kostki2 = new TransformGroup(t3D_kostki2);
           tg_kostki2.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
           tg_kostki2.setBoundsAutoCompute(true);
           /*Inspector3DS loader = new Inspector3DS("D:\\Documents and Settings\\szeryf\\Tlo3D\\xw-pilot.3ds");
           loader.setDetail(9);
           loader.setLogging(true);
          loader.setTextureLightingOn();
          loader.setTexturePath("D:\\Documents and Settings\\szeryf\\Tlo3D\\");
          loader.setCreaseAngle(1.0);
           loader.parseIt();
          TransformGroup theModel = loader.getModel();
          theModel.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);*/
           SimpleBehavior myRotationBehavior = new SimpleBehavior(tg_kostki1);
           myRotationBehavior.setSchedulingBounds(new BoundingSphere(new Point3d(0, 0, 0), 1000));
           korzen.addChild(myRotationBehavior);
          korzen.addChild(tg_kostki1);
          korzen.addChild(tg_kostki2);
          Font3D font3d1 = new Font3D(new Font("Helvetica", Font.ITALIC, 1), new FontExtrusion());
          Text3D textGeom1 = new Text3D(font3d1, new String("JEDEN"), new Point3f(-4.0f, 0.0f, 0.0f));
           Appearance ap1 = new Appearance();
           ColoringAttributes ca1 = new ColoringAttributes();
           ca1.setColor(1.0f, 0.0f, 0.0f);
           ap1.setColoringAttributes(ca1);
          Shape3D textShape1 = new Shape3D(textGeom1,ap1);
           tg_kostki1.addChild(textShape1);
           Font3D font3d2 = new Font3D(new Font("Helvetica", Font.ITALIC, 1), new FontExtrusion());
           Text3D textGeom2 = new Text3D(font3d2, new String("DWA"), new Point3f(-4.0f, 0.0f, 0.0f));
          Appearance ap2 = new Appearance();
           ColoringAttributes ca2 = new ColoringAttributes();
           ca2.setColor(0.0f, 1.0f, 0.0f);
           ap2.setColoringAttributes(ca2);
           Shape3D textShape2 = new Shape3D(textGeom2,ap2);
           tg_kostki2.addChild(textShape2);
           SimpleBehavior2 myRotationBehavior2 = new SimpleBehavior2(tg_kostki2);
           myRotationBehavior2.setSchedulingBounds(new BoundingSphere(new Point3d(0, 0, 0), 1000));
           korzen.addChild(myRotationBehavior2);
          korzen.compile();
           return korzen;
         public class SimpleBehavior extends Behavior
             private TransformGroup targetTG;
             private Transform3D rotation2 = new Transform3D();
             private WakeupCriterion wakeupNextFrame;
             private Transform3D rotation = new Transform3D();
             private double angle, x, angle2;
             SimpleBehavior(TransformGroup targetTG)
                this.targetTG = targetTG;
                wakeupNextFrame = new WakeupOnElapsedFrames(5);
             public void initialize()
                wakeupOn(new WakeupOnAWTEvent(MouseEvent.MOUSE_PRESSED));     
                angle = -3.0f;
                angle2 = 10;
                x = 0.2;
             public void processStimulus(Enumeration criteria)
                if (angle < angle2)
                 x = x + 0.001;
                 angle += x;
                 rotation.setTranslation(new Vector3d(-angle, 0, 0));
                 targetTG.setTransform(rotation);
                 this.wakeupOn(wakeupNextFrame);
                else
                 angle2 = angle2 + 10;
                 x = -x;
                 wakeupOn(new WakeupOnAWTEvent(MouseEvent.MOUSE_PRESSED));
         public class SimpleBehavior2 extends Behavior
              private TransformGroup TG;
              private WakeupOnCollisionEntry wEnter;
             private WakeupOnCollisionExit wExit;
             private WakeupOnCollisionMovement wMove;
             private Transform3D rotation = new Transform3D();
             private Transform3D rotation2 = new Transform3D();
             private WakeupCriterion wakeupNextFrame;
             private double angle, x, angle2;
             SimpleBehavior2(TransformGroup targetTG)
               TG = targetTG;
               wakeupNextFrame = new WakeupOnElapsedFrames(20);
               wMove = new WakeupOnCollisionMovement(TG);
             public void initialize()
               wakeupOn(wMove);
               x = 0;
             public void processStimulus(Enumeration criteria)
               rotation.rotX(x);
               x = x + 0.1;
               rotation2.setTranslation(new Vector3d(-3f, 0f, 0f));
               rotation.mul(rotation2);
               TG.setTransform(rotation);
               wakeupOn(wMove);
         public static void main(String[] args)
             new MainFrame(new Tlo3D(), 500, 500);
    }A simple grey floor with 2 texts objects on it, right mouse button moves "jeden" to the left, while "jeden" intersects "dwa", "dwa" rotates around its X axis, then, when "jeden" stops moving you can click again to force the movement in right direction, so that "jeden" is going to intersect "dwa" once again. The thing is, that while "jeden" moves left everyhing is allright, "dwa" rotates as long as both objects remain in collision, however, as "jeden" moves back (that is in the right direction) "dwa" keeps rotating even though they are not colliding anymore. The best way is just to copy /paste that code and try it out to observe what kind of problem i am facing.
    Another question : how can i rewrite that code, so that "dwa" object could do something on wakeupOnCollisionExit, for example move up.
    regards, Lukasz

    How did you solve this problem?
    I'm having the same issue.
    It would mean the word to me if you could share your solution.

  • Problem with BoundingSphere

    i made simple ground, loaded and 3ds object, placed it straight in the middle and used KeyNavigatorBehavior to move around and admire the models
    the code :
    import java.applet.Applet;
    import java.awt.BorderLayout;
    import java.awt.Frame;
    import java.awt.Window;
    import java.awt.event.*;
    import java.awt.GraphicsConfiguration;
    import com.mnstarfire.loaders3d.Inspector3DS;
    import com.sun.j3d.utils.applet.MainFrame;
    import com.sun.j3d.utils.universe.*;
    import com.sun.j3d.utils.geometry.*;
    import javax.media.j3d.*;
    import javax.vecmath.*;
    import java.awt.event.*;
    import java.awt.AWTEvent;
    import java.util.Enumeration;
    import com.sun.j3d.utils.behaviors.keyboard.*;
    public class Tlo3D extends Applet
         public Tlo3D()
           setLayout(new BorderLayout());
           GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
           Canvas3D canvas3D = new Canvas3D(config);
           add(canvas3D);
           SimpleUniverse simpleUniverse = new SimpleUniverse(canvas3D);
           BranchGroup scene = createSceneGraph(simpleUniverse);
           simpleUniverse.getViewingPlatform().setNominalViewingTransform();
           simpleUniverse.addBranchGraph(scene);
         public class Podloga extends Shape3D
              Geometry geometria;
             Appearance wyglad;
              public Podloga(float kolor, float przezroczystosc)
                float k = kolor;
                float p = przezroczystosc;
                geometria = createGeometry(k);
                wyglad = createAppearance(p);
                setGeometry(geometria);
                setAppearance(wyglad);
              public Geometry createGeometry(float kolor)
                float k = kolor;
                TriangleFanArray geometria_podlogi = new TriangleFanArray(44, GeometryArray.COORDINATES | GeometryArray.COLOR_3, new int[] {44});
                Point3f punkty[] = new Point3f[44];
                float l = -50.0f;
                for (int c = 0; c < 44; c += 4)
                 geometria_podlogi.setCoordinate(c + 0, new Point3f(-500.0f, 0.0f, l));
                 geometria_podlogi.setCoordinate(c + 1, new Point3f(500.0f, 0.0f, l));
                 geometria_podlogi.setCoordinate(c + 2, new Point3f(l, 0.0f, -500.0f));
                 geometria_podlogi.setCoordinate(c + 3, new Point3f(l, 0.0f, 500.0f));
                l += 10.0f;
               Color3f c = new Color3f(0.1f, k, k);
               for (int i = 0; i < 44; i++) geometria_podlogi.setColor(i, c);
              return geometria_podlogi;
              public Appearance createAppearance(float przezroczystosc)
                   float p = przezroczystosc;
                   Appearance wyglad = new Appearance();
                   PolygonAttributes atrybuty_poligowow ;
                   atrybuty_poligowow = new PolygonAttributes();
                  atrybuty_poligowow.setCullFace(PolygonAttributes.CULL_NONE);
                  atrybuty_poligowow.setPolygonMode(PolygonAttributes.POLYGON_FILL);
                  atrybuty_poligowow.setPolygonOffset(0.1f);
                  atrybuty_poligowow.setBackFaceNormalFlip(false);
                  TransparencyAttributes atrybuty_przezroczystosci = new TransparencyAttributes(1, p);
                  wyglad.setTransparencyAttributes(atrybuty_przezroczystosci);
                   wyglad.setPolygonAttributes(atrybuty_poligowow);
                  return wyglad;
         public BranchGroup createSceneGraph(SimpleUniverse simpleUniverse)
           SimpleUniverse su;
           su = simpleUniverse;
           BranchGroup korzen = new BranchGroup();     
           BoundingLeaf boundingLeaf = new BoundingLeaf(new BoundingSphere(new Point3d(), 1000.0));
           PlatformGeometry platformGeom = new PlatformGeometry();
           platformGeom.addChild(boundingLeaf);
           platformGeom.compile();
           su.getViewingPlatform().setPlatformGeometry(platformGeom);
           KeyNavigatorBehavior keyNavBeh = new KeyNavigatorBehavior(su.getViewingPlatform().getViewPlatformTransform());
           keyNavBeh.setSchedulingBoundingLeaf(boundingLeaf);
           korzen.addChild(keyNavBeh);
           Background background = new Background(new Color3f(1f, 1f, 0f));
           background.setApplicationBounds(new BoundingSphere(new Point3d(), 1000.0));
          // background.setGeometry(createBackGraph());
           korzen.addChild(background);
           Transform3D t3D_podlogi = new Transform3D();
           t3D_podlogi.set(new Vector3d(0.0f, -1.0f, 0.0f));
           TransformGroup tr_podlogi = new TransformGroup(t3D_podlogi);
           korzen.addChild(tr_podlogi);
           Podloga podloga = new Podloga(0.5f, 0.9f);
           tr_podlogi.addChild(podloga);
           Inspector3DS loader = new Inspector3DS("D:\\Documents and Settings\\szeryf\\Tlo3D\\xw-pilot.3ds");
           loader.setDetail(9);
           loader.setLogging(true);
        //loader.setTextureLightingOn();
          loader.setTexturePath("D:\\Documents and Settings\\szeryf\\Tlo3D\\");
        //loader.setCreaseAngle(1.0);
           loader.parseIt();
          TransformGroup theModel = loader.getModel();
          theModel.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
          korzen.addChild(theModel);
           korzen.compile();
           return korzen;
         public static void main(String[] args)
             new MainFrame(new Tlo3D(), 256, 256);
    }everything works fine apart from one thing, if i either move too high or to far away, the object along with ground dissapear, at first i though that must be the matter of boundingsphere which obviously might have been initialiazed as too small, so i changed the constructor to expand it to 1000 from 1 (as is it set in default constructor) however that didnt help either, whats is the problem then ?
    cheers, Lukasz
    Message was edited by:
    Konieczny
    Message was edited by:
    Konieczny

    I can`t see anything wrong with your code.
    There may be an issue with the front or back view clip. See the javadoc for View for details. Or there may be an issue with z-buffer settings on the video card.
    regards

  • Traversing SceneGraph

    Hi!
    I would really appriciate if someone could help me with this.
    I have to travers all the nodes in one tree, from one BranchGroup, to all the leaf nodes in the tree, to get the Shape3D generated by a 3ds-loader.
    I would like a method that takes the BranchGroup as argument and then for all the leaf nodes sets the capability bits for each. Does anyone have that code or have a simple example how I should do this?
    Regards,
    Henrik

    This should be pretty straightforward. If you have the branch group, then you are all set. Simply traverse the scene graph recursively, using leaf nodes as your base case for returning. So your algorithm will look something like this:
    public void findAllShape3DNodes( final Node parentNode )
         int numChildren = parentNode.numChildren();
         for( int i=0; i<numChildren; ++i )
              Node node = parentNode.getChild( i );
              if( node instanceof Shape3D )
                  //  Do whatever you need to do to this Shape3D
              else
                  findAllShape3DNodes( node );
    }That's the general gist of the algorithm. Of course, you will have to modify it to suit your needs, but in general that is the idea you want to follow. So the parentNode parameter to the method will be the branch group that you picked. You send that branch group to the method and it iterates over its child nodes, searching for Shape3D objects. If it finds a Shape3D object, then does whatever you wanted to do to that node. If it isn't a Shape3D node, then it must be some other kind of node (might want to check that its not any other kind of leaf node, but with this algorithm it shouldn't make a difference since a leaf node has no children). If its some other kind of node, recur on that node and iterate over all of its children, and so on.
    Hope that helps!
    Cheers,
    Greg

  • Quake Problems

    I am using those MD2 & BSP loaders (found in J3D.org) in my project, but I have problems setting them up to work with my collision avoidance. With the MD2s, I can set the appropriate capabilities for a static model, but when it is animated, I get exceptions. I have tried loading all of the frames and setting capabilities for each, but this does not seem to make a difference.
    The other, more serious problem is with the BSP (level) files. I cannot seem to set the capabilities on these either. I try, using the code below (where bgIn is the BranchGroup from the BSP):
    Vector groups = new Vector();
    int currentGroup = 0;
    groups.add( bgIn );
    Enumeration eGroup;
    Object oGroup;
    Enumeration eShape;
    Object oShape;
    while( currentGroup < groups.size() )
         eShape = ((Group)groups.get(currentGroup)).getAllChildren();
         while( eShape.hasMoreElements() )
              oGroup = eShape.nextElement();
              if( oGroup instanceof Group )
                   groups.add( oGroup );
              else if( oGroup instanceof Shape3D )
                   ((Shape3D)oGroup).setCapability( Shape3D.ALLOW_GEOMETRY_READ );
                   eShape = ((Shape3D)oGroup).getAllGeometries();
                   while( eShape.hasMoreElements() )
                        oShape = eShape.nextElement();
                        System.out.println( oShape );
                        ((Geometry)oShape).setCapability( GeometryArray.ALLOW_COORDINATE_READ );
                        ((Geometry)oShape).setCapability( GeometryArray.ALLOW_FORMAT_READ );
                        ((Geometry)oShape).setCapability( GeometryArray.ALLOW_COUNT_READ );
         currentGroup++;
    When I do this, the level only seems to be made of one Shape3D, which includes just one TriangleFanArray, which I cannot believe is correct. When I touch a wall, I get a javax.media.j3d.CapabilityNotSetException: Shape3D: no capability to get geometry. Is there something wrong with this code, or some other way to do this?
    Thanks

    Ouch, this brings back painful memories for me. I had similar problems with importing .3ds files but it was a long time ago and I don't have the code to hand. I do recall, however, after much toiling I eventaully went through and set ALL the capabilities of the Shape3Ds possible similar to some of your code:
    ((Geometry)oShape).setCapability(GeometryArray.ALLOW_COORDINATE_READ );and then removed them one by one to find out which capability was needed to stop the Exception. (This was all done by modifying the 3ds Loader code BTW - I was using 3ds Loader by Richard Hawkes, also from j3d.org)
    Sorry I can't be of more help, I know how irritating it is :(

  • Storing 3D Models

    I've written a small 3DS loader, but now I've run into the problem of storing the information. When I load one model, there are the XYZ coordinates and ABC for the faces. Coordinates are extracted from the file as floats then converted to integers with a small loss of precision and the faces are integers as well.
    This is really a problem of storing multiple(~20) large arrays(~200) of 6 integer arrays. I was thinking about doing a bit wise operation to convert the 6 arrays into one long. 2 bytes for each x y and z then store each face as one byte. But, this gives me multiple large arrays of longs. Also limiting the amount of polygons I have to 256.
    I'm sure I'm over complicating this so I figured I would ask if there is a simpler method.

    Hello,
    This is really a problem of storing multiple(~20) large arrays(~200) of 6 integer arrays. I was thinking about doing a bit wise operation to convert the 6 arrays into one long. 2 bytes for each x y and z then store each face as one byte. But, this gives me multiple large arrays of longs. Also limiting the amount of polygons I have to 256.
    I'm sure I'm over complicating this so I figured I would ask if there is a simpler method.Can you re-state what your "problem" is? I don't see any in your description, but maybe I missed something.
    Based on your numbers, you're talking about storing 20*200*6=24000 integers, i.e. 96kB. Not a big amount in the RAM of a regular desktop computer - but maybe you're running on a more limited device? Please clarify if this is the case.
    This is likely not a big number either in terms of file storage.
    Is your problem the fact that you don't know how to code this "storage"? Then search about "Java serialization" (of course a lot of other approaches exist).
    Best regards,
    J.

  • Java3d - starfire: Where is my 3ds object?

    I have made a simple application using java3d. I am able to view a pyramide that I have modeled using java. However, I am not able to see the 3ds-object I am trying to import using starfire. I have moved the view back, it orbits around origo, and I have lights in my scene....but no 3ds-object....why? I have tried both materialised objects and objects without materials...
    Here is my code:
    package vindm�lle;
    import javax.media.j3d.Shape3D;
    import javax.media.j3d.TransformGroup;
    import com.mnstarfire.loaders3d.Inspector3DS;
    public class Blad extends Object {
         TransformGroup bladModel;
        public Blad() {
            Inspector3DS loader = new Inspector3DS("models/box.3ds"); // constructor
              loader.parseIt(); // process the file
              loader.setLogging(true); // turns on logging to a disk file "log3ds.txt"
              loader.setDetail(6); // sets the level of detail to be logged
              loader.setTextureLightingOn(); // turns on modulate mode for textures (lighting)
              TransformGroup bladModel = loader.getModel(); // get the resulting 3D model as a Transform Group with Shape3Ds as children
              bladModel.setCapability(TransformGroup.ALLOW_CHILDREN_READ);
              bladModel.setCapability(TransformGroup.ALLOW_CHILDREN_WRITE);
        public TransformGroup getTransformGroup() {
            return bladModel;
    package vindm�lle;
    import javax.media.j3d.Appearance;
    import javax.media.j3d.ColoringAttributes;
    import javax.media.j3d.Material;
    import javax.media.j3d.PolygonAttributes;
    import javax.media.j3d.Shape3D;
    import javax.media.j3d.TriangleArray;
    import javax.vecmath.Color3f;
    public class ColorPyramide extends Object {
         private static final float[] verts = {
                // front face
                    1.0f, -1.0f, 1.0f, 0.0f, 1.0f, 0.0f, -1.0f,
                    -1.0f, 1.0f,
                    // back face
                    -1.0f, -1.0f, -1.0f, 0.0f, 1.0f, 0.0f, 1.0f,
                    -1.0f, -1.0f,
                    // right face
                    1.0f, -1.0f, -1.0f, 0.0f, 1.0f, 0.0f, 1.0f,
                    -1.0f, 1.0f,
                    // left face
                    -1.0f, -1.0f, 1.0f, 0.0f, 1.0f, 0.0f, -1.0f,
                    -1.0f, -1.0f,
                    // top face
                    0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f,
                    0.0f,
                    // bottom face
                    -1.0f, -1.0f, 1.0f, 1.0f, -1.0f, -1.0f, 1.0f,
                    -1.0f, 1.0f, };
    public Appearance normalAppearance (){
         Appearance pyramideAppearance = new Appearance();
         Color3f color1 = new Color3f (1.0f, 0.0f, 0.0f);
         ColoringAttributes pyramideColor = new ColoringAttributes (color1, ColoringAttributes.NICEST);
         pyramideAppearance.setColoringAttributes(pyramideColor);
         return pyramideAppearance;
    public Appearance wireAppearance(){
         Appearance pyramideAppearance = new Appearance();
        Color3f color1 = new Color3f (1.0f, 0.0f, 0.0f);
         ColoringAttributes pyramideColor = new ColoringAttributes (color1, ColoringAttributes.NICEST);
         pyramideAppearance.setColoringAttributes(pyramideColor);
        PolygonAttributes polyAtt = new PolygonAttributes();
        polyAtt.setPolygonMode(PolygonAttributes.POLYGON_LINE);
         pyramideAppearance.setPolygonAttributes(polyAtt);
         return pyramideAppearance;
        private Shape3D shape;
        public ColorPyramide() {
            TriangleArray pyramide = new TriangleArray(24,
                      TriangleArray.COORDINATES | TriangleArray.ALLOW_COLOR_READ);
            pyramide.setCoordinates(0, verts);
            shape = new Shape3D(pyramide);
            shape.setAppearance(normalAppearance());
        public Shape3D getShape() {
            return shape;
    package vindm�lle;
    import java.applet.Applet;
    import java.awt.BorderLayout;
    import java.awt.GraphicsConfiguration;
    import java.awt.GraphicsEnvironment;
    import javax.media.j3d.AmbientLight;
    import javax.media.j3d.Background;
    import javax.media.j3d.BoundingSphere;
    import javax.media.j3d.BranchGroup;
    import javax.media.j3d.Canvas3D;
    import javax.media.j3d.GraphicsConfigTemplate3D;
    import javax.media.j3d.PointLight;
    import javax.media.j3d.SpotLight;
    import javax.media.j3d.TransformGroup;
    import javax.vecmath.Color3f;
    import javax.vecmath.Point3d;
    import javax.vecmath.Point3f;
    import com.sun.j3d.utils.applet.MainFrame;
    public class VindM�lle extends Applet {
        public BranchGroup createSceneGraph() {
            // Create the root of the branch graph
            BranchGroup objRoot = new BranchGroup();
            // Create the TransformGroup node and initialize it to the
            // identity. Enable the TRANSFORM_WRITE capability so that
            // our behavior code can modify it at run time. Add it to
            // the root of the subgraph.
            TransformGroup objTrans = new TransformGroup();
            objTrans.setCapability(
                                TransformGroup.ALLOW_TRANSFORM_WRITE);
            objRoot.addChild(objTrans);
            // Create a simple Shape3D node; add it to the scene graph.
            //objTrans.addChild(new ColorPyramide().getShape());
            objTrans.addChild(new Blad().getTransformGroup());
         // Setter p� lys slik at modellen blir synlig
            BoundingSphere boundsb = new BoundingSphere(new Point3d(0.0,0.0,0.0), 500.0);
            AmbientLight al = new AmbientLight(true,new Color3f(1,1,1));
            al.setInfluencingBounds(boundsb);
            Point3f point = new Point3f(60,0,120);
            PointLight lgt1 = new PointLight();
            SpotLight lgt2 = new SpotLight();
            Color3f lColor1 = new Color3f(1.0f,1.0f,1.0f);
            lgt1.setPosition(point);
            lgt1.setColor(lColor1);
            lgt1.setInfluencingBounds(boundsb);
            lgt2.setDirection(-100.0f, 0.0f, -100.0f);
            lgt2.setPosition(100.0f, 0.0f, 100.0f);
            lgt2.setSpreadAngle((float)Math.PI/64);
            lgt2.setInfluencingBounds(boundsb);
            objRoot.addChild(lgt1);
            objRoot.addChild(lgt2);
            objRoot.addChild(al);
            Background b=new Background(1,1,1);
            //BoundingSphere boundsb2 = new BoundingSphere(new Point3d(0.0,0.0,0.0), 500.0);
            b.setApplicationBounds(boundsb);
            objRoot.addChild(b);
            return objRoot;
        public VindM�lle() {
            // Get the GraphicsConfiguration that best fits our needs.
            GraphicsConfigTemplate3D template = new GraphicsConfigTemplate3D();
            template.setSceneAntialiasing(GraphicsConfigTemplate3D.REQUIRED);
            GraphicsConfiguration gcfg =
            GraphicsEnvironment.getLocalGraphicsEnvironment().
            getDefaultScreenDevice().getBestConfiguration(template);
           setLayout(new BorderLayout());
           Canvas3D c = new Canvas3D(gcfg);
           add("Center", c);
            // Create a simple scene and attach it to the virtual
            // universe
            BranchGroup scene = createSceneGraph();
            UniverseBuilder u = new UniverseBuilder(c);
            u.addBranchGraph(scene);
        public static void main(String[] args) {
             new MainFrame(new VindM�lle(), 500, 500);
    package vindm�lle;
    import javax.media.j3d.Alpha;
    import javax.media.j3d.BoundingSphere;
    import javax.media.j3d.BranchGroup;
    import javax.media.j3d.Canvas3D;
    import javax.media.j3d.Locale;
    import javax.media.j3d.PhysicalBody;
    import javax.media.j3d.PhysicalEnvironment;
    import javax.media.j3d.PositionPathInterpolator;
    import javax.media.j3d.RotationInterpolator;
    import javax.media.j3d.Transform3D;
    import javax.media.j3d.TransformGroup;
    import javax.media.j3d.View;
    import javax.media.j3d.ViewPlatform;
    import javax.media.j3d.VirtualUniverse;
    import javax.vecmath.AxisAngle4f;
    import javax.vecmath.Point3d;
    import javax.vecmath.Point3f;
    import javax.vecmath.Vector3f;
    public class UniverseBuilder extends Object {
        // User-specified canvas
        Canvas3D canvas;
        // Scene graph elements to which the user may want access
        VirtualUniverse                        universe;
        Locale                        locale;
        TransformGroup                        vpTrans;
        TransformGroup kameraTrans;
        View                        view;
        public UniverseBuilder(Canvas3D c) {
            this.canvas = c;
            // Establish a virtual universe that has a single
            // hi-res Locale
            universe = new VirtualUniverse();
            locale = new Locale(universe);
            // Create a PhysicalBody and PhysicalEnvironment object
            PhysicalBody body = new PhysicalBody();
            PhysicalEnvironment environment =
                                                new PhysicalEnvironment();
            // Create a View and attach the Canvas3D and the physical
            // body and environment to the view.
            view = new View();
            view.addCanvas3D(c);
            view.setPhysicalBody(body);
            view.setPhysicalEnvironment(environment);
            // Create a BranchGroup node for the view platform
            BranchGroup vpRoot = new BranchGroup();
            // Create a ViewPlatform object, and its associated
            // TransformGroup object, and attach it to the root of the
            // subgraph. Attach the view to the view platform.
            Transform3D t = new Transform3D();
            t.set(new Vector3f(0.0f, 2.0f, 10.0f));
            ViewPlatform vp = new ViewPlatform();
            kameraTrans = new TransformGroup();
            kameraTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
            kameraTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
            Transform3D r = new Transform3D();
            Alpha rotationAlpha = new Alpha(
                    -1, Alpha.INCREASING_ENABLE,
                    0, 0,            4000, 0, 0,                        0, 0, 0);
            RotationInterpolator rotator = new RotationInterpolator(
                    rotationAlpha, kameraTrans, r,
                    0.0f, (float) Math.PI*2.0f);
            BoundingSphere bounds =
                new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0);
            rotator.setSchedulingBounds(bounds);
            kameraTrans.addChild(rotator);
            kameraTrans.setTransform(r);
            vpTrans = new TransformGroup();
            vpTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
            vpTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
            vpTrans.setTransform(t);
            kameraTrans.addChild(vpTrans);
            vpTrans.addChild(vp);
            vpRoot.addChild(kameraTrans);
            view.attachViewPlatform(vp);
            // Attach the branch graph to the universe, via the
            // Locale. The scene graph is now live!
            locale.addBranchGraph(vpRoot);
    public void rotate(){
        public void addBranchGraph(BranchGroup bg) {
            locale.addBranchGraph(bg);
    }

    If you look down the list of forums, there is one specifically for Java3D, so you might try posting this there to see if any of the real J3D experts can help you.
    Here in Java Essentials we just discuss the proper way to place braces and whether or not you have enough comments :D

Maybe you are looking for

  • Charging a US iPod with UK Charger

    Would it be possible to use a UK or European iPod Mini charger to refill the battery on my iPod (US) Mini?

  • One CS4 Design Volume License works on PC and MAC?

    We are a small company and we are planning to buy the volume license for the CS4 Desgin Premium. We all work on PC, except for one who uses MacOSX. Can the same license be used on both platforms? Thanks

  • Does Skype 2.8 run well on OS X 10.8 Mountain Lion

    The only thing holding us back from upgrading to Mountain Lion is the question of Skype compatibility. We would prefer to use Skype 2.8. We would take the plunge, though, if we knew Skype 5.8 worked well on Mountain Lion. But Roaring Apps says Skype

  • Partial sound failure, need help

    Tecra A9-S9015X running Windows XP SP3 After an unexplained system crash when I unplugged the AC converter at the wall, all sounds failed (system, CD, DVD, mp3). After I updated the BIOS from the origianl vers. 1.1 to 2.0, system sounds returned loud

  • Importing avi from Canon Ixus 960 into FCE 4

    Is it possible to import the movie clips i make with my digital ixus camera directly into FCE 4. With iMovie there is this possibility. I use this camera mainly because of its size.