Skip to main content

MouseRotate/MouseZoom doesn't work

7 replies [Last post]
mu88
Offline
Joined: 2012-08-30
Points: 0

Hello,

I'm trying to to visualize sample points by spheres in Java3D. The coordinates of the sample points are about {x|y|z} = {4500000...4600000|5600000...5700000|-100...100}.

I use MouseTranslate, MouseRotate and MouseZoom to navigate through the 3D-space.

If I subtract values {x|y} = {4550000|5650000} while importing the sample points (so that my coordinates are quite small), I can rotate, translate and zoom without any problems, everything is fine.

But if I don't subtract, I have to translate the view, of course. This works also, I can see the sample points in X-Y-view, but rotating and zooming is not possible, the points just disappear, without any error message! Whereas Translating is possible.

The bounding sphere is translated to the position where the view is located.

Can anyone tell me why I don't see the sample points while rotating or zooming at the not-subtracted positions?

Kind regards

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
interactivemesh
Offline
Joined: 2006-06-07
Points: 0

Check your settings for the view model's back and front clip distances:

javax.media.j3d.View.getBackClipDistance()
javax.media.j3d.View.setBackClipDistance(double distance)
javax.media.j3d.View.getFrontClipDistance()
javax.media.j3d.View.setFrontClipDistance(double distance)

August

mu88
Offline
Joined: 2012-08-30
Points: 0

Hey,

my FrontClipDistance is 6 and my BackClipDistance 6000. But why should this be important? I don't shift the Z-value, only the X-Y-position in comparison to the situation when subtracting the coordinate correction.

Kind regards

interactivemesh
Offline
Joined: 2006-06-07
Points: 0

MouseRotate rotates the content of its TransformGroup around the center of the universe (0,0,0). A 90 degree rotation around the y-axis will move a point from (4550000, 5650000, 0) to (0, 5650000, -4550000) and therefore far behind the back clip plane with a distance of 6000 as well as outside of the view frustum if the ViewPlatform is located at (4550000, 5650000, 100).

'com.sun.j3d.utils.behaviors.vp.OrbitBehavior' or the derived work 'OrbitBehaviorInterim' (http://www.interactivemesh.org/testspace/orbitbehavior.html) might be helpful. They allow to set an arbitrary center of rotation.

August

mu88
Offline
Joined: 2012-08-30
Points: 0

Okay, I did the following:

center = new Point3d(4603400, 5696800, 0);
ViewingPlatform vPlatform = simpleUniverse.getViewingPlatform();
OrbitBehavior orbit = new OrbitBehavior(canvas);
orbit.setRotationCenter(center);
orbit.setSchedulingBounds(boundingSphere);
vPlatform.setViewPlatformBehavior(orbit);

ViewingPlatform vPlatform = simpleUniverse.getViewingPlatform();
OrbitBehavior orbit = new OrbitBehavior(canvas);
orbit.setRotationCenter(center);
orbit.setSchedulingBounds(boundingSphere);
vPlatform.setViewPlatformBehavior(orbit);

Viewer viewer = simpleUniverse.getViewer();
View view = viewer.getView();
view.setProjectionPolicy(View.PARALLEL_PROJECTION); // parallel projection
//view.setFrontClipDistance(6);
view.setBackClipDistance(6000);
view.setScreenScalePolicy(View.SCALE_EXPLICIT);
view.setScreenScale(.0001);

center.z = 3000;
Transform3D camera_transform = new Transform3D();
camera_transform.setTranslation(new Vector3d(center.x, center.y, center.z));

TransformGroup camera_transform_group = simpleUniverse.getViewingPlatform().getViewPlatformTransform();
camera_transform_group.setTransform(camera_transform);

I had to disable the FrontClipDistance (that means back to default) because with a value of 6 I see anything.
Nevertheless, the problem stays the same, as soon as I zoom or rotate, everything disappears. What I'm doing wrong?

interactivemesh
Offline
Joined: 2006-06-07
Points: 0

PARALLEL_PROJECTION wasn't mentioned so far! Neither MouseRotate nor OrbitBehavior will handle parallel projection correctly. Do the objects also disappear in perspective mode?

So, have a look at 'OrbitBehaviorInterim' and the source code of the sample 'SimpleUniverse Navigation 2' (http://www.interactivemesh.org/testspace/orbitbehavior.html).

Unfortunately, I can't respond during the next 10 days. Good luck, August

mu88
Offline
Joined: 2012-08-30
Points: 0

Okay, I switched back to perspective mode, the objects also disappear, but it seems that I can rotate maybe a half or one degree before disappearing.

I still don't understand, why this happens, I changed the extent of the bounding sphere, the orbit behaviour, front- and back clipping plane...

The way to subtract a defined value from the coordinates works, but it's an ugly hack =/

mu88
Offline
Joined: 2012-08-30
Points: 0

*push*