Hello all,
I have used KeyPressed event to zoom on the scene. My Scene is on X-Y axis.
To view the scene from front side, I have rotate the camera on x-axis.
Now to zoom the scene, I should decrease the y-axis.
When I run the program, for the first time that I press z-key it zooms, but to continue it, camera position changes on y-axis. I have attached the code of my camera.
Can you find what is the problem ?
Thanks in advance.
Regards,
Saeed
public void execute() {
mid_city_x = 0.0f;
mid_city_y = 21.0f;
mid_city_y = 21.0f;
z_camera = 150f;
getContentPane().add("Center", canvas3d);
setSize(500, 500);
bgRoot = createSceneGraph();
canvas3d.addKeyListener(this);
camera3d.rotX(1.5f);
Vector3f v3ff = new Vector3f(0.0f, mid_city_y , 200.0f);
su.getViewingPlatform().setNominalViewingTransform();
ViewingPlatform viewingPlatform = su.getViewingPlatform();
View_TransformGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
View_TransformGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
View_TransformGroup = viewingPlatform.getMultiTransformGroup().getTransformGroup(0);
View_Transform3D = new Transform3D();
View_TransformGroup.getTransform(View_Transform3D);
View_Transform3D.setTranslation(v3ff);
camera3d.mul(View_Transform3D);
View_TransformGroup.setTransform(camera3d);
com.sun.j3d.utils.universe.Viewer vi = su.getViewer();
view.setBackClipDistance(150.0);
getContentPane().add("Center", canvas3d);
setSize(500, 500);
bgRoot = createSceneGraph();
canvas3d.addKeyListener(this);
camera3d.rotX(1.5f);
Vector3f v3ff = new Vector3f(0.0f, mid_city_y , 200.0f);
su.getViewingPlatform().setNominalViewingTransform();
ViewingPlatform viewingPlatform = su.getViewingPlatform();
View_TransformGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
View_TransformGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
View_TransformGroup = viewingPlatform.getMultiTransformGroup().getTransformGroup(0);
View_Transform3D = new Transform3D();
View_TransformGroup.getTransform(View_Transform3D);
View_Transform3D.setTranslation(v3ff);
camera3d.mul(View_Transform3D);
View_TransformGroup.setTransform(camera3d);
com.sun.j3d.utils.universe.Viewer vi = su.getViewer();
view.setBackClipDistance(150.0);
View view = vi.getView();
BoundingSphere bounds = new BoundingSphere(new Point3d(0.0f, 0.0f, 0.0f),800D);
BoundingSphere bounds = new BoundingSphere(new Point3d(0.0f, 0.0f, 0.0f),800D);
bgRoot.compile();
su.addBranchGraph(bgRoot);
OrbitBehavior orbit = new OrbitBehavior(canvas3d, OrbitBehavior.REVERSE_ALL);
orbit.setSchedulingBounds(bounds);
viewingPlatform.setViewPlatformBehavior(orbit);
show();
}
su.addBranchGraph(bgRoot);
OrbitBehavior orbit = new OrbitBehavior(canvas3d, OrbitBehavior.REVERSE_ALL);
orbit.setSchedulingBounds(bounds);
viewingPlatform.setViewPlatformBehavior(orbit);
show();
}
public void keyPressed(KeyEvent e) {
char keyChar = e.getKeyChar();
if( keyChar == 'z' || keyChar == 'Z' ){
mid_city_y -= 10;
View_Transform3D.setTranslation(new Vector3f(mid_city_x, mid_city_y, z_camera));
camera3d.rotX(1.5f);
camera3d.mul(View_Transform3D);
View_TransformGroup.setTransform(camera3d);
canvas3d.repaint();
}
if( keyChar == 'x' || keyChar == 'X' ){
mid_city_y += 10;
View_Transform3D.setTranslation(new Vector3f(mid_city_x, mid_city_y, z_camera ));
camera3d.rotX(1.5f);
camera3d.mul(View_Transform3D);
View_TransformGroup.setTransform(camera3d);
canvas3d.repaint();
}
char keyChar = e.getKeyChar();
if( keyChar == 'z' || keyChar == 'Z' ){
mid_city_y -= 10;
View_Transform3D.setTranslation(new Vector3f(mid_city_x, mid_city_y, z_camera));
camera3d.rotX(1.5f);
camera3d.mul(View_Transform3D);
View_TransformGroup.setTransform(camera3d);
canvas3d.repaint();
}
if( keyChar == 'x' || keyChar == 'X' ){
mid_city_y += 10;
View_Transform3D.setTranslation(new Vector3f(mid_city_x, mid_city_y, z_camera ));
camera3d.rotX(1.5f);
camera3d.mul(View_Transform3D);
View_TransformGroup.setTransform(camera3d);
canvas3d.repaint();
}
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
===========================================================================
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".