| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1219 人关注过本帖
标题:JAVA3D做这个人多么 好研究不
只看楼主 加入收藏
cdmalcl
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:24
帖 子:4091
专家分:524
注 册:2005-9-23
结帖率:74.19%
收藏
已结贴  问题点数:66 回复次数:9 
JAVA3D做这个人多么 好研究不
想做一些东西 需要JAVA3D实现 做这个的人多不 如果没有好研究不
搜索更多相关主题的帖子: 研究 
2010-07-16 01:12
lampeter123
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:54
帖 子:2508
专家分:6424
注 册:2009-1-30
收藏
得分:33 
下载一个官方3D插件:
JAVA 3D API 最新j3d-1_5_2-windows-i586.exe
https://java3d.dev.

可以画3D的正方体,长方体
程序代码:
// JFrame
import javax.swing.JFrame;

// BorderLayout stuff
import java.awt.*;
import javax.swing.*;

// Canvas3D
import javax.media.j3d.Canvas3D;

// The Universe
import com.sun.j3d.utils.universe.SimpleUniverse;

// The BranchGroup
import javax.media.j3d.BranchGroup;

// For the Box
import com.sun.j3d.utils.geometry.Box;
import javax.vecmath.*;

// The directional light
import javax.media.j3d.DirectionalLight;

// For the bouding sphere of the light source
import javax.media.j3d.BoundingSphere;
import javax.media.j3d.Appearance;
import javax.media.j3d.Material;

// Transformgroup
import javax.media.j3d.TransformGroup;
import com.sun.j3d.utils.behaviors.mouse.*;

public class BasicConstruct extends JFrame
{
    /**
     * The SimpleUniverse object
     */
    protected SimpleUniverse simpleU;

    /**
     * The root BranchGroup Object.
     */
    protected BranchGroup rootBranchGroup;

    /**
     * Constructor that consturcts the window with the given
     * name.
     *
     * @param name The name of the window, in String format
     */
    public BasicConstruct(String name)
    {
        // The next line will construct the window and name it
        // with the given name
        super(name);

        // Perform the initial setup, just once
        initial_setup();
    }

    /**
     * Perform the essential setups for the Java3D
     */
    protected void initial_setup()
    {
        // A JFrame is a Container -- something that can hold
        // other things, e.g a button, a textfield, etc..
        // however, for a container to hold something, you need
        // to specify the layout of the storage. For our
        // example, we would like to use a BorderLayout.
        // The next line does just this:
        getContentPane().setLayout(new BorderLayout());

        // The next step is to setup graphics configuration
        // for Java3D. Since different machines/OS have differnt
        // configuration for displaying stuff, therefore, for
        // java3D to work, it is important to obtain the correct
        // graphics configuration first.
        GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();

        // Since we are doing stuff via java3D -- meaning we
        // cannot write pixels directly to the screen, we need
        // to construct a "canvas" for java3D to "paint". And
        // this "canvas" will be constructed with the graphics
        // information we just obtained.
        Canvas3D canvas3D = new Canvas3D(config);

        // And we need to add the "canvas to the centre of our
        // window..
        getContentPane().add("Center", canvas3D);

        // Creates the universe
        simpleU = new SimpleUniverse(canvas3D);

        // First create the BranchGroup object
        rootBranchGroup = new BranchGroup();
    }

    /**
     * Adds a light source to the universe
     *
     * @param    direction The inverse direction of the
     *                    light
     * @param    color        The color of the light
     */
    public void addDirectionalLight(Vector3f direction, Color3f color)
    {
        // Creates a bounding sphere for the lights
        BoundingSphere bounds = new BoundingSphere();
        bounds.setRadius(1000d);

        // Then create a directional light with the given
        // direction and color
        DirectionalLight lightD = new DirectionalLight(color, direction);
        lightD.setInfluencingBounds(bounds);

        // Then add it to the root BranchGroup
        rootBranchGroup.addChild(lightD);
    }

    /**
     * Adds a box to the universe
     *
     * @param    x    The x dimension of the box
     * @param    y    The y dimension of the box
     * @param    z    The z dimension of the box
     */
    public void addBox(float x, float y, float z, Color3f diffuse, Color3f spec)
    {
        // Add a box with the given dimension

        // First setup an appearance for the box
        Appearance app = new Appearance();
        Material mat = new Material();
        mat.setDiffuseColor(diffuse);
        mat.setSpecularColor(spec);
        mat.setShininess(5.0f);

        app.setMaterial(mat);
        Box box = new Box(x, y, z, app);

        // Create a TransformGroup and make it the parent of the box
        TransformGroup tg = new TransformGroup();
        tg.addChild(box);

        // Then add it to the rootBranchGroup
        rootBranchGroup.addChild(tg);

        tg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
        tg.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);

        MouseRotate myMouseRotate = new MouseRotate();
        myMouseRotate.setTransformGroup(tg);
        myMouseRotate.setSchedulingBounds(new BoundingSphere());
        rootBranchGroup.addChild(myMouseRotate);

        MouseTranslate myMouseTranslate = new MouseTranslate();
        myMouseTranslate.setTransformGroup(tg);
        myMouseTranslate.setSchedulingBounds(new BoundingSphere());
        rootBranchGroup.addChild(myMouseTranslate);

        MouseZoom myMouseZoom = new MouseZoom();
        myMouseZoom.setTransformGroup(tg);
        myMouseZoom.setSchedulingBounds(new BoundingSphere());
        rootBranchGroup.addChild(myMouseZoom);
    }

    /**
     * Finalise everything to get ready
     */
    public void finalise()
    {
        // Then add the branch group into the Universe
        simpleU.addBranchGraph(rootBranchGroup);

        // And set up the camera position
        simpleU.getViewingPlatform().setNominalViewingTransform();
    }

    public static void main(String[] argv)
    {
        BasicConstruct bc = new BasicConstruct("Foo");

        bc.setSize(250, 250);
        bc.addBox(0.4f, 0.5f, 0.6f, new Color3f(1, 0, 0), new Color3f(1, 0, 0));
        bc.addDirectionalLight(new Vector3f(0f, 0f, -1),
                                new Color3f(1f, 1f, 0f));
        bc.finalise();

        bc.show();

        return;
    }
}




你的优秀和我的人生无关!!!!
    
    我要过的,是属于我自己的生活~~~
2010-07-16 17:05
baifenghan
Rank: 8Rank: 8
等 级:贵宾
威 望:10
帖 子:258
专家分:952
注 册:2006-3-17
收藏
得分:33 
这玩意几乎被官方放弃了,哎。。。,这几年没什么进展。
2010-07-17 03:55
lampeter123
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:54
帖 子:2508
专家分:6424
注 册:2009-1-30
收藏
得分:0 
如果要做专业的3D图像,还是用MAYA和3DMAX吧

你的优秀和我的人生无关!!!!
    
    我要过的,是属于我自己的生活~~~
2010-07-17 08:14
cdmalcl
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:24
帖 子:4091
专家分:524
注 册:2005-9-23
收藏
得分:0 
以下是引用baifenghan在2010-7-17 03:55:11的发言:

这玩意几乎被官方放弃了,哎。。。,这几年没什么进展。
为什么放弃这个东西呢
2010-07-18 01:15
cdmalcl
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:24
帖 子:4091
专家分:524
注 册:2005-9-23
收藏
得分:0 
以下是引用lampeter123在2010-7-17 08:14:02的发言:

如果要做专业的3D图像,还是用MAYA和3DMAX吧
MAYA和3DMAX的模型怎么在WEB上显示..
2010-07-18 01:16
lampeter123
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:54
帖 子:2508
专家分:6424
注 册:2009-1-30
收藏
得分:0 
以下是引用cdmalcl在2010-7-18 01:16:26的发言:

MAYA和3DMAX的模型怎么在WEB上显示..
程序代码:
<HTML>

 <HEAD>

 </HEAD>


 <BODY>
  <applet code="ch.randelshofer.rubik.RubikPlayer.class" archive="rubikplayer.jar" codebase="http://www. width="300" height="300">
<param name="colortable" value="0xf8f8f8,0x00732f,0xff4400,0xffd200,0x003373,0x8c000f,0x858585">
<param name="scrptLanguage" value="SupersetENG">
<param name="scrpt" value="R U R'">
<param name="scriptProgress" value="0">
<param name="stickersFront" value="6,6,3,6,3,6,6,3,6">
<param name="stickersRight" value="1,6,6,6,2,6,6,2,6">
<param name="stickersDown" value="6,1,6,1,1,1,6,1,6">
<param name="stickersBack" value="6,2,6,6,6,6,6,6,6">
<param name="stickersLeft" value="6,6,6,6,6,6,6,6,6">
<param name="stickersUp" value="6,3,6,6,6,6,6,6,2">
</applet>

 </BODY>
</HTML>
某个魔方网站的JAVA Applet例子

[ 本帖最后由 lampeter123 于 2010-7-20 16:13 编辑 ]

你的优秀和我的人生无关!!!!
    
    我要过的,是属于我自己的生活~~~
2010-07-20 16:11
SoftWarezx
Rank: 1
等 级:新手上路
威 望:1
帖 子:47
专家分:9
注 册:2010-7-14
收藏
得分:0 
用Java3D做起来很麻烦,用3Dmax比较好,个人认为学Java这方面不用那么太重视,现实中实用的几乎为0。
2010-07-24 19:41
cdmalcl
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:24
帖 子:4091
专家分:524
注 册:2005-9-23
收藏
得分:0 
以下是引用SoftWarezx在2010-7-24 19:41:00的发言:

用Java3D做起来很麻烦,用3Dmax比较好,个人认为学Java这方面不用那么太重视,现实中实用的几乎为0。
..用JAVA读取3DMAX的模型文件 不行么
2010-07-24 22:10
快速回复:JAVA3D做这个人多么 好研究不
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.021135 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved