Ejemplo n.º 1
0
        public override Mesh decode(MeshInfo minfo, CtmInputStream input)
        {
            int vc = minfo.getVertexCount();

            checkTag(input.readLittleInt(), MG2_HEADER_TAG);
            float vertexPrecision = input.readLittleFloat();
            float normalPrecision = input.readLittleFloat();

            Grid grid = Grid.fromStream(input);
            if(!grid.checkIntegrity()) {
                throw new InvalidDataException("The vertex size grid is corrupt!");
            }

            float[] vertices = readVertices(input, grid, vc, vertexPrecision);

            int[] indices = readIndices(input, minfo.getTriangleCount(), vc);

            float[] normals = null;
            if (minfo.hasNormals()) {
                normals = readNormals(input, vertices, indices, normalPrecision, vc);
            }

            AttributeData[] uvData = new AttributeData[minfo.getUvMapCount()];
            for (int i = 0; i < uvData.Length; i++) {
                uvData[i] = readUvData(input, vc);
            }

            AttributeData[] attributs = new AttributeData[minfo.getAttrCount()];
            for (int i = 0; i < attributs.Length; i++) {
                attributs[i] = readAttribute(input, vc);
            }

            return new Mesh(vertices, normals, indices, uvData, attributs);
        }
Ejemplo n.º 2
0
        public override Mesh decode(MeshInfo minfo, CtmInputStream input)
        {
            int vc = minfo.getVertexCount();

            AttributeData[] tex = new AttributeData[minfo.getUvMapCount()];
            AttributeData[] att = new AttributeData[minfo.getAttrCount()];

            checkTag(input.readLittleInt(), INDX);
            int[] indices = readIntArray(input, minfo.getTriangleCount(), 3, false);

            checkTag(input.readLittleInt(), VERT);
            float[] vertices = readFloatArray(input, vc * Mesh.CTM_POSITION_ELEMENT_COUNT, 1);

            float[] normals = null;
            if (minfo.hasNormals()) {
                checkTag(input.readLittleInt(), NORM);
                normals = readFloatArray(input, vc, Mesh.CTM_NORMAL_ELEMENT_COUNT);
            }

            for (int i = 0; i < tex.Length; ++i) {
                checkTag(input.readLittleInt(), TEXC);
                tex[i] = readUVData(vc, input);
            }

            for (int i = 0; i < att.Length; ++i) {
                checkTag(input.readLittleInt(), ATTR);
                att[i] = readAttrData(vc, input);
            }

            return new Mesh(vertices, normals, indices, tex, att);
        }
Ejemplo n.º 3
0
        public override Mesh decode(MeshInfo minfo, CtmInputStream input)
        {
            int vc = minfo.getVertexCount();

            AttributeData[] tex = new AttributeData[minfo.getUvMapCount()];
            AttributeData[] att = new AttributeData[minfo.getAttrCount()];

            checkTag(input.readLittleInt(), INDX);
            int[] indices = readIntArray(input, minfo.getTriangleCount(), 3, false);

            checkTag(input.readLittleInt(), VERT);
            float[] vertices = readFloatArray(input, vc * Mesh.CTM_POSITION_ELEMENT_COUNT, 1);

            float[] normals = null;
            if (minfo.hasNormals())
            {
                checkTag(input.readLittleInt(), NORM);
                normals = readFloatArray(input, vc, Mesh.CTM_NORMAL_ELEMENT_COUNT);
            }

            for (int i = 0; i < tex.Length; ++i)
            {
                checkTag(input.readLittleInt(), TEXC);
                tex[i] = readUVData(vc, input);
            }

            for (int i = 0; i < att.Length; ++i)
            {
                checkTag(input.readLittleInt(), ATTR);
                att[i] = readAttrData(vc, input);
            }

            return(new Mesh(vertices, normals, indices, tex, att));
        }
Ejemplo n.º 4
0
        public override Mesh decode(MeshInfo minfo, CtmInputStream input)
        {
            int vc = minfo.getVertexCount();

            checkTag(input.readLittleInt(), MG2_HEADER_TAG);
            float vertexPrecision = input.readLittleFloat();
            float normalPrecision = input.readLittleFloat();

            Grid grid = Grid.fromStream(input);

            if (!grid.checkIntegrity())
            {
                throw new InvalidDataException("The vertex size grid is corrupt!");
            }

            float[] vertices = readVertices(input, grid, vc, vertexPrecision);

            int[] indices = readIndices(input, minfo.getTriangleCount(), vc);

            float[] normals = null;
            if (minfo.hasNormals())
            {
                normals = readNormals(input, vertices, indices, normalPrecision, vc);
            }

            AttributeData[] uvData = new AttributeData[minfo.getUvMapCount()];
            for (int i = 0; i < uvData.Length; i++)
            {
                uvData[i] = readUvData(input, vc);
            }

            AttributeData[] attributs = new AttributeData[minfo.getAttrCount()];
            for (int i = 0; i < attributs.Length; i++)
            {
                attributs[i] = readAttribute(input, vc);
            }

            return(new Mesh(vertices, normals, indices, uvData, attributs));
        }