?? directionallighttest.java
字號:
import java.applet.Applet;
import java.awt.BorderLayout;
import javax.media.j3d.*;
import javax.vecmath.*;
import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j3d.utils.behaviors.mouse.*;
import com.sun.j3d.utils.geometry.*;
import com.sun.j3d.utils.universe.*;
public class DirectionalLightTest extends Applet
{
public BranchGroup createBranchGroup()
{
BranchGroup branch=new BranchGroup();
BoundingSphere bounds=new BoundingSphere();
DirectionalLight light=new DirectionalLight();
light.setInfluencingBounds(bounds);
branch.addChild(light);
TransformGroup trans=new TransformGroup();
trans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
MouseRotate rotate=new MouseRotate(trans);
rotate.setSchedulingBounds(bounds);
branch.addChild(rotate);
Sphere sphere=new Sphere(0.5f);
trans.addChild(sphere);
branch.addChild(trans);
branch.compile();
return branch;
}
public DirectionalLightTest()
{
this.setLayout(new BorderLayout());
Canvas3D c=new Canvas3D(SimpleUniverse.getPreferredConfiguration());
this.add(c,"Center");
SimpleUniverse u=new SimpleUniverse(c);
u.getViewingPlatform().setNominalViewingTransform();
u.addBranchGraph(this.createBranchGroup());
}
public static void main(String[] args)
{
new MainFrame(new DirectionalLightTest(),300,300);
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -