当前位置: 首页>>代码示例>>Java>>正文


Java SimpleUniverse.getViewingPlatform方法代码示例

本文整理汇总了Java中com.sun.j3d.utils.universe.SimpleUniverse.getViewingPlatform方法的典型用法代码示例。如果您正苦于以下问题:Java SimpleUniverse.getViewingPlatform方法的具体用法?Java SimpleUniverse.getViewingPlatform怎么用?Java SimpleUniverse.getViewingPlatform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sun.j3d.utils.universe.SimpleUniverse的用法示例。


在下文中一共展示了SimpleUniverse.getViewingPlatform方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCanvas

import com.sun.j3d.utils.universe.SimpleUniverse; //导入方法依赖的package包/类
/** Get the canvas that displays the scene. If this method is called 
 * several times the same <code>Canvas3D</code> object will be returned 
 * every time.*/
public Canvas3D getCanvas(){
	if(canvas==null){
		//initialBuild();

		//			GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
		GraphicsConfigTemplate3D template = new GraphicsConfigTemplate3D();
		template.setSceneAntialiasing(GraphicsConfigTemplate3D.PREFERRED);
		template.setRedSize(6);
		template.setGreenSize(6);
		template.setBlueSize(6);//Fixes the weird ugly rastering on mac 
		GraphicsConfiguration config =
				GraphicsEnvironment.getLocalGraphicsEnvironment().
				getDefaultScreenDevice().getBestConfiguration(template);

		//			canvas = new HudCanvas3D(config);
		canvas = new Canvas3D(config);

		SimpleUniverse universe = new SimpleUniverse(canvas);
		//universe.getViewer().getView().setProjectionPolicy(View.PARALLEL_PROJECTION);
		universe.addBranchGraph(sceneRoot);
		universe.getViewingPlatform().setNominalViewingTransform();
		universe.getViewer().getView().setLocalEyeLightingEnable(true);

		camera = new Camera(this, universe.getViewingPlatform(), fog);
		//						universe.getViewer().getView().setSceneAntialiasingEnable(true);

		//			CamListener cl = new CamListener();
		//			canvas.addMouseListener(cl);
		//			canvas.addMouseMotionListener(cl);
		//			canvas.addKeyListener(cl);
		//			canvas.addMouseWheelListener(cl);

		//			orbitBehavior = new OrbitBehavior(canvas,
		//					OrbitBehavior.PROPORTIONAL_ZOOM | OrbitBehavior.REVERSE_ROTATE
		//					| OrbitBehavior.REVERSE_TRANSLATE );
		//			orbitBehavior.setSchedulingBounds(bounds);    
		//			universe.getViewingPlatform().setViewPlatformBehavior(orbitBehavior);

		pickCanvas = new PickCanvas(canvas, sceneRoot);
		pickCanvas.setMode(PickCanvas.GEOMETRY);
		addClickListener(new ClickListener(){
			public void shapeClicked(Shape shape, MouseEvent e) {
				if(e.getClickCount()==2 && shape!=null){
					centerCamera(shape.getCenter());
					//						camera.setLookingAt(shape.getCenter());
				}
			}});

		canvas.addMouseListener(new PickListener());

		canvas.getView().setTransparencySortingPolicy(View.TRANSPARENCY_SORT_GEOMETRY);

	}

	return canvas;
}
 
开发者ID:DIKU-Steiner,项目名称:ProGAL,代码行数:60,代码来源:J3DScene.java

示例2: init

import com.sun.j3d.utils.universe.SimpleUniverse; //导入方法依赖的package包/类
private void init( )
{
	canvasComponent.setPreferredSize( new Dimension( 400 , 400 ) );
	canvasComponent.setSize( new Dimension( 400 , 400 ) );
	universe = new SimpleUniverse( this.canvas );
	
	frame = new JFrame( );
	frame.getContentPane( ).setLayout( new BorderLayout( ) );
	
	frame.getContentPane( ).add( BorderLayout.CENTER , canvas );
	
	vp = universe.getViewingPlatform( );
	camera = new Camera3D( vp );
	camera.setLocation( new Point3d( 0 , 2 , 0 ) , true );
	camera.lookAt( new Point3d( 0 , 0 , 0 ) , true );
	
	sceneRoot = new BranchGroup( );
	sceneRoot.setCapability( BranchGroup.ALLOW_CHILDREN_EXTEND );
	sceneRoot.setCapability( BranchGroup.ALLOW_CHILDREN_READ );
	sceneRoot.setCapability( BranchGroup.ALLOW_CHILDREN_WRITE );
	axes = new XyzAxes2( .05f , 1f );
	sceneRoot.addChild( axes );
	
	ambientLight = new AmbientLight( new Color3f( .3f , .3f , .3f ) );
	worldBounds = new BoundingSphere( new Point3d( ) , 10000.0 );
	ambientLight.setInfluencingBounds( worldBounds );
	ambientLight.setCapability( Light.ALLOW_STATE_WRITE );
	sceneRoot.addChild( ambientLight );
	
	sceneTrans = new TransformGroup( );
	sceneTrans.setCapability( TransformGroup.ALLOW_TRANSFORM_WRITE );
	sceneTrans.addChild( sceneRoot );
	
	worldRoot = new BranchGroup( );
	worldRoot.addChild( sceneTrans );
	
	orbiter = new OrbitBehavior( universe.getCanvas( ) );
	orbiter.setSchedulingBounds( worldBounds );
	vp.setViewPlatformBehavior( orbiter );
	
	universe.addBranchGraph( worldRoot );
	
	frame.pack( );
}
 
开发者ID:jedwards1211,项目名称:breakout,代码行数:45,代码来源:Sandbox3D.java

示例3: ObjectLoader

import com.sun.j3d.utils.universe.SimpleUniverse; //导入方法依赖的package包/类
public ObjectLoader() {

		setLayout(new BorderLayout());
		GraphicsConfiguration graphicsConfig = SimpleUniverse
				.getPreferredConfiguration();

		Canvas3D canvas3D = new Canvas3D(graphicsConfig);
		add(canvas3D);
		canvas3D.setSize(1200, 800);
		canvas3D.setVisible(true);

		BranchGroup scene = new BranchGroup();

		ObjectFile loader = new ObjectFile(ObjectFile.LOAD_ALL);
		loader.setFlags(ObjectFile.RESIZE);

		Color3f light1Color = new Color3f(1.8f, 0.1f, 0.1f);

		BoundingSphere bounds =

		new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0);

		Vector3f light1Direction = new Vector3f(2.0f, 12.0f, -12.0f);

		DirectionalLight light1

		= new DirectionalLight(light1Color, light1Direction);

		light1.setInfluencingBounds(bounds);

		scene.addChild(light1);

		Scene modelScene = null;

		try {
			modelScene = loader.load("Images/gargoyle.obj");

		} catch (Exception e) {

		}

		scene.addChild(modelScene.getSceneGroup());

		SimpleUniverse universe = new SimpleUniverse(canvas3D);
		universe.getViewingPlatform().setNominalViewingTransform();

		universe.addBranchGraph(scene);
		
		ViewingPlatform viewPlatform = universe.getViewingPlatform();
	    TransformGroup viewTransform = viewPlatform.getViewPlatformTransform();
	    Transform3D t3d = new Transform3D();
	    viewTransform.getTransform(t3d);
	    t3d.lookAt(new Point3d(0, 0, 4), new Point3d(0, 0, 0), new Vector3d(0, 1, 0));
	    t3d.invert();
	    viewTransform.setTransform(t3d);

	}
 
开发者ID:GettingNifty,项目名称:Heavy-Evil,代码行数:58,代码来源:ObjectLoader.java


注:本文中的com.sun.j3d.utils.universe.SimpleUniverse.getViewingPlatform方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。