Example usage for javax.media.j3d View View

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

Introduction

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

Prototype

public View() 

Source Link

Document

Constructs a View object with default parameters.

Usage

From source file:J3dSwingFrame.java

public Camera() {
    hud_group = new Group();
    hud_group.setCapability(Group.ALLOW_CHILDREN_EXTEND);

    platform = new ViewPlatform();
    location = new Transform3D();

    root_tx_grp = new TransformGroup();
    root_tx_grp.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    root_tx_grp.setTransform(location);/*from   ww  w. j  av  a2s .  co m*/
    root_tx_grp.addChild(platform);
    root_tx_grp.addChild(hud_group);

    // now create the headlight
    headlight = new DirectionalLight();
    headlight.setCapability(Light.ALLOW_STATE_WRITE);
    headlight.setColor(White);
    headlight.setInfluencingBounds(LIGHT_BOUNDS);
    root_tx_grp.addChild(headlight);

    body = new PhysicalBody();
    env = new PhysicalEnvironment();

    view = new View();
    view.setBackClipDistance(BACK_CLIP_DISTANCE);
    view.setPhysicalBody(body);
    view.setPhysicalEnvironment(env);
    view.attachViewPlatform(platform);
}

From source file:Demo3D.java

/**
 * Create the ViewBranch/*from ww  w  .  ja  va2  s . c  o  m*/
 * 
 * @return javax.media.j3d.BranchGroup vbBrGr - the root of the ViewBranch
 */
public BranchGroup myViewBranch() {
    // Create the minimal PhysicalBody and PhysicalEnvironnement
    // instances with default parameters.
    body = new PhysicalBody();
    environment = new PhysicalEnvironment();

    // Create a View instance and attach the Canvas3D, the PhysicalBody
    // and the PhysicalEnvironment to it.
    view = new View();
    view.setFrontClipDistance(0.02); // Default value is 0.1 m
    view.setBackClipDistance(40.0); // Default value is 10 m
    // Rem.: BackClipDistance / FrontClipDistance = 2000 > 1000 but < 3000
    view.addCanvas3D(canvas3D);
    view.setPhysicalBody(body);
    view.setPhysicalEnvironment(environment);
    /*
     * // Choices of the projection type. They are 2 possibilities, namely: //
     * PERSPECTIVE_PROJECTION and PARALLEL_PROJECTION. // Note: the default
     * value is PERSPECTIVE_PROJECTION
     * view.setProjectionPolicy(View.PARALLEL_PROJECTION);
     */
    // Create a ViewPlatform instance and bind it with the View instance.
    viewPlat = new ViewPlatform();
    viewPlat.setActivationRadius(40.0f); // Default value is 62 m
    view.attachViewPlatform(viewPlat);

    // Create the action volume for the camera's navigation.
    cameraBounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0);

    // Create the two necessary TransformGroups for the ViewPlatform's
    // motion (6 translations and 4 rotations).
    vpTrGrKeys_Rot_Up_Down = new TransformGroup();
    vpTrGrKeys_Transl_Turn = new TransformGroup();

    // With the ALLOW_TRANSFORM_READ and ALLOW_TRANSFORM_WRITE
    // capabilities, we allow the modification of the TransformGroup's
    // code by the Behavior's code at run time.
    vpTrGrKeys_Transl_Turn.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
    vpTrGrKeys_Transl_Turn.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);

    vpTrGrKeys_Rot_Up_Down.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
    vpTrGrKeys_Rot_Up_Down.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);

    // Attach the ViewPlatform to the vpTrGrKeys_Rot_Up_Down node.
    vpTrGrKeys_Rot_Up_Down.addChild(viewPlat);

    // Create and attach an aimer to the TransformGroup node
    // vpTrGrKeys_Rot_Up_Down.
    aimer = new Aimer(1.5f);
    vpTrGrKeys_Rot_Up_Down.addChild(aimer.myAimer());

    // View-platform's motion ==> camera's navigation: 6 translations and 4
    // rotations.

    // Create and attach the camera's rotation on the vpTrGrKeys_Rot_Up_Down
    // node.
    camera_Rot_Up_Down = new Camera_Rot_Up_Down(vpTrGrKeys_Rot_Up_Down);
    camera_Rot_Up_Down.setSchedulingBounds(cameraBounds);
    vpTrGrKeys_Rot_Up_Down.addChild(camera_Rot_Up_Down);

    // Create and attach the camera's translation and rotation instances
    // on the vpTrGrKeys_Transl_Turn node.
    camera_Transl_Turn = new Camera_Transl_Turn(vpTrGrKeys_Transl_Turn);
    camera_Transl_Turn.setSchedulingBounds(cameraBounds);
    vpTrGrKeys_Transl_Turn.addChild(camera_Transl_Turn);

    // Attach the vpTrGrKeys_Rot_Up_Down node to the vpTrGrKeys_Transl_Turn
    // node.
    vpTrGrKeys_Transl_Turn.addChild(vpTrGrKeys_Rot_Up_Down);

    // Give the starting position of the ViewPlatform.
    trStart = new Transform3D(); // Identity matrix
    trStart.set(new Vector3f(0.0f, 0.0f, 10.0f)); // Translation of the
    // camera (0,0,10)

    // Create the TransformGroup node for the ViewPlatform's
    // starting position.
    vpTrGrStart = new TransformGroup(trStart);

    // Attach the vpTrGrKeys_Transl_Turn node to the TransformGroup
    // node vpTrGrStart.
    vpTrGrStart.addChild(vpTrGrKeys_Transl_Turn);

    // Add the TransformGroup node vpTrGrStart to the view
    // BranchGroup node vbBrGr.
    vbBrGr = new BranchGroup();
    vbBrGr.addChild(vpTrGrStart);

    // Compile the ViewBranch to optimize the performances.
    vbBrGr.compile();

    // Return the final version of the view branch BranchGroup node vbBrGr.
    return vbBrGr;
}

From source file:MixedTest.java

protected View createView(ViewPlatform vp) {
    View view = new View();

    PhysicalBody pb = createPhysicalBody();
    PhysicalEnvironment pe = createPhysicalEnvironment();

    AudioDevice audioDevice = createAudioDevice(pe);

    if (audioDevice != null) {
        pe.setAudioDevice(audioDevice);/*from  w ww . j  a v a 2s  .com*/
        audioDevice.initialize();
    }

    view.setPhysicalEnvironment(pe);
    view.setPhysicalBody(pb);

    if (vp != null)
        view.attachViewPlatform(vp);

    view.setBackClipDistance(getBackClipDistance());
    view.setFrontClipDistance(getFrontClipDistance());

    Canvas3D c3d = createCanvas3D();
    view.addCanvas3D(c3d);
    addCanvas3D(c3d);

    return view;
}