5 Replies Latest reply: Sep 22, 2011 3:49 AM by 879348 RSS

    Java3D Coordinates


      I am looking for some advice on Java3D coordinates. As far as I understand, a Point 3f's x, y, and z are specified between -1.0f and 1.0f. I am modelling a terrain and I currently have to convert my terrain x, y, and z's to between -1.0f and 1.0f. To me, this is effectively doubling the number of floats I am using in memory.

      Am I looking at this correctly? or, is there another way to handle Java3D coordinates I haven't fount yet?

      Thanks in advance
        • 1. Re: Java3D Coordinates
          There are no such bouds to a point3f value.
          • 2. Re: Java3D Coordinates
            Well jfp, I am not sure your answer is helpful. I will explain differently ...

            Following the AxisApp example from the tutorial, the following code creates the x-axis:

            // create line for X axis
            LineArray axisXLines = new LineArray(2, LineArray.COORDINATES );
            axisBG.addChild(new Shape3D(axisXLines));
            axisXLines.setCoordinate(0, new Point3f(-1.0f, 0.0f, 0.0f));
            axisXLines.setCoordinate(1, new Point3f( 1.0f, 0.0f, 0.0f));

            If I were to change the values of the Point3f's to be below -1 then the x-axis would no longer be visible.

            // create line for X axis
            LineArray axisXLines = new LineArray(2, LineArray.COORDINATES );
            axisBG.addChild(new Shape3D(axisXLines));
            axisXLines.setCoordinate(0, new Point3f(-3.0f, 0.0f, 0.0f));
            axisXLines.setCoordinate(1, new Point3f(-2.0f, 0.0f, 0.0f));

            To me, this implies that the values must be between -1 and 1 for all x, y, z. Is this true? Or, is there another way to specify what the min and max can be?

            The reason I ask is that I have many x, y, z's that are not in the -1 -> 1 range. So, do I need to convert (scale) them so they will appear? I was hoping a BoundingBox may help but didn't.
            • 3. Re: Java3D Coordinates

              Has anyone got an answer for this?

              • 4. Re: Java3D Coordinates
                just saw your Post but sorry I don't have a solution to your problem.
                Yes, the coordinate system for Point3f lies between -1.0f to 1.0f along each axis (at least when your Canvas is added in JFrame :-P)
                I also made Java3D app and in my case I have to use coordinate values as double because of the no. of geometries I made are calculated and drawn precisely and in a fraction of second. I saw some sample Java3D apps and found that most developers used Point3f. but in your case I think you need to scale them accordingly. best way is to figure out a constant conversion factor.

                PS: I noticed that 3D apps are not meant to be memory efficient but they should be performance efficient.

                • 5. Re: Java3D Coordinates
                  Jfp again
                  Sorry for my late response (and I hope better than the first).
                  Here is how I understand your problem :
                  You want to figure some terrain but you can see only a part of it because as soon as you increase the terrain <<size>>, it is drawn out of the sceen.
                  Of course you could insert in your terrain graph some transform to size it. It would work as a zoom function.
                  In true life, to look at landcsape, we move and turn our head.
                  Here is some code to perform viewpoint move with mouse :
                  1-a viewing platform must be defined and moved back a bit :

                  ViewPlat=u.getViewingPlatform(); // get universe view
                  ViewPlat.setNominalViewingTransform(); // make one step backward

                  2- define an orbit behavior and branch it to ViewingPlatform :

                  camMove = new OrbitBehavior();
                  camMove.setEnable(false); // turned off because not always running

                  If other mouse behaviors are used(PickRotate, translate...), turn them off before using OrbitBehavior and camMove enabled.

                  If you branch the ViewingPlatform to a RotPosPathInterpolator, the viewpoint will move between defined points, making an animation. But this is another story.
                  You can find code (i hope usefull) here [http://cliper.pagesperso-orange.fr/launchen.html] . Get the JAR (NetBeans project) which could help you.
                  Please do not try launching app because of bug with JavaWebStart.
                  Feel free if you need further help.