codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  Simple Java 3D - Unable to apply Transform3D to rotate object  TZRick at 23:28 on Tuesday, January 25, 2005
 

Hello experts!

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);
}









CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  Re: Help: Trouble with z-Index and SELECT lists
•  Help with
•  Re: C# and EXCEL question saving a file saving the the first column as read only
•  Iexplore -
•  Iframe and Div Layer Scrollbar Problem
•  Left margin increases as page fills.....
•  Re: Parse error that is slowly driving me insane
•  simple javascript/dhtml drop-down menu
•  notify an object that the user interface has changed one of its properties


Recent Articles
Communicating with the Database (Using ADO)
MagicGrid
Simple Thumbnail Browsing Solution
Type Anywhere
A Better Moustrap: FmtDate to replace FormatDateTime
ASP.NET Forum Source Code
Internal Search Engine
Javascript Growing Window
Simple date validation
Search engine friendly URLs using ASP.NET (C#.NET)


Site Survey
Help us serve you better. Take a five minute survey. Click here!

© Copyright codetoad.com 2001-2005