mousebehaviourexample.java

来自「JAVA3D里面应用MOUSE Behaviour。」· Java 代码 · 共 51 行

JAVA
51
字号

import javax.media.j3d.*;
import javax.vecmath.Point3d;

import com.sun.j3d.utils.behaviors.mouse.*;
import com.sun.j3d.utils.geometry.*;

public class MouseBehaviourExample extends BasicScene
{
  public static void main(String args[]){new MouseBehaviourExample();}
  
  public BranchGroup createContentBranch() 
  {
    BranchGroup root = new BranchGroup();
   
    // Create the TransformGroup that is to be updated
    TransformGroup tg = new TransformGroup();
    tg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    root.addChild(tg);
    
    // Approximate infinite bounds
    BoundingSphere infiniteBounds = new BoundingSphere(new Point3d(), 
        Double.POSITIVE_INFINITY);
    
    // Create the MouseRotate behaviour
    MouseRotate rotate = new MouseRotate(tg);
    rotate.setSchedulingBounds(infiniteBounds);
    tg.addChild(rotate);
    
    // Create the MouseZoom behaviour
    MouseZoom zoom = new MouseZoom(tg);
    zoom.setSchedulingBounds(infiniteBounds);
    tg.addChild(zoom);
    
    // Create the MouseWheelZoom behaviour
    MouseWheelZoom wheelZoom = new MouseWheelZoom(tg);
    wheelZoom.setSchedulingBounds(infiniteBounds);
    tg.addChild(wheelZoom);
    
    // Create the MouseTranslate behaviour
    MouseTranslate translate = new MouseTranslate(tg);
    translate.setSchedulingBounds(infiniteBounds);
    tg.addChild(translate);
    
    ColorCube colorCube = new ColorCube(0.4);
    tg.addChild(colorCube);

    return root;
  }
}

⌨️ 快捷键说明

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