现在我们老师要求我们能够实现2维的三角形转化成三维图形,要用java 3d实现,小弟逛遍了论坛没有找到合适的答案,请各问大虾行行好,救救小弟一命吧。。在此先行谢过了。。
解决方案 »
- pdf到png的转换(java)
- 如何加密二进制文件
- 如何在一个有n个字符的一位数组中找到包含k个字符组合的全部集合,
- 一个爬虫,怎样一边抓取网页一边在JTree中显示
- 请问, 正则表达式如何表示一个不是数字的字符?
- 如何取得方法调用者--注意,要对象,不要类名
- 奇怪的例子,Java中switch() 中可以用字符串来进行判断吗?
- 请大家帮忙写个方法,要求输入两个int a,b,然后计算a/b,输出百分数的形式,比如输入2和3,输入67,请问如何实现?
- 菜鸟的疑惑,为什么我现在编写代码还要看书?大人截获
- 诚聘精通C++和java的同志。
- 能输入2个KEY,获取一个value吗?
- jvm线程调度!
import com.sun.j3d.utils.applet.MainFrame;import com.sun.j3d.utils.universe.SimpleUniverse;import javax.media.j3d.*;import javax.vecmath.Point3f;import java.applet.Applet;import java.awt.*;/** * Triangle: a simple triangle * * @author Kevin J. Duling ([email protected]) */public final class Triangle extends Applet{ /** * Default constructor. Here we create the universe. */ public Triangle() { setLayout(new BorderLayout()); Canvas3D canvas = createCanvas(); add("Center", canvas); SimpleUniverse u = new SimpleUniverse(canvas); BranchGroup scene = createContent(); u.getViewingPlatform().setNominalViewingTransform(); // back away from object a little scene.compile(); u.addBranchGraph(scene); } /** * Create a canvas to draw the 3D world on. */ private Canvas3D createCanvas() { GraphicsConfigTemplate3D graphicsTemplate = new GraphicsConfigTemplate3D(); GraphicsConfiguration gc1 = GraphicsEnvironment.getLocalGraphicsEnvironment() .getDefaultScreenDevice().getBestConfiguration(graphicsTemplate); return new Canvas3D(gc1); } /** * Fill your 3D world with content */ private BranchGroup createContent() { BranchGroup objRoot = new BranchGroup(); // Create a triangle with each point a different color. Remember to // draw the points in counter-clockwise order. That is the default // way of determining which is the front of a polygon. // o (1) // / \ // / \ // (2) o-----o (0) Shape3D shape = new Shape3D(); TriangleArray tri = new TriangleArray(3, TriangleArray.COORDINATES); tri.setCoordinate(0, new Point3f(0.5f, 0.0f, 0.0f)); tri.setCoordinate(1, new Point3f(0.0f, 0.5f, 0.0f)); tri.setCoordinate(2, new Point3f(-0.5f, 0.0f, 0.0f)); shape.setGeometry(tri); objRoot.addChild(shape); return objRoot; } /** * This is our entrypoint to the application. This code is not called when the program runs as an applet. * * @param args - command line arguments (unused) */ public static void main(String args[]) { // MainFrame allows an applet to run as an application Frame frame = new MainFrame(new Triangle(), 320, 280); // Put the title in the application titlebar. The titlebar // isn't visible when running as an applet. frame.setTitle("A Simple Triangle"); }}