move_in_axis_direction.java

来自「一个java3D的动画程序」· Java 代码 · 共 55 行

JAVA
55
字号
/*
 * Created on 2005-7-17
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package Move;

/**
 * @author carso
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
import com.sun.j3d.utils.geometry.ColorCube; 
import javax.media.j3d.*; 
import javax.vecmath.*;


public class Move_In_Axis_direction {
	
	 public BranchGroup Move_in_direction(float startpoint,float endpoint){
	 	BranchGroup objRoot=new BranchGroup();
	 	BranchGroup bg_createAnim=null;
	 	//set bounding sphere
	 	BoundingSphere bound=new BoundingSphere(new Point3d(0.0,0.0,0.0),400.); 

	 	//create a TransformGroup
	 	Transform3D tr1=new Transform3D();
	 	TransformGroup trans1=new TransformGroup(tr1);
	 	trans1.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
	 	
	 	//create a Color cube
	 	ColorCube cube1=new ColorCube(0.5);
	 	trans1.addChild(cube1);
	 	
	 	//set cube1 to move 
	 	Alpha xtranAlpha = new Alpha(-1, 
                Alpha.DECREASING_ENABLE|Alpha.INCREASING_ENABLE, 
				 0, 0,0, 0, 0,2000, 0, 0);
	 	PositionInterpolator pos1=new PositionInterpolator(xtranAlpha,trans1,tr1,startpoint,endpoint);
	 	pos1.setSchedulingBounds(bound);
	 	trans1.addChild(pos1);
   
   
	 	objRoot.addChild(trans1);
        return objRoot;
	 }
	 public Move_In_Axis_direction()
	 {
	 	System.out.println("Move_In_Axis_direction Class draw a cube and move in a direction");
	 	
	 }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?