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

📄 reader3ds.java

📁 基于java的3d开发库。对坐java3d的朋友有很大的帮助。
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
                        }                        for ( j = 0;                               j < map_i.associatedTriangles.length; j++ ) {                            if ( k >= newTrianglesList.length ) {                                VSDK.reportMessage(null, VSDK.WARNING,                                "Reader3ds.processChunk",                                "k to large at checkpoint A.");                            }                            if ( map_i.associatedTriangles[j] >=                                 currentTrianglesList.length ) {                                VSDK.reportMessage(null, VSDK.WARNING,                                "Reader3ds.processChunk",                                "map to large at checkpoint A.");                            }                            newTrianglesList[k] =                             currentTrianglesList[map_i.associatedTriangles[j]];                            k++;                        }                        newMaterialRanges[i][0] = k;                        newMaterialRanges[i][1] = i;                        newTextureRanges[i][0] = k;                        if ( newTextures[i] == null ) {                            newTextureRanges[i][1] = 0;                        }                        else {                            newTextureRanges[i][1] = i+1;                        }                    }                    currentTriangleMesh.setTriangles(newTrianglesList);                    currentTriangleMesh.setMaterials(newMaterials);                    currentTriangleMesh.setTextures(newTextures);                    currentTriangleMesh.setMaterialRanges(newMaterialRanges);                    currentTriangleMesh.setTextureRanges(newTextureRanges);                    currentTrianglesList = null;                }                // Mesh adition to environment                currentTriangleMesh.calculateNormals();                addThing(currentTriangleMesh, currentSimpleBodiesArray);            }        }        else if ( currentChunk.id == currentChunk.ID_VERTEX_LIST ) {            //-------------------------------------------------------------            //System.out.println(indent(level) + currentChunk);            int numVertexes = readIntLE(is);            //System.out.println(indent(level+1) + "  . Reading " + numVertexes +            //                 " vertexes");            currentVertexPositionArray = new ArrayList<Vector3D>();            Vector3D p;            for ( i = 0; i < numVertexes; i++ ) {                p = new Vector3D();                p.x = readFloatLE(is);                p.y = readFloatLE(is);                p.z = readFloatLE(is);                currentVertexPositionArray.add(p);            }            if ( currentChunk.length-8-numVertexes*12 > 0 ) {                is.skip(currentChunk.length-8-numVertexes*12);            }        }        else if ( currentChunk.id == currentChunk.ID_TRIANGLE_LIST ) {            //-------------------------------------------------------------            //System.out.println(indent(level) + currentChunk);            //----            int numTriangles = readIntLE(is);            //System.out.println(indent(level+1) + "  . Reading " + numTriangles +            //                 " triangles");            int a, b, c, flags;            currentTrianglesList = new Triangle[numTriangles];            for ( i = 0; i < numTriangles; i++ ) {                a = readIntLE(is);                b = readIntLE(is);                c = readIntLE(is);                flags = readIntLE(is) & 0x07;                /* Warning: dont know how to process this! */                if ( (flags & 0x07) == 0x00 ||                     (flags & 0x07) == 0x01 ||                     (flags & 0x07) == 0x02 ||                     (flags & 0x07) == 0x03 ||                     (flags & 0x07) == 0x04 ||                     (flags & 0x07) == 0x05 ||                     (flags & 0x07) == 0x06 ||                     (flags & 0x07) == 0x07 ) {                    currentTrianglesList[i] = new Triangle(a, b, c);                  }                  else {                    currentTrianglesList[i] = new Triangle(a, c, b);                }                //System.out.println("FACE: " + flags);            }            //----            // skip current chunk header AND triangles            long internalBytes = 8+numTriangles*8;             // Processing of recursive chunks            _Reader3dsChunk subChunk = new _Reader3dsChunk();            do {                subChunk.readHeader(is);                processChunk(is, subChunk, currentChunk, level+1);                internalBytes += subChunk.length;            } while ( is.available() > 0 &&                       (internalBytes < currentChunk.length) );        }        else if ( currentChunk.id == currentChunk.ID_MATRIX ) {            //-------------------------------------------------------------            //System.out.println(indent(level) + currentChunk);            is.skip(12*4);        }        else if ( currentChunk.id == currentChunk.ID_MATERIAL_NAME ) {            //-------------------------------------------------------------            //System.out.println(indent(level) + currentChunk);            String materialName = readAsciiString(is);            if ( currentBuildingMaterial != null ) {                currentBuildingMaterial.setName(materialName);            }        }        else if ( currentChunk.id == currentChunk.ID_COLOR_RGB2 ) {            //-------------------------------------------------------------            //System.out.println(indent(level) + currentChunk);            byte r[] = new byte[1];            byte g[] = new byte[1];            byte b[] = new byte[1];            readBytes(is, r);            readBytes(is, g);            readBytes(is, b);            if ( currentColor != null ) {                currentColor.r =                     (double)(VSDK.signedByte2unsignedInteger(r[0])) / 255.0;                currentColor.g =                     (double)(VSDK.signedByte2unsignedInteger(g[0])) / 255.0;                currentColor.b =                     (double)(VSDK.signedByte2unsignedInteger(b[0])) / 255.0;            }        }        else if ( currentChunk.id == currentChunk.ID_AMOUNT ) {            //-------------------------------------------------------------            //System.out.println(indent(level) + currentChunk);            currentAmount = readIntLE(is);        }        else if ( currentChunk.id == currentChunk.ID_MATERIAL_MAPFILENAME ) {            //-------------------------------------------------------------            currentTextureFilename = new String(readAsciiString(is));        }        else if ( currentChunk.id == currentChunk.ID_MATERIAL_SHININESS_KTE ) {            //System.out.println(indent(level) + currentChunk);            currentAmount = 0;            // Processing of recursive chunks            _Reader3dsChunk subChunk = new _Reader3dsChunk();            long internalBytes = 6; // Skip current chunk header            do {                subChunk.readHeader(is);                processChunk(is, subChunk, currentChunk, level+1);                internalBytes += subChunk.length;            } while ( is.available() > 0 &&                       (internalBytes < currentChunk.length) );            if ( currentBuildingMaterial != null ) {                // Warning: don't know well how to handle this (percent over                // specular color?)                ;            }        }        else if ( currentChunk.id == currentChunk.ID_MATERIAL_TRANSPARENCY ) {            //System.out.println(indent(level) + currentChunk);            currentAmount = 0;            // Processing of recursive chunks            _Reader3dsChunk subChunk = new _Reader3dsChunk();            long internalBytes = 6; // Skip current chunk header            do {                subChunk.readHeader(is);                processChunk(is, subChunk, currentChunk, level+1);                internalBytes += subChunk.length;            } while ( is.available() > 0 &&                       (internalBytes < currentChunk.length) );            if ( currentBuildingMaterial != null && currentAmount > 0 ) {                if ( currentAmount > 100 ) currentAmount = 100;                // Warning: not verified yet                currentBuildingMaterial.setOpacity(1.0-((double)currentAmount)/100.0);            }        }        else if ( currentChunk.id == currentChunk.ID_MATERIAL_TRANSPARENCY_F ) {            //System.out.println(indent(level) + currentChunk);            currentAmount = 0;            // Processing of recursive chunks            _Reader3dsChunk subChunk = new _Reader3dsChunk();            long internalBytes = 6; // Skip current chunk header            do {                subChunk.readHeader(is);                processChunk(is, subChunk, currentChunk, level+1);                internalBytes += subChunk.length;            } while ( is.available() > 0 &&                       (internalBytes < currentChunk.length) );            if ( currentBuildingMaterial != null ) {                // Warning: don't know well how to handle this            }        }        else if ( currentChunk.id == currentChunk.ID_MATERIAL_TRANSPARENCY_FI ) {            // Warning: don't know well how to handle this        }        else if ( currentChunk.id == currentChunk.ID_MATERIAL_TWOSIDED ) {            if ( currentBuildingMaterial != null ) {                currentBuildingMaterial.setDoubleSided(true);            }        }        else if ( currentChunk.id == currentChunk.ID_MATERIAL_REFLECT_BLUR ) {            //System.out.println(indent(level) + currentChunk);            currentAmount = 0;            // Processing of recursive chunks            _Reader3dsChunk subChunk = new _Reader3dsChunk();            long internalBytes = 6; // Skip current chunk header            do {                subChunk.readHeader(is);                processChunk(is, subChunk, currentChunk, level+1);                internalBytes += subChunk.length;            } while ( is.available() > 0 &&                       (internalBytes < currentChunk.length) );            if ( currentBuildingMaterial != null ) {                // Warning: don't know well how to handle this            }        }        else if ( currentChunk.id == currentChunk.ID_MATERIAL_SHININESS_EXP ) {            //System.out.println(indent(level) + currentChunk);            currentAmount = 0;            // Processing of recursive chunks            _Reader3dsChunk subChunk = new _Reader3dsChunk();            long internalBytes = 6; // Skip current chunk header            do {                subChunk.readHeader(is);                processChunk(is, subChunk, currentChunk, level+1);                internalBytes += subChunk.length;            } while ( is.available() > 0 &&                       (internalBytes < currentChunk.length) );            if ( currentBuildingMaterial != null ) {                currentBuildingMaterial.setPhongExponent((double)currentAmount);            }        }        else if ( currentChunk.id == currentChunk.ID_MATERIAL_AMBIENT ) {            //-------------------------------------------------------------            //System.out.println(indent(level) + currentChunk);            currentColor = new ColorRgb();            // Processing of recursive chunks            _Reader3dsChunk subChunk = new _Reader3dsChunk();            long internalBytes = 6; // Skip current chunk header            do {                subChunk.readHeader(is);                processChunk(is, subChunk, currentChunk, level+1);                internalBytes += subChunk.length;            } while ( is.available() > 0 &&                       (internalBytes < currentChunk.length) );            // Set color in the material            if ( currentBuildingMaterial != null ) {                currentBuildingMaterial.setAmbient(currentColor);            }        }        else if ( currentChunk.id == currentChunk.ID_MATERIAL_DIFFUSE ) {            //-------------------------------------------------------------            //System.out.println(indent(level) + currentChunk);            currentColor = new ColorRgb();            // Processing of recursive chunks            _Reader3dsChunk subChunk = new _Reader3dsChunk();            long internalBytes = 6; // Skip current chunk header            do {                subChunk.readHeader(is);                processChunk(is, subChunk, currentChunk, level+1);                internalBytes += subChunk.length;            } while ( is.available() > 0 &&                       (inter

⌨️ 快捷键说明

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