开发工具:
文件大小: 13kb
下载次数: 0
上传时间: 2008-12-29
详细说明: //存为MoFang.java import java.applet.Applet ; import java.awt.*; import com.sun.j3d.utils.applet.MainFrame ; import java.awt.BorderLayout ; import com.sun.j3d.utils.universe.SimpleUniverse ; import javax.media.j3d.*; import javax.vecmath.*; import com.sun.j3d.utils.behaviors.mouse.*; import com.sun.j3d.utils.behaviors.keyboard.*; import com.sun.j3d.utils.picking.behaviors.*; import com.sun.j3d.utils.geometry.*; import com.sun.j3d.utils.image.TextureLoader ; import javax.swing.*; import java.awt.*; import java.awt.event.*; import javax.swing.JFrame.*; import javax.swing.*; class mySimpleUniverse extends Applet { BranchGroup createSceneGraph(Canvas3D canvas) { //System.out.print("**1**"); //创建变换组,无用的t3D Transform3D t3d=new Transform3D(); TransformGroup trans=new TransformGroup(t3d); trans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); trans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); //创建分枝组 BranchGroup objRoot=new BranchGroup(); //测试 //SomeShape3D.book3D( this, trans); SomeShape3D.addText3DDonghua(trans,"魔方",new Point3f(-7.0f,6.0f,6.0f),0.1f,new Color3f(1.0f,0.0f,0.0f),1); //初始化数据结构 System.out.println("\n\n载入方块,并向变换组中加入每个方块的坐标系和方块..."); for(int i=0;i<=2;i++) for(int j=0;j<=2;j++) for(int k=0;k<=2;k++) { int[] p; p=Position.getPxyzFromPositionAy(i,j,k,MoFang.positionArray); MoFang.blockArray[i][j][k]=new Block(i,j,k,p[0],p[1],p[2],trans,t3d,objRoot,this); } System.out.println("加入每个方块的坐标系和方块,完成.\n"); //创建大坐标轴,自动加到主坐标系 SomeShape3D.zuoBiaoZhuBigXShape3D(trans); SomeShape3D.zuoBiaoZhuBigYShape3D(trans); SomeShape3D.zuoBiaoZhuBigZShape3D(trans); //创建边界对象 BoundingSphere bounds=new BoundingSphere(new Point3d(0.0,0.0,0.0),100); //创建鼠标pick行为,加到分支组objRoot PickRotateBehavior pickRotate=new PickRotateBehavior(objRoot,canvas,bounds); PickTranslateBehavior pickTranslate=new PickTranslateBehavior(objRoot,canvas,bounds); PickZoomBehavior pickZoom=new PickZoomBehavior(objRoot,canvas,bounds); //objRoot.addChild(pickRotate); objRoot.addChild(pickTranslate); //objRoot.addChild(pickZoom); //创建鼠标旋转行为 MouseRotate behavior=new MouseRotate(); behavior.setTransformGroup(trans); behavior.setSchedulingBounds(bounds); //创建鼠标平移行为 //MouseTranslate myMouseRotate=new MouseTranslate(); //myMouseRotate.setTransformGroup(trans); //myMouseRotate.setSchedulingBounds(bounds); ...展开收缩
(系统自动生成,下载前可以参看下载内容)
下载文件列表
相关说明
- 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
- 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度。
- 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
- 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
- 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
- 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.