亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? load3ds.java

?? 包括了JAVA3D(全世界都能看到的網絡三維動畫)的源代碼部分! 很多基礎但是卻很精彩的例子!有什么不明白的也可以和我交流MSN:guorui0728@hotmail.com
?? JAVA
?? 第 1 頁 / 共 4 頁
字號:
/*
 * Copyright 1998 Hewlett-Packard Company
 *
 * This file may be copied, modified and distributed only in
 * accordance with the terms of the limited licence contained
 * in the accompanying file LICENSE.TXT.
 */

//package hplb.java3d;

import  java.io.*;
import  java.util.*;
import  java.awt.Component;

import  javax.media.j3d.*;
import  javax.vecmath.*;
import  com.sun.j3d.utils.image.TextureLoader;

/**
 *  .3DS format model loader for Java3D.
 *  @author Rycharde Hawkes
 *  @version 1.0
 */

public class Load3DS
{
    static final int        MAX_SURFACES    = 33;
    static final int        verbosity       = 0;

    int                     totalPolygons   = 0;
    int                     totalVertices   = 0;

    //
    // Root of the scene graph for the file.
    //

    BranchGroup             root            = null;

    //
    // Lookup table of instances of SharedObjects held
    // in <objectTable>, indexed by name.
    //

    Hashtable               instanceTable   = null;

    //
    // Lookup table of all SharedObjects created,
    // indexed by name.
    //

    Hashtable               objectTable     = null;

    //
    // Refers to the object currently being constructed.
    //

    SharedGroup             object          = null;

    //
    // Refers to the shape component of the object
    // currently being constructed.
    //

    Shape3D                 shape           = null;

    //
    // <geometry>     == current object's geometry.
    // <noofVertices> == number of vertices in the face list.
    // <vertices>     == vertex array.
    // <noofFaces>    == number of faces in the object.
    // <faces>        == list of all the faces in the object.
    // <sharedFaces>  == list of vertices constructing each face.
    // <surfaces>     == list of surfaces making up geometry.
    // <textureCoords>== list of geometry's texture coordinates.
    //

    TriangleArray           geometry        = null;
    int                     noofVertices    = 0;
    Point3f[]               vertices        = null;
    int                     noofFaces       = 0;
    Face[]                  faces           = null;
    Vector[]                sharedFaces     = null;
    Surface[]               surfaces        = null;
    Point2f[]               textureCoords   = null;

    //
    // Used to indicate whether surfaces were specified
    // and created.
    //

    boolean                 surfacesCreated = true;

    //
    // A lookup table of Appearance objects representing
    // the materials in the file, indexed by material name.
    //

    Hashtable               mats            = null;

    //
    // <mat> refers to 3DS material currently being constructed.
    // <matName> is that name of the 3DS material.
    // <material> refers to the counterpart Java3D Material.
    //

    Appearance              mat             = null;
    String                  matName         = null;
    Material                material        = null;

    //
    // <shininess>    == 3DS shininess percentage.
    //

    float                   shininess       = 0.0f;

    //
    // Provided by the constructor of this object, needed
    // by the TextureLoader class.
    //

    Component               component       = null;

    //
    // <nodeName>     == name of a referenced SharedObject.
    // <instanceName> == name of an instance of a SharedObject.
    //

    String                  nodeName        = null;
    String                  instanceName    = null;

    //
    // <translation>  == positional component of the objects' transform.
    // <orientation>  == rotational component of the objects' transform.
    // <scale>        == scalar component of the objects' transform.
    //

    Vector3f                translation     = null;
    Matrix4f                orientation     = null;
    Vector3f                scale           = null;


	String					path 			= null;

    /**
     * <p>Given a <i>filename</i>, Load3DS will construct an appropriate Java3D scene graph
     * - accessible from Load3DS.root().  It also constructs a table of <i>objects</i>,
     * indexed by their proper name and a table of <instances> of those objects which
     * are refered to by ther instance name.  Currently, only two <properties> are
     * returned, "polygons" and "vertices", the value of which are a java.lang.Integer
     * giving the total number of polygons and vertices in the .3DS file respectively.</p>
     * <p>Limitations of the current version:
     * <li>Lights are not created.</li>
     * <li>Interpretation of 3DS's shininess and shininess strength could be better.</li>
     * <li>Only handles those texture map image formats supported by com.sun.j3d.utils.image.TextureLoader.</li>
     * </p>
     * <p>Java3Disms:
     * <li>3DS wireframe material = PolygonAttributes.POLYGON_LINE</li>
     * <li>3DS metal-shaded material = PolygonAttributes.POLYGON_POINT</li>
     * <li>3DS constant-shaded material = PolygonAttributes.POLYGON_FILL</li>
     * <li>3DS phong-shaded material = PolygonAttributes.POLYGON_PHONG</li>
     * <li>Hidden objects don't seem to be set by 3DSMax.  Load3DS simulates this
     * by hiding objects whose names begin with '$'.</li>
     * <li>Note that only 3DS planar mapping generates correct 2D texture coords.</li>
     * <li>1 generic 3DSMax unit = 1 Java3D unit.  This loader does not handle other 3DSMax units,
     * e.g. metric.</li>
     * </p>
     * <p>Known bugs:
     * <li>Normal calculation fails for certain surfaces.</li>
     * @param filename .3DS file to load.
     * @param component parent java.awt.Component (needed by com.sun.j3d.utils.image.TextureLoader).
     * @param objects table of named objects indexed by object name.  name-value pairs
     * are a string and a SharedGroup respectively.
     * @param instances table of instanced objects indexed by instance name.  name-value
     * pairs are a string and a TransformGroup respectively.
     * @param properties information about the .3DS file.
     * @exception IOException any failure to process .3DS file.
     * @see com.sun.j3d.utils.image.TextureLoader
     */

    public Load3DS( String filename, Component component,
                      Hashtable objects, Hashtable instances,
                      Properties properties )
                throws IOException
    {
    	//System.out.println( "Load3DS: loading '" + filename + "'..." );
		path = (new java.io.File( filename )).getParent();
		if ( path == null )
		{
			path = ".\\";
		}

		System.out.println( "Load3DS: using path = " + path );
        RandomAccessFile    in  = new RandomAccessFile( filename, "r" );

        this.component   = component;
        root        = new BranchGroup();        // Root of scene graph for this file.
        mats        = new Hashtable();

        objectTable     = objects;
        instanceTable   = instances;

        try
        {
            for ( ;; )
            {
                processChunk( in );
            }
        }
        catch ( EOFException e )
        {
        }

        properties.put( "polygons", Integer.toString( totalPolygons ) );
        properties.put( "vertices", Integer.toString( totalVertices ) );
    }


    void prepareForNewObject()
    {
        object          = null;
        shape           = null;
        geometry        = null;
        noofVertices    = 0;
        vertices        = null;
        sharedFaces     = null;
        noofFaces       = 0;
        faces           = null;
        surfaces        = null;
        surfacesCreated = false;
        textureCoords   = null;
        mat             = null;
        matName         = null;
        material        = null;
        shininess       = 0.0f;
        component       = null;
        nodeName        = null;
        instanceName    = null;
        translation     = null;
        orientation     = null;
        scale           = null;
    }


    /**
     *  Returns the root of the scene graph constructed
     *  from the given file.
     *  @return Root of constructed scene graph.
     */

    public BranchGroup root()
    {
        return root;
    }


    //
    // A .3DS file consists of a series of chunks.  Each chunk
    // starts with a tag ID and the chunks' length followed by
    // optional data.  This method handles most of those chunks
    // processed by this loader.  Those chunks that are not
    // recognised are ignored.
    //

    void processChunk( RandomAccessFile in )
            throws IOException
    {
        int tag     = readUnsignedShort( in );
        int length  = readInt( in );

        switch ( tag )
        {
            case S3D_M3DMAGIC:          // 3DS file
            case S3D_MMAGIC:            // Editor chunks
            case S3D_MAT_ENTRY:         // 3DS material
            case S3D_HIERARCHY_NODE:    // Object instance
            case S3D_N_TRI_OBJECT:      // Object definition
                processChunk( in );
                break;

            case S3D_HIERARCHY:         // Start of the instance tree
                if ( surfacesCreated == false )
                {
                    createUnsmoothedFaces();
                    prepareForNewObject();
                }

                processChunk( in );
                break;

            case S3D_HIERARCHY_LINK:    // Details of an object instance
                processLink( in );
                break;

            case S3D_NODE_ID:           // Node ID - unused.
                processNodeID( in );
                break;

            case S3D_POS_TRACK_TAG:     // Contains object's initial position
                processPosTrackTag( in );
                break;

            case S3D_ROT_TRACK_TAG:     // Contains object's initial orientation
                processRotTrackTag( in );
                break;

            case S3D_SCL_TRACK_TAG:     // Contains object's initial scale
                processSclTrackTag( in );
                break;

            case S3D_INSTANCE_NAME:     // Name given to object instance
                instanceName = readName( in );
                break;

            case S3D_AMBIENT_LIGHT:     // Ambient light
                processAmbientLight( in );
                break;

            case S3D_MASTER_SCALE:      // Global scaling factor
                processMasterScale( in );
                break;

            case S3D_MAT_NAME:          // Start of a 3DS material
                matName     = readName( in );
                mat         = new Appearance();
                material    = new Material();
                material.setLightingEnable( true );
                mat.setMaterial( material );
                mats.put( matName, mat );

                if ( verbosity > 2 )
                {
                    System.out.println( "Processing material '" + matName + "'" );
                }
                break;

            case S3D_MAT_AMBIENT:       // Ambient colour of material
                Color3f     ambient = readColor( in );
                material.setAmbientColor( ambient );

                if ( verbosity > 2 )
                {
                    System.out.println( "==     Ambient: " + ambient );
                }
                break;

            case S3D_MAT_DIFFUSE:       // Diffuse colour of material
                Color3f     diffuse = readColor( in );
                material.setDiffuseColor( diffuse );

                if ( verbosity > 2 )
                {
                    System.out.println( "==     Diffuse: " + diffuse );
                }
                break;

            case S3D_MAT_SPECULAR:      // Specular colour of material
                material.setSpecularColor( readColor( in ) );
                break;

            case S3D_MAT_SHININESS:     // 3DS shininess percentage
                shininess = readPercentage( in );
                //System.out.println( "== Shininess: " + shininess );
                break;

            case S3D_MAT_SHININESS_STRENGTH:    // 3DS shininess strength
                float   shininessStrength = readPercentage( in );
                //System.out.println( "== Shininess strength: " + shininessStrength );
                material.setShininess( (1.0f - ((shininess + shininessStrength) / 2.0f)) * 128 );
                break;

            case S3D_MAT_TRANSPARENCY:  // Transparency percentage
                float   transparency = readPercentage( in );

                if ( verbosity > 2 )
                {
                    System.out.println( "== Transparency: " + transparency );
                }

                if ( transparency > 0.1f )
                {
                    TransparencyAttributes  ta  = new TransparencyAttributes();

                    ta.setTransparency( transparency );
                    mat.setTransparencyAttributes( ta );

                    //
                    // If we turn transparency on then we should
                    // also turn back face culling off.
                    //

                    PolygonAttributes       pa  = new PolygonAttributes();

                    pa.setCullFace( PolygonAttributes.CULL_NONE );
                    mat.setPolygonAttributes( pa );
                }
                break;

            case S3D_MAT_SHADING:       // Type of rendering
                int                 style;
                int                 mode = readUnsignedShort( in );
                PolygonAttributes   pa = mat.getPolygonAttributes();
                ColoringAttributes  ca = mat.getColoringAttributes();

                if ( pa == null )
                {
                    pa = new PolygonAttributes();
                }

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久er99热精品一区二区| 中文字幕一区在线| 久久国内精品自在自线400部| 欧美片网站yy| 免费亚洲电影在线| 欧美mv和日韩mv国产网站| 国产一区二区三区美女| 久久久久99精品一区| 成人av资源站| 亚洲精品一二三四区| 欧美日本一区二区| 国精产品一区一区三区mba桃花 | 久久精品国产澳门| 久久丝袜美腿综合| 成人黄色在线网站| 亚洲一区二区精品视频| 日韩一区二区免费在线电影| 黑人精品欧美一区二区蜜桃 | 日本一区二区电影| 色94色欧美sute亚洲线路一久| 亚洲理论在线观看| 欧美一卡二卡三卡四卡| 国产乱一区二区| 亚洲另类在线视频| 日韩亚洲国产中文字幕欧美| 国产乱子轮精品视频| 亚洲日本免费电影| 日韩欧美专区在线| 99精品国产视频| 免费在线欧美视频| 中文字幕日韩欧美一区二区三区| 欧美在线啊v一区| 久草中文综合在线| 亚洲激情在线激情| 久久久精品日韩欧美| 欧美午夜精品一区| 国产剧情在线观看一区二区| 亚洲最新视频在线观看| 久久婷婷综合激情| 欧美日韩一区国产| 岛国精品在线观看| 日本vs亚洲vs韩国一区三区二区| 国产精品视频你懂的| 欧美一区2区视频在线观看| 波多野结衣中文一区| 青青草97国产精品免费观看无弹窗版 | 久久久久久久久岛国免费| 在线欧美一区二区| 丁香五精品蜜臀久久久久99网站| 天堂影院一区二区| 亚洲女厕所小便bbb| 国产亚洲精品中文字幕| 88在线观看91蜜桃国自产| proumb性欧美在线观看| 激情综合网最新| 午夜精品久久久久久久| 亚洲欧美影音先锋| 国产日韩欧美在线一区| 日韩免费性生活视频播放| 欧美日韩在线免费视频| 91麻豆国产香蕉久久精品| 国产高清在线观看免费不卡| 日韩精品高清不卡| 亚洲成人午夜电影| 洋洋成人永久网站入口| 日韩一区中文字幕| 国产精品欧美极品| 国产欧美一区二区三区网站 | 国产乱人伦精品一区二区在线观看| 亚洲综合偷拍欧美一区色| 亚洲欧美中日韩| 国产精品无遮挡| 国产精品网友自拍| 国产精品色噜噜| 国产拍揄自揄精品视频麻豆| 日韩精品一区二区三区中文精品| 欧美精品欧美精品系列| 欧美色大人视频| 欧美三级在线视频| 欧美日韩精品一区二区三区蜜桃 | 不卡的av在线| 成人小视频在线| 成人sese在线| 99re亚洲国产精品| 色乱码一区二区三区88| 在线观看91视频| 欧美精品在线一区二区三区| 欧美麻豆精品久久久久久| 精品污污网站免费看| 6080午夜不卡| 亚洲精品在线电影| 午夜精品一区二区三区电影天堂| 亚洲精品老司机| 亚洲va在线va天堂| 美女爽到高潮91| 黄网站免费久久| 成人毛片老司机大片| 色哟哟精品一区| 欧美日韩国产另类一区| 欧美一级二级三级蜜桃| 久久视频一区二区| 亚洲欧洲日产国码二区| 亚洲一区二区三区中文字幕在线| 午夜精品久久一牛影视| 精品在线观看免费| 成人高清视频免费观看| 在线看不卡av| 日韩免费电影网站| 中文字幕日韩一区| 日韩成人dvd| 成人综合婷婷国产精品久久免费| 97久久人人超碰| 欧美放荡的少妇| 国产日韩欧美a| 亚洲在线视频网站| 激情伊人五月天久久综合| 成人av免费在线| 777午夜精品免费视频| 国产欧美一区二区精品婷婷 | 亚洲一二三四久久| 久久99热国产| 色视频成人在线观看免| 日韩免费观看2025年上映的电影| 国产精品看片你懂得| 性感美女极品91精品| 粉嫩aⅴ一区二区三区四区五区 | 蜜臀av性久久久久蜜臀aⅴ流畅| 国产精品一区二区三区网站| 欧美午夜不卡在线观看免费| 国产亚洲一二三区| 日韩精品欧美成人高清一区二区| 成人av在线播放网址| 欧美一区二区成人6969| 亚洲精品视频在线观看网站| 成人av网站大全| 精品乱人伦小说| 亚洲国产精品一区二区www| 国产98色在线|日韩| 日韩一区二区三区视频在线| 亚洲欧美日韩中文播放 | 日韩av电影免费观看高清完整版在线观看| 国产老女人精品毛片久久| 51精品国自产在线| 亚洲精品高清在线| av在线一区二区| 国产亚洲精品久| 国内偷窥港台综合视频在线播放| 欧美日韩一区二区三区不卡| 国产精品成人一区二区艾草 | 日日夜夜免费精品| 91小视频免费观看| 中文字幕国产精品一区二区| 久久91精品久久久久久秒播| 7777女厕盗摄久久久| 亚洲国产精品自拍| 在线精品视频一区二区三四 | 亚洲国产视频直播| 97se亚洲国产综合自在线观| 国产网站一区二区| 国产揄拍国内精品对白| 欧美成人aa大片| 免费成人深夜小野草| 337p亚洲精品色噜噜噜| 手机精品视频在线观看| 欧美在线观看视频在线| 亚洲综合免费观看高清在线观看| 不卡欧美aaaaa| 国产精品无遮挡| 成人激情视频网站| 国产精品乱码久久久久久| 国产999精品久久久久久| 中文字幕乱码久久午夜不卡 | 色婷婷久久综合| 最好看的中文字幕久久| 91啪九色porn原创视频在线观看| 国产精品乱码一区二区三区软件| 成人蜜臀av电影| 久久成人综合网| 久久综合九色综合欧美亚洲| 国产精品综合在线视频| 欧美激情艳妇裸体舞| 波多野结衣中文字幕一区二区三区| 国产精品国产成人国产三级| 99精品国产热久久91蜜凸| 伊人色综合久久天天人手人婷| 91福利在线导航| 亚洲福利电影网| 日韩免费观看高清完整版| 国产尤物一区二区| 国产精品精品国产色婷婷| 在线影院国内精品| 日本午夜一本久久久综合| 欧美精品一区二区在线观看| 粉嫩av亚洲一区二区图片| 亚洲免费观看高清完整| 欧美日韩免费观看一区二区三区 | 亚洲免费在线看| 欧美日韩高清在线播放| 精品制服美女久久| 亚洲色图.com|