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

📄 text_ball.java

📁 使用java3d进行,obj文件的加载.和实现全方位的3维场景交互
💻 JAVA
字号:
package csu.chailei.test;
import com.sun.j3d.utils.geometry.*;
import com.sun.j3d.utils.universe.*;
import javax.media.j3d.*;
import com.sun.j3d.utils.geometry.Box;
import javax.media.j3d.Appearance;
import javax.vecmath.*;
public class Text_Ball {

	/**
	 * @param args
	 */
	public Text_Ball()
	{
		//new Universe
		SimpleUniverse universe=new SimpleUniverse();
	    //new Branch
		BranchGroup group=new BranchGroup();
		//new a spere add group
	     Sphere sphere=new Sphere(0.3f);
		//Sphere sphere2=new Sphere(0.2f);
		group.addChild(sphere);
		//group.addChild(sphere2);
		Appearance ap=new Appearance();
		Color3f ac=new Color3f(1.2f,1.1f,0.1f);
		ColoringAttributes c=new ColoringAttributes(ac,ColoringAttributes.NICEST);
		
		ap.setColoringAttributes(c);
		sphere.setAppearance(ap);
		//Box b=new Box(0.3f,0.3f,0.3f,ap);
		//group.addChild(b);
		//Appearance a=new Appearance(); 
		//new a light
		
		Color3f lightColor=new Color3f(1.8f,0.1f,0.1f);//color
		BoundingSphere bounds=new BoundingSphere(new Point3d(0.0,0.0,0.0),100.0);//point radium
		
		Vector3f lightDirection=new Vector3f(-8.0f,-7.0f,-12.0f);//derection
		
		DirectionalLight light1=
			new DirectionalLight(lightColor,lightDirection);
	     light1.setInfluencingBounds(bounds);
	     group.addChild(light1);
	     
	     //view spere
	     universe.getViewingPlatform().setNominalViewingTransform();
	     //add to universe
	     universe.addBranchGraph(group);
	
	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Text_Ball();
	}

}

⌨️ 快捷键说明

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