Example usage for javax.media.j3d Canvas3D Canvas3D

List of usage examples for javax.media.j3d Canvas3D Canvas3D

Introduction

In this page you can find the example usage for javax.media.j3d Canvas3D Canvas3D.

Prototype

public Canvas3D(GraphicsConfiguration graphicsConfiguration) 

Source Link

Document

Constructs and initializes a new Canvas3D object that Java 3D can render into.

Usage

From source file:YoyoPointApp.java

public YoyoPointApp() {
    setLayout(new BorderLayout());
    Canvas3D canvas3D = new Canvas3D(null);
    add("Center", canvas3D);

    BranchGroup scene = createSceneGraph();

    // SimpleUniverse is a Convenience Utility class
    SimpleUniverse simpleU = new SimpleUniverse(canvas3D);

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

    simpleU.addBranchGraph(scene);//from   www .j  a va  2 s  .  c  o  m
}

From source file:YoyoLineApp.java

public YoyoLineApp() {
    setLayout(new BorderLayout());
    Canvas3D canvas3D = new Canvas3D(null);
    add("Center", canvas3D);

    BranchGroup scene = createSceneGraph();

    // SimpleUniverse is a Convenience Utility class
    SimpleUniverse simpleU = new SimpleUniverse(canvas3D);

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

    simpleU.addBranchGraph(scene);// ww  w .  j  ava2  s.  co m
}

From source file:TextureByReference.java

public void init() {
    if (urls == null) {
        urls = new java.net.URL[defaultFiles.length];
        for (int i = 0; i < defaultFiles.length; i++) {
            try {
                urls[i] = new java.net.URL(getCodeBase().toString() + defaultFiles[i]);
            } catch (java.net.MalformedURLException ex) {
                System.out.println(ex.getMessage());
                System.exit(1);/*w  w w  . ja v  a 2 s .  c  om*/
            }
        }
    }
    setLayout(new BorderLayout());
    GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();

    Canvas3D canvas = new Canvas3D(config);

    add("Center", canvas);

    // create a simple scene graph and attach it to a simple universe
    BranchGroup scene = createSceneGraph();
    universe = new SimpleUniverse(canvas);
    universe.getViewingPlatform().setNominalViewingTransform();
    universe.addBranchGraph(scene);

    // create the gui
    JPanel gui = buildGui();

    this.add("South", gui);
}

From source file:SimpleGeometry.java

public void init() {

    setLayout(new BorderLayout());
    GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();

    Canvas3D c = new Canvas3D(config);
    add("Center", c);

    // Create a simple scene and attach it to the virtual universe
    BranchGroup scene = createSceneGraph();

    u = new SimpleUniverse(c);

    PlatformGeometry pg = createAimer();

    // Now set the just created PlatformGeometry.
    ViewingPlatform vp = u.getViewingPlatform();
    vp.setPlatformGeometry(pg);/*  ww w.j  a v a  2s  .c om*/

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

    // Add everthing to the scene graph - it will now be displayed.
    u.addBranchGraph(scene);
}

From source file:BackgroundGeometry.java

public void init() {

    if (bgImage == null) {
        // the path to the image for an applet
        try {/*from w  w  w .  j  a  v a 2  s .co m*/
            bgImage = new java.net.URL(getCodeBase().toString() + "/bg.jpg");
        } catch (java.net.MalformedURLException ex) {
            System.out.println(ex.getMessage());
            System.exit(1);
        }
    }
    setLayout(new BorderLayout());
    GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();

    Canvas3D c = new Canvas3D(config);
    add("Center", c);

    BranchGroup scene = createSceneGraph();
    u = new SimpleUniverse(c);

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

    TransformGroup viewTrans = u.getViewingPlatform().getViewPlatformTransform();

    // Create the rotate behavior node
    MouseRotate behavior1 = new MouseRotate(viewTrans);
    scene.addChild(behavior1);
    behavior1.setSchedulingBounds(bounds);

    // Create the zoom behavior node
    MouseZoom behavior2 = new MouseZoom(viewTrans);
    scene.addChild(behavior2);
    behavior2.setSchedulingBounds(bounds);

    // Create the translate behavior node
    MouseTranslate behavior3 = new MouseTranslate(viewTrans);
    scene.addChild(behavior3);
    behavior3.setSchedulingBounds(bounds);

    // Let Java 3D perform optimizations on this scene graph.
    scene.compile();

    u.addBranchGraph(scene);
}

From source file:ColorYoyoApp.java

public ColorYoyoApp() {
    setLayout(new BorderLayout());
    Canvas3D canvas3D = new Canvas3D(null);
    add("Center", canvas3D);

    BranchGroup scene = createSceneGraph();

    // SimpleUniverse is a Convenience Utility class
    SimpleUniverse simpleU = new SimpleUniverse(canvas3D);

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

    simpleU.addBranchGraph(scene);//from   w ww  . ja v a2s .  c om
}

From source file:LitTwistApp.java

public LitTwistApp() {
    setLayout(new BorderLayout());
    Canvas3D canvas3D = new Canvas3D(null);
    add("Center", canvas3D);

    BranchGroup scene = createSceneGraph();

    // SimpleUniverse is a Convenience Utility class
    SimpleUniverse simpleU = new SimpleUniverse(canvas3D);

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

    simpleU.addBranchGraph(scene);// w  w w  . j  a  v  a2  s  . c o  m
}

From source file:TwistStripApp.java

public TwistStripApp() {
    setLayout(new BorderLayout());
    Canvas3D canvas3D = new Canvas3D(null);
    add("Center", canvas3D);

    BranchGroup scene = createSceneGraph();

    // SimpleUniverse is a Convenience Utility class
    SimpleUniverse simpleU = new SimpleUniverse(canvas3D);

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

    simpleU.addBranchGraph(scene);/*from w  w  w  . ja v a  2 s .  co  m*/

}

From source file:PickText3DBounds.java

public void init() {
    setLayout(new BorderLayout());
    GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();

    Canvas3D c = new Canvas3D(config);
    add("Center", c);

    u = new SimpleUniverse(c);
    BranchGroup scene = createSceneGraph(c);

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

    u.addBranchGraph(scene);/*  w  w w . jav a2  s.com*/
}

From source file:GearTest.java

public void init() {
    setLayout(new BorderLayout());
    GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();

    Canvas3D c = new Canvas3D(config);
    add("Center", c);

    // Create a simple scene and attach it to the virtual universe
    BranchGroup scene = createSceneGraph(toothCount);
    u = new SimpleUniverse(c);

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

    u.addBranchGraph(scene);//  w  w  w  . ja  v a 2 s. c  om
}