Hey all,
I’m having a bit of trouble getting started with Java 3D… I can get a BranchGroup to render and all, rotate a cube, etc. But after the scene is compiled (BranchGroup.compile()), I can’t set the Transform3D object on my TransformGroup object. Here’s my code:
[quote]import java.awt.;
import javax.swing.;
import javax.media.j3d.;
import com.sun.j3d.utils.universe.;
import com.sun.j3d.utils.geometry.*;
public class Test extends JFrame {
TransformGroup cubeTG = new TransformGroup();
public Test() {
setSize(400, 300);
setResizable(false);
setDefaultCloseOperation(EXIT_ON_CLOSE);
GraphicsConfiguration gc = SimpleUniverse.getPreferredConfiguration();
Canvas3D c = new Canvas3D(gc);
getContentPane().add(c);
BranchGroup scene = new BranchGroup();
scene.addChild(cubeTG);
cubeTG.addChild(new ColorCube(0.4));
scene.compile();
SimpleUniverse su = new SimpleUniverse(c);
su.getViewingPlatform().setNominalViewingTransform();
su.addBranchGraph(scene);
setVisible(true);
while(true) {
Transform3D t3d = new Transform3D();
cubeTG.getTransform(t3d);
t3d.rotY(Math.toRadians(1));
cubeTG.setTransform(t3d);
}
}
public static void main(String args[]) {
new Test();
}
}
[/quote]
I recieve the following exception:
[quote]Exception in thread “main” javax.media.j3d.CapabilityNotSetException: Group: no
capability to set transform
at javax.media.j3d.TransformGroup.setTransform(TransformGroup.java:115)
at Test.(Test.java:38)
at Test.main(Test.java:43)
[/quote]
If I can’t set the transform on an object after the scene has been compiled, how can I render in real time (for 3D games…)?