import com.sun.j3d.utils.universe.SimpleUniverse;
import com.sun.j3d.utils.geometry.ColorCube;
import javax.media.j3d.BranchGroup;
public class HelloJava3Da
{
public HelloJava3Da()
{
// Create a virtual universe to contain your scene.
SimpleUniverse universe = new SimpleUniverse();
// Create a data structure to contain a group of objects
BranchGroup group = new BranchGroup();
// Add an object to the group
group.addChild(new ColorCube(0.3));
// Position the viewer so that they are looking at the object
universe.getViewingPlatform().setNominalViewingTransform();
// Add the group of objects to the universe
universe.addBranchGraph(group);
}
public static void main( String[] args )
{
new HelloJava3Da();
}
}
At the Hello3d() constructor, you will see the five lines that perform each of the commented steps. The program displays a glowing cube, the viewer is looking directly at the red face of the cube, so what you actually see is a red square on a black background.
No comments:
Post a Comment