Thanks Matt. I was not actually able to get your code to work with the
hacking that I'm doing. Instead I did the following:
To refresh...the problem I was having is that I had a SimpleUniverse with an
OrbitBehavior.
The OrbitBehavior worked fine, but I also wanted the ability to set a view
to any point and look at any
point I wanted. Instead, when I used the 'lookAt' function, after having
rotated/zoomed/panned in the scene,
my rotation center was switched from 0,0,0 to the eyePos (3.5,-1,-2) that is
specified in lookAt. Basically,
lookAt was somehow changing my rotationCenter, and even if I explicitly told
the OrbitBehavior to set
the rotation center to 0,0,0 it still would NOT. That was frustrating but
with some help we figured out that
we would need to set the Transform3D (viewTrans) of the TransformGroup (vTG)
of the ViewingPlatform (vPlatform)
to which the OrbitBehavior was attached. This was done by keeping a global
track of the TransformGroup (vTG) of the ViewingPlatform (vPlatform) and
then when using the 'lookAt' function on the Transform3D, we used this
Transform3D on the TransformGroup (vTG).
The end result is that, I can still use the OrbitBehavior to move around to
any point and I can also use the
'lookAt' function to snap my view to any desired point. So, for example, I
can do coordinate axes views from
+X,-X,+Y,-Y,+Z,-Z direction even after rotations/pans/zooms.
Hope this helps someone (again, code is below)
//---------- CODE START
-----------------------------------------------------------------
// Global Variables:
private TransformGroup vTG;
private OrbitBehavior orbit;
public myPanel() {
// Define the scene
...
SimpleUniverse universe = new SimpleUniverse(canvas3D);
// Define the OrbitBehavior
ViewingPlatform vPlatform = universe.getViewingPlatform();
BoundingSphere infiniteBounds = new BoundingSphere(new Point3d(),
10000.0);
orbit = new OrbitBehavior(canvas3D,112); // 112 = REVERSE_ALL
orbit.setSchedulingBounds(infiniteBounds);
vPlatform.setViewPlatformBehavior(orbit);
// Get the TransformGroup of the ViewingPlatform
vTG = viewingPlatform.getViewPlatformTransform();
}
public void changeView() {
Point3d center = new Point3d();
Point3d eyePos = new Point3d(center);
eyePos.z += 3.5;
eyePos.x -= 1.0;
eyePos.y -= 2.0;
Vector3d up = new Vector3d();
up.y = 1;
Transform3D viewTrans = new Transform3D();
viewTrans.setIdentity();
viewTrans.lookAt( eyePos, center, up );
viewTrans.invert();
vTG.setTransform(viewTrans);
}
//---------- CODE END
-----------------------------------------------------------------
Mario
Mariusz Zaczek
NASA - Johnson Space Center
Automated Vehicles and Orbit Analysis / DM35
Flight Design and Dynamics Division
Mission Operations Directorate
Bldg: 30A Room: 3040A
Disclaimer: "The opinions, observations and comments expressed in my email
are strictly my own and do not necessarily reflect those of
NASA."
-----Original Message-----
From: Pierce, Matthew A [mailto:[EMAIL PROTECTED]
Sent: Wednesday, April 02, 2003 12:53 PM
To: [EMAIL PROTECTED]
Subject: Re: [JAVA3D] ? OrbitBehavior and LookAt ?
Mario -
I use the orbit behavior and the Transform3D "lookAt" in my application with
OK results. I have included some code snippets below, but I don't think I am
doing anything special. You need to do two things: update the orbit behavior
focus point, and update the view platform transform group. Hope this helps.
Matt
!!! IMPLEMENTING CLASS VARIABLES !!!
protected SimpleUniverse univ;
protected OrbitBehavior ob;
!!! METHOD TO UPDATE ORBIT BEHAVIOR & VIEW PLATFORM ORIENTATION !!!!
private void setView(Point3d eye, Point3d focus, Vector3d up, boolean
autoSize) {
if (autoSize) {
// Modify the eye position by changing the distance from the
focus
// point, while retaining the direction from the specified eye
to
// focus points, so that the bounding box around the mode is
within
// the field of view of the view.
!!!!! CUT - OFF TOPIC CODE !!!!!
}
// Create a Transform3d object, and set it to look at the focus
point
// from the eye position with the specified up vector.
Transform3D initial = new Transform3D();
initial.lookAt(eye, focus, up);
initial.invert();
// update the orbit behavior center of movement to coorespond to the
// focus position we just set.
ob.setRotationCenter(focus);
// Set the transform for the viewplatform using this transformation
matrix
TransformGroup vpTG =
univ.getViewingPlatform().getViewPlatformTransform();
vpTG.setTransform(initial);
}
-----Original Message-----
From: ZACZEK, MARIUSZ P. (MARIO) (JSC-DM) (NASA)
[mailto:[EMAIL PROTECTED]
Sent: Wednesday, April 02, 2003 11:13 AM
To: [EMAIL PROTECTED]
Subject: [JAVA3D] ? OrbitBehavior and LookAt ?
If you use 'OrbitBehavior' is there a way to also use the 'lookAt' function
of
the viewing transform3d correctly? Does anyone have any example code?
I can use the OrbitBehavior but once I do a single rotation of my view and
then
try to use the lookAt function to set my view I don't get the proper result.
Please give me some suggestions.
Mario
Mariusz Zaczek
NASA - Johnson Space Center
Automated Vehicles and Orbit Analysis / DM35
Flight Design and Dynamics Division
Mission Operations Directorate
Bldg: 30A Room: 3040A
Disclaimer: "The opinions, observations and comments expressed in my email
are strictly my own and do not necessarily reflect those of
NASA."
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".
==========================================================================To
unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".