The Artima Developer Community
Sponsored Link

Java Answers Forum
Simple Java 3D - Unable to apply Transform3D to rotate object

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Taarik Z. Rahaman

Posts: 1
Nickname: tzrick
Registered: Jan, 2005

Simple Java 3D - Unable to apply Transform3D to rotate object Posted: Jan 25, 2005 3:10 PM
Reply to this message Reply
Advertisement
Hello experts! Sorry about the formatting...


I have a project that has been quite frustrating to me. Please help me get the rotation work...

Below is a function that is called by clicking on a JButton. This code works:

private void zoom(boolean in) {
Transform3D zoom = world3d.zoom;
zoom.set(zoom.getScale()+(in ? -0.2 : 0.2));
world3d.zoomg.setTransform(zoom); // access member variable
}


However, the procedure doesn't work for rotation as follows:

private void rotateX(boolean cw) {
Transform3D rot = world3d.rotateX;
xrot = xrot + (cw ? 0.1 : -0.1);
rot.rotX (xrot);
world3d.tgRotateX.setTransform(rot); // access member variable
}


The constructor for the World3D class is as follows:

public World3D (Canvas3D canvas3d) {

mainShuttle = new Shuttle (); // returns BranchGroup with 3D object

Transform3D translate = new Transform3D ();
translate.set (new Vector3f (0.15f, 0.0f, 0.7f)); // Translate to fit on screen
TransformGroup tg = new TransformGroup (translate);

zoom.set (0.5);
zoomg = new TransformGroup (zoom); // Allow for dynamic zoom
zoomg.setCapability (TransformGroup.ALLOW_TRANSFORM_READ);
zoomg.setCapability (TransformGroup.ALLOW_TRANSFORM_WRITE);

tgRotateX = new TransformGroup (rotateX); // Allow for dynamic x-rotation
tgRotateX.setCapability (TransformGroup.ALLOW_TRANSFORM_READ);
tgRotateX.setCapability (TransformGroup.ALLOW_TRANSFORM_WRITE);

zoomg.addChild (mainShuttle.getBG ());
tg.addChild (zoomg);
BranchGroup mainScene = new BranchGroup ();
tgRotateX.addChild (tg);
mainScene.addChild (tgRotateX);
mainScene.compile ();

SimpleUniverse simpleU = new SimpleUniverse (canvas3d);

// This moves the ViewPlatform back a bit so the
// objects in the scene can be viewed.
simpleU.getViewingPlatform ().setNominalViewingTransform ();

simpleU.addBranchGraph (mainScene);
}

Topic: Need help in architecture design Previous Topic   Next Topic Topic: Performance in ways of Exception Handling.

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use