I need a working example of a virtual universe without using
SimpleUniverse, deriving from Applet or MainFrame. Does this actually work?
All the examples that I have seen use SimpleUniverse and derivce from
Applet which is really lame. I've followed everything in the tutorial as it
says (but of course it offers no complete examples) and it doesn't work at
all. Following is my shot at build it. It shouldn't be this difficult to
get a standalone Java3D application to work! I am very surprised at the
lack of quality in examples and documentation on Java3D that are available!
Sun and the Java3D community should know better...
public class VU
{
public static void main(String[] args)
{
initUniverse();
}
public static void initUniverse()
{
GraphicsEnvironment graphicsEnvironment =
GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice graphicsDevice =
graphicsEnvironment.getDefaultScreenDevice();
GraphicsConfigTemplate3D graphicsConfigTemplate3D = new
GraphicsConfigTemplate3D();
GraphicsConfiguration graphicsConfiguration =
graphicsDevice.getBestConfiguration(graphicsConfigTemplate3D);
Frame mainFrame = new Frame(graphicsConfiguration);
Canvas3D canvas3D = new Canvas3D(graphicsConfiguration);
VirtualUniverse virtualUniverse = new VirtualUniverse();
Locale locale = new Locale(virtualUniverse);// construct and
initialize a new high resolution Locale object located at (0, 0, 0)
View view = new View();
ViewPlatform viewPlatform = new ViewPlatform();
PhysicalBody physicalBody = new PhysicalBody();
PhysicalEnvironment physicalEnvironment = new
PhysicalEnvironment();
view.attachViewPlatform(viewPlatform);
view.setPhysicalBody(physicalBody);
view.setPhysicalEnvironment(physicalEnvironment);
BranchGroup branchGroup = new BranchGroup();
branchGroup.addChild(viewPlatform);
TransformGroup transformGroup = new TransformGroup();
Transform3D transform3D = new Transform3D();
transform3D.setScale(0.4);
transformGroup.setTransform(transform3D);
ColorCube colorCube = new ColorCube(0.2);
transformGroup.addChild(colorCube);
ColoringAttributes sphereColoringAttributes = new
ColoringAttributes();
sphereColoringAttributes.setColor((float)0.3, (float)0.6,
(float)0.9);
Appearance sphereAppearance = new Appearance();
sphereAppearance.setColoringAttributes(sphereColoringAttributes);
Sphere sphere = new Sphere((float)0.3, sphereAppearance);
transformGroup.addChild(sphere);
branchGroup.addChild(transformGroup);
branchGroup.compile();
locale.addBranchGraph(branchGroup);
int screenX = 200;
int screenY = 200;
int windowWidth = 600;
int windowHeight = 600;
mainFrame.setBounds(screenX, screenY, windowWidth, windowHeight);
mainFrame.add(canvas3D);
mainFrame.show();
}
}
===========================================================================
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".