⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 directionallighttest.java

📁 里面 有一些java3d编程的例子
💻 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);
	}
}

⌨️ 快捷键说明

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