Java3D: rotation of a universe with a step

I am trying to develop a Java3D method for rotating a universe in increments from the current viewing direction to the direction in the center of the object.

In other words, I want the 3D universe to rotate, say, 100 short steps, so that the object I click on seems to be gradually moving to the center of the screen.

I looked at various answers to questions about 3D rotation here on StackOverflow (and also on the Internet), but pretty much all of them are specific to rotating objects, and not to the world itself.

I also tried looking through my linear algebra, but this did not help me identify Java-specific functions that fulfill my requirements.

So far, I have been trying to determine the set of incremental XYZ coordinates and dynamically using lookAt () in each pass through the loop. It almost works, but I don’t see any way to save or get the viewpoint values ​​from one full rotation to the next; Each pass of rotation begins with the origin.

I also tried to determine the rotation matrix, getting the difference between the target and initial transformations and dividing by the number of increments (and removing the scaling value), and then adding that the incremental rotation matrix in the current viewing direction on each pass through the loop. This works great for an increment value of 1. But splitting a rotation into two or more increments always generates the error "Error without conversion": "Non-congruent conversion above ViewPlatform". (I read the meager documentation about this exception in the Java3D API reference, it could also be written in Urdu for everything I could do from it. There seems to be no simple English-language definition of 3D context terms such as "affine" or “shear” or “congruent” or “uniform”anywhere Google can see.)

, AxisAngle4d, ( ), . , , , , , .

rotX rotY ( Z ) Math.cos() Math.sin(). .

, Java3D . , , , . , , , , - Java3D. , , .

​​, , Java Timer. , , ActionListener. , , , - , ( ) , "" .

  private void flyRotate(double endX, double endY, double endZ)
  {
    // Rotate universe by increments until target object is centered in view
    // 
    // REQUIREMENTS
    // 1. Rotate the universe by NUMROTS increments from an arbitrary (non-origin)
    //   3D position and starting viewpoint to an ending viewpoint using the
    //   shortest path and preserving the currently defined "up" vector.
    // 2. Use the Java Timer() method to schedule the visual update for each
    //   incremental rotation.
    //
    // GLOBALS
    // rotLoop contains the integer loop counter for rotations (init'd to 0)
    // viewTransform3D contains rotation/translation for current viewpoint
    // t3d is a reusable Transform3D variable
    // vtg contains the view platform transform group
    // NUMROTS contains the number of incremental rotations to perform
    //
    // INPUTS
    // endX, endY, endZ contain the 3D position of the target object
    //
    // NOTE: Java3D v1.5.1 or later is required for the Vector3D getX(),
    //   getY(), and getZ() methods to work.

    final int delay = 20; // milliseconds between firings
    final int pause = 10; // milliseconds before starting

    // Get translation components of starting viewpoint vector
    Vector3d viewVector = new Vector3d();
    viewTransform3D.get(viewVector);
    final double startX = viewVector.getX();
    final double startY = viewVector.getY();
    final double startZ = viewVector.getZ();

    // Don't try to rotate to the location of the current viewpoint
    if (startX != endX || startY != endY || startZ != endZ)
    {
      // Get a copy of the starting view transform
      t3d = new Transform3D(viewTransform3D);

      // Define the initial eye/camera position and the "up" vector
      // Note: "up = +Y" is just the initial naive implementation
      Point3d  eyePoint = new Point3d(startX,startY,startZ);
      Vector3d upVector = new Vector3d(0.0,1.0,0.0);

      // Get target view transform
      // (Presumably something like this is necessary to get a transform
      // containing the ending rotation values.)
      Transform3D tNew = new Transform3D();
      Point3d viewPointTarg = new Point3d(endX,endY,endZ);
      tNew.lookAt(eyePoint,viewPointTarg,upVector);
      tNew.invert();

      // Get a copy of the target view transform usable by the Listener
      final Transform3D tRot = new Transform3D(tNew);

      //
      // (obtain either incremental rotation angle
      // or congruent rotation transform here)
      //

      ActionListener taskPerformer = new ActionListener()
      {
        public void actionPerformed(ActionEvent evt)
        {
          if (++rotLoop <= NUMROTS)
          {
            // Apply incremental angle or rotation transform to the
            // current view
            t3d = magic(tRot);

            // Communicate the rotation to the view platform transform group
            vtg.setTransform(t3d);
          }
          else
          {
            timerRot.stop();
            rotLoop = 0;
            viewTransform3D = t3d;
          }
        }
      };

      // Set timer for rotation steps
      timerRot = new javax.swing.Timer(delay,taskPerformer);
      timerRot.setInitialDelay(pause);
      timerRot.start();
    }
  }

, , , . .

!


.

Java3D-, Sphere. XYZ.

"" XYZ , , .

(: . , , , , - XYZ.)

XYZ , , . , , "" , . ( , , , !)

. , , "" 1,0 Y, . , 180 , , .

, ( 50) , .

Java3D, , ( 0,0,0), Y- . (I.e., , Z Z- .)

:

  • - , .
  • , , ( ) .
  • - 180 .
  • "" "" ; "" ( "" ) .

, : , () , XYZ , Java3D N , ?

, : -, 3D- ( Java3D) , XYZ; -, , [ ], .

, . bash , . , , ( " ViewPlatform" ).

....

+3
1

, , - , , , "" .

, :

  • ( A) "", , .
  • -, / ( D), "", . , Z/Y /.
  • dA dD A/D N, , , .
  • / A/D dA ​​/dD N , . , "" , .

, , SLERP.

0

All Articles