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: 4097
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:
 
 
 
Adding Animation Behavior to the Cube E-mail
User Rating: / 1
PoorBest 

When the proper capability is set,the content of virtual world can be modified at runtime. So if we can change the content continuously with time lapsing, we can add the animation behavior to the virtual object.

Java3D provides some Interpolator classes to do this work.Through using the subclasses of Interpolator class, we can add many animation behaviors to the virtual object.

This program illustrates how to add the rotation behavior to the Cube by RotationInterpolator class.

public class RotationBehavior extends JFrame {
  public RotationBehavior() {
    ...
  

  public BranchGroup createSceneGraph() {
    // Create the root of the branch graph
    BranchGroup objRoot = new BranchGroup();
    
    // Create the transform group node with the proper capiability
    TransformGroup objSpin=new TransformGroup();
    objSpin.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    objRoot.addChild(objSpin);
    
    objSpin.addChild(new ColorCube(0.4));
    
    // Create time varying function to drive the animation
    Alpha rotationAlpha=new Alpha(-1,4000);
    
    // Create a new Behavior object that performs the desired
    // operation on the specified transform object and add it into
    // the scene graph.
    RotationInterpolator rotator=new RotationInterpolator(rotationAlpha,objSpin);
    
    //a bounding sphere specifies a region a behavior is active
    BoundingSphere bounds=new BoundingSphere();
    rotator.setSchedulingBounds(bounds);
    objSpin.addChild(rotator);

    return objRoot;
  }
  
  public static void main(String[] args){
    ...
  }
}

 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.