Package info.ata4.unity.cli.extract.mesh

Examples of info.ata4.unity.cli.extract.mesh.MeshWriter


    public void extract(UnityObject obj) throws IOException {
        this.path = path;

        try {
            // create Texture2D from serialized object
            tex = new Texture2D(obj);
        } catch (RuntimeException ex) {
            L.log(Level.WARNING, "Deserialization error", ex);
            return;
        }
       
View Full Code Here


        assert !bb.hasRemaining();
    }
   
    private void convertToRGBA32() {
        ByteBuffer imageBuffer = tex.imageBuffer;
        TextureFormat tf = tex.textureFormat;
       
        if (tf == RGBA32 || tf == ARGB32) {
            // convert ARGB and RGBA directly by swapping the bytes to get BGRA
            byte[] pixelOld = new byte[4];
            byte[] pixelNew = new byte[4];
View Full Code Here

        assert !bb.hasRemaining();
    }
   
    private void convertToRGBA32() {
        ByteBuffer imageBuffer = tex.imageBuffer;
        TextureFormat tf = tex.textureFormat;
       
        if (tf == RGBA32 || tf == ARGB32) {
            // convert ARGB and RGBA directly by swapping the bytes to get BGRA
            byte[] pixelOld = new byte[4];
            byte[] pixelNew = new byte[4];
View Full Code Here

                                in.skipBytes(2); // padding?
                            }
                            break;

                        case CHANNEL_COLORS:
                            Color32 c = new Color32();
                            c.read(in);
                            colors.add(c);
                            break;

                        case CHANNEL_UV1:
                        case CHANNEL_UV2:
View Full Code Here

            }
        }

        int[] colorInts = readPackedBits(cmesh.colors);
        for (int i = 0; i < colorInts.length; i++) {
            Color32 c = new Color32();
            c.fromInt(colorInts[i]);
            colors.add(c);
        }
       
        // TODO: works for triangulated meshes only!
        int[] triangleInts = readPackedBits(cmesh.triangles);
View Full Code Here

                for (int j = firstVertex; j < firstVertex + vertexCount; j++) {
                    Vector3f v = vertices.get(j);
                    Vector3f vn = normals.isEmpty() ? null : normals.get(j);
                    Vector2f vt1 = uv1.isEmpty() ? null : uv1.get(j);
                    Vector2f vt2 = uv2.isEmpty() ? null : uv2.get(j);
                    Color32 c = colors.isEmpty() ? null : colors.get(j);
                    writeVertex(v, vn, vt1, vt2, c);
                }

                // write faces
                List<Integer> faceTriangles = new ArrayList<>();
View Full Code Here

                            colors.add(c);
                            break;

                        case CHANNEL_UV1:
                        case CHANNEL_UV2:
                            Vector2f vt = new Vector2f();
                            vt.setHalf(half);
                            vt.read(in);
                            if (j == CHANNEL_UV1) {
                                uv1.add(vt);
                            } else {
                                uv2.add(vt);
                            }
View Full Code Here

            normals.add(vn);
        }

        float[] uvFloats = readPackedFloats(cmesh.UV);
        for (int i = 0; i < uvFloats.length / 2; i++) {
            Vector2f vt = new Vector2f();
            vt.x = uvFloats[i * 2];
            vt.y = uvFloats[i * 2 + 1];
            if (i < vertexFloats.length / 3) {
                uv1.add(vt);
            } else {
View Full Code Here

               
                // write vertices
                for (int j = firstVertex; j < firstVertex + vertexCount; j++) {
                    Vector3f v = vertices.get(j);
                    Vector3f vn = normals.isEmpty() ? null : normals.get(j);
                    Vector2f vt1 = uv1.isEmpty() ? null : uv1.get(j);
                    Vector2f vt2 = uv2.isEmpty() ? null : uv2.get(j);
                    Color32 c = colors.isEmpty() ? null : colors.get(j);
                    writeVertex(v, vn, vt1, vt2, c);
                }

                // write faces
View Full Code Here

                        half = channel.format == 1;
                    }

                    switch (j) {
                        case CHANNEL_VERTS:
                            Vector3f v = new Vector3f();
                            v.setHalf(half);
                            v.read(in);
                            vertices.add(v);
                            break;

                        case CHANNEL_NORMALS:
                            Vector3f vn = new Vector3f();
                            vn.setHalf(half);
                            vn.read(in);
                            normals.add(vn);
                            if (half && channel != null && channel.dimension == 4) {
                                in.skipBytes(2); // padding?
                            }
                            break;
View Full Code Here

TOP

Related Classes of info.ata4.unity.cli.extract.mesh.MeshWriter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.