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

📄 hellouniverse.html

📁 JAVA多媒体开发类库说明
💻 HTML
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head>  <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">  <title>HelloUniverse</title></head><body><h2>HelloUniverse: A Sample Java3D Program</h2><p>Here are code fragments from a simple program, <code>HelloUniverse.java</code>,that creates a cube and a RotationInterpolator behavior object thatrotates the cube at a constant rate of pi/2 radians per second. TheHelloUniverse class creates the branch graphthat includes the cube and the RotationInterpolator behavior. It thenadds this branch graph to the Locale object generated by theSimpleUniverse utility.</p><pre><hr><br>public class HelloUniverse ... {<br>    public BranchGroup createSceneGraph() {<br><i>        // Create the root of the branch graph<br></i>        BranchGroup objRoot = new BranchGroup();<br><br><i>        // Create the TransformGroup node and initialize it to the<br>        // identity. Enable the TRANSFORM_WRITE capability so that<br>        // our behavior code can modify it at run time. Add it to<br>        // the root of the subgraph.<br></i>        TransformGroup objTrans = new TransformGroup();<br>        objTrans.setCapability(<br>                TransformGroup.ALLOW_TRANSFORM_WRITE);<br>        objRoot.addChild(objTrans);<br><br><i>        // Create a simple Shape3D node; add it to the scene graph.<br></i>        objTrans.addChild(new ColorCube(0.4));<br><br><i>        // Create a new Behavior object that will perform the<br>        // desired operation on the specified transform and add<br>        // it into the scene graph.<br></i>        Transform3D yAxis = new Transform3D();<br>        Alpha rotationAlpha = new Alpha(-1, 4000);<br>        RotationInterpolator rotator = new RotationInterpolator(<br>                rotationAlpha, objTrans, yAxis,<br>                0.0f, (float) Math.PI*2.0f);<br>        BoundingSphere bounds =<br>            new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0);<br>        rotator.setSchedulingBounds(bounds);<br>        objRoot.addChild(rotator);<br><br><i>        // Have Java 3D perform optimizations on this scene graph.</i><br>        objRoot.compile();<br><br>        return objRoot;<br>    }<br><br>    public HelloUniverse() {<br><i>        &lt;set layout of container, construct canvas3d, add canvas3d&gt;<br><br>        // Create the scene; attach it to the virtual universe<br></i>        BranchGroup scene = createSceneGraph();<br>        SimpleUniverse u = new SimpleUniverse(canvas3d);<br>        u.getViewingPlatform().setNominalViewingTransform();<br>        u.addBranchGraph(scene);<br>    }<br>}</pre></body></html>

⌨️ 快捷键说明

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