java left logo
java middle logo
java right logo
 

Home arrow Other API Tips
 
 
Main Menu
Home
Java Tutorials
Book Reviews
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Java Network
Java Forums
Java Blog




Most Visited Tips
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Book Reviews
Top Rated Tips
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Book Reviews


Statistics
Registered Users: 4089
Java SE Tips: 614
Java ME Tips: 202
Java EE Tips: 183
Other API Tips: 779
Java Applications: 298
Java Libraries: 209
Java Games: 16
Book Reviews:
 
 
 
Using Behavior Utility Classes for Keyboard Navigation E-mail
User Rating: / 1
PoorBest 

It is easy to use the KeyNavigatorBehavior utility class in a Java 3D program. Here is the recipe:

  1. create a KeyNavigatorBehavior object, setting the transform group
  2. add the KeyNavigatorBehavior object to the scene graph
  3. provide a bounds (or BoundingLeaf) for the KeyNavigatorBehavior object

In this program you can see that the steps involved in using the KeyNavigatorBehavior class are essentially identical to those of using any behavior class.

public BranchGroup createSceneGraph(SimpleUniverse su) {
    TransformGroup vpTrans = null;

    BranchGroup objRoot = new BranchGroup();

    Vector3f translate = new Vector3f();
    Transform3D T3D = new Transform3D();
    TransformGroup TG = null;

    objRoot.addChild(createLand());

    SharedGroup share = new SharedGroup();
    share.addChild(createPyramid());

    float[][] position = { { 0.0f0.0f, -3.0f }6.0f0.0f0.0f },
        6.0f0.0f6.0f }3.0f0.0f, -10.0f },
        13.0f0.0f, -30.0f }-13.0f0.0f30.0f },
        -13.0f0.0f23.0f }13.0f0.0f3.0f } };

    for (int i = 0; i < position.length; i++) {
      translate.set(position[i]);
      T3D.setTranslation(translate);
      TG = new TransformGroup(T3D);
      TG.addChild(new Link(share));
      objRoot.addChild(TG);
    }
    vpTrans = su.getViewingPlatform().getViewPlatformTransform();
    translate.set(0.0f0.3f0.0f);
    T3D.setTranslation(translate);
    vpTrans.setTransform(T3D);
    KeyNavigatorBehavior keyNavBeh = new KeyNavigatorBehavior(vpTrans);
    keyNavBeh
        .setSchedulingBounds(new BoundingSphere(new Point3d()1000.0));
    objRoot.addChild(keyNavBeh);

    objRoot.compile();

    return objRoot;
}

 Related Tips

 
< Prev   Next >

Page 1 of 0 ( 0 comments )

You can share your information about this topic using the form below!

Please do not post your questions with this form! Thanks.


Name (required)


E-Mail (required)

Your email will not be displayed on the site - only to our administrator
Homepage(optional)



Comment Enable HTML code : Yes No



 
       
         
     
 
 
 
   
 
 
java bottom left
java bottom middle
java bottom right
RSS 0.91 FeedRSS 1.0 FeedRSS 2.0 FeedATOM FeedOPML Feed

Home - About Us - Privacy Policy
Copyright 2005 - 2008 www.java-tips.org
Java is a trademark of Sun Microsystems, Inc.