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

📄 point3d2.java

📁 Java 多媒体技术(附源码) Java 3D API JavaSound API 各种格式的多媒体数据文件 JBuilder开发环境
💻 JAVA
字号:
package point3d2;import java.awt.*;import java.awt.event.*;import java.applet.Applet;import java.awt.BorderLayout;import com.sun.j3d.utils.applet.MainFrame;import com.sun.j3d.utils.universe.*;import javax.media.j3d.*;import javax.vecmath.*;/** * <p>Title: 输出显示三维点</p> * <p>Description: 应用Java 3D API生成三维点</p> * <p>Copyright: Copyright (c) 2004</p> * <p>Company: 北京师范大学计算机系</p> * @author 王大伟 * @version 1.0 */public class Point3D2 extends Applet {  boolean isStandalone = false;  public BranchGroup createSceneGraph() {    BranchGroup objRoot = new BranchGroup();    float vert[] = {        .8f, 0.8f, 0.0f, -0.8f, 0.8f, 0.0f, 0.5f, 0.0f, 0.0f,        -0.5f, 0.0f, 0.0f, -0.8f,-0.8f, 0.0f, 0.8f,-0.8f, 0.0f, };    float color[] = {        0.0f, 0.5f, 1.0f, 0.5f, 0.0f, 1.0f, 0.0f, 0.8f, 2.0f,        1.0f, 0.0f, 0.3f, 0.0f, 1.0f, 0.3f, 0.3f, 0.8f, 0.0f, };        Shape3D shape = new Shape3D();         int[] index={ 0 , 2 , 3 , 4 };        int VertexCount=4;        IndexedPointArray point = new IndexedPointArray(6,IndexedPointArray.COORDINATES|IndexedPointArray.COLOR_3, VertexCount);          point.setCoordinates(0,vert);          point.setColors(0,color);          point.setCoordinateIndices(0,index);          point.setColorIndices(0,index);        PointAttributes pa = new PointAttributes();          pa.setPointSize(20.0f);          pa.setPointAntialiasingEnable(true);        Appearance ap = new Appearance();         ap.setPointAttributes(pa);          shape.setGeometry(point);        shape.setAppearance(ap);        objRoot.addChild(shape);        objRoot.compile();        return objRoot;    }     public Point3D2() {        setLayout(new BorderLayout());        GraphicsConfiguration config =           SimpleUniverse.getPreferredConfiguration();        Canvas3D c = new Canvas3D(config);        add("Center", c);        BranchGroup scene = createSceneGraph();        SimpleUniverse u = new SimpleUniverse(c);        u.getViewingPlatform().setNominalViewingTransform();        u.addBranchGraph(scene);    }  public static void main(String[] args) {    Point3D2 applet = new Point3D2();    applet.isStandalone = true;    Frame frame;    frame = new Frame() {      protected void processWindowEvent(WindowEvent e) {        super.processWindowEvent(e);        if (e.getID() == WindowEvent.WINDOW_CLOSING) {          System.exit(0);        }      }      public synchronized void setTitle(String title) {        super.setTitle(title);        enableEvents(AWTEvent.WINDOW_EVENT_MASK);      }    };    frame.setTitle("显示应用Java 3D API生成的三维点");    frame.add(applet, BorderLayout.CENTER);    applet.init();    applet.start();    frame.setSize(400,320);    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();    frame.setLocation((d.width - frame.getSize().width) / 2, (d.height - frame.getSize().height) / 2);    frame.setVisible(true);  }}

⌨️ 快捷键说明

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