3 Replies Latest reply: Nov 17, 2010 8:58 AM by 692454 RSS

    Java3D help

    808974
      Hi. I'm trying to create a propeller and make it spin. However, it just spins around the wrong way and I have no idea how to change it.

      sceneBG.addChild(propeller);

           propeller.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
           Alpha spinAlpha = new Alpha(-1, 6000);
           RotationInterpolator objRotate = new RotationInterpolator(spinAlpha, propeller);


           BoundingSphere zone = new BoundingSphere();
           objRotate.setSchedulingBounds(zone);

           propeller.addChild(objRotate);
        • 1. Re: Java3D help
          DarrylBurke
          Moderator action: Moved from New to Java

          db
          • 2. Re: Java3D help
            809116
            hi!

            I had such problem in the earlier session of Java3d and here is how i solved the problem.
            all you need to do is set the axis of Rotation of objRotate via the Transform3D object. it should go something like this -

            Transform3D t1 = new Transform3D();
            t1.rotX(Math.PI/4.0f);
            objRotate.setAxisOfRotation(t1);


            do specify the rotation specification according to your need. you have rotX,rotY and rotZ.

            I hope my reply was useful. if not plz state your exact requirement and the source code, we'll definitely find a way out..!
            happy Java3Ding...!

            -neo
            • 3. Re: Java3D help
              692454
              Hello together,
              I have the same problems with setting the rotation around one axis. I tried the small example but still i can rotate the whole object via MouseRotate in all directions and not only in one.
              So here is my code. If one of you could give me a hint, how to solve my problem, i will be thankful.


              "
              public BranchGroup createSceneGraph() {

                   BranchGroup objRoot = new BranchGroup();


                   // Create a TransformGroup to rotate the scene around Y-axis
              TransformGroup objRotate = new TransformGroup();
              Transform3D t1 = new Transform3D();
              t1.rotX(2.0f*Math.PI);
              objRotate.setAxisOfRotation(t1);
              objRoot.addChild(objRotate);

                   
                   
                   // Create a TransformGroup and initialize it to the
                   // identity. Enable the TRANSFORM_WRITE capability so that
                   // our behavior code can modify it at runtime. Add it to the
                   // root of the subgraph.
                   TransformGroup objTrans = new TransformGroup();
                   objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
              objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
              objRoot.addChild(objTrans);

              //Add primitives to the scene
              objTrans.addChild(new SingleBox().getBG());

              BoundingSphere bounds = new BoundingSphere(new Point3d(), 100.0);

              Background bg = new Background(new Color3f(1.0f, 1.0f, 1.0f));
              bg.setApplicationBounds(bounds);
              objTrans.addChild(bg);

              // set up Zoom bahaviour
              MouseZoom mz = new MouseZoom();
              mz.setTransformGroup(objTrans);
              mz.setSchedulingBounds(bounds);
              mz.setFactor(0.05);
              objTrans.addChild(mz);


              // set up a mouse translation
              MouseTranslate mt = new MouseTranslate();
              mt.setTransformGroup(objTrans);
              mt.setSchedulingBounds(bounds);
              mt.setFactor(0.2);
              objTrans.addChild(mt);

              // set up the mouse rotation behaviour
              MouseRotate mr= new MouseRotate();
              mr.setTransformGroup(objTrans);
              mr.setSchedulingBounds(bounds);
              mr.setFactor(0.007);
              objTrans.addChild(mr);

              "

              And another issue. I wanted to use texture over my object, but i get the following exception, although i added the picture to the project file:
              "java.lang.NoClassDefFoundError: boxes/SetOfBoxes

              Caused by: java.lang.ClassNotFoundException: boxes.SetOfBoxes

              at java.net.URLClassLoader$1.run(Unknown Source)

              at java.security.AccessController.doPrivileged(Native Method)

              at java.net.URLClassLoader.findClass(Unknown Source)

              at java.lang.ClassLoader.loadClass(Unknown Source)

              at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)

              at java.lang.ClassLoader.loadClass(Unknown Source)

              Exception in thread "main
              "
              Thanks in advance
              Lui