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)
{
final int delay = 20;
final int pause = 10;
Vector3d viewVector = new Vector3d();
viewTransform3D.get(viewVector);
final double startX = viewVector.getX();
final double startY = viewVector.getY();
final double startZ = viewVector.getZ();
if (startX != endX || startY != endY || startZ != endZ)
{
t3d = new Transform3D(viewTransform3D);
Point3d eyePoint = new Point3d(startX,startY,startZ);
Vector3d upVector = new Vector3d(0.0,1.0,0.0);
Transform3D tNew = new Transform3D();
Point3d viewPointTarg = new Point3d(endX,endY,endZ);
tNew.lookAt(eyePoint,viewPointTarg,upVector);
tNew.invert();
final Transform3D tRot = new Transform3D(tNew);
ActionListener taskPerformer = new ActionListener()
{
public void actionPerformed(ActionEvent evt)
{
if (++rotLoop <= NUMROTS)
{
t3d = magic(tRot);
vtg.setTransform(t3d);
}
else
{
timerRot.stop();
rotLoop = 0;
viewTransform3D = t3d;
}
}
};
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" ).
....