Пример #1
0
        private static ThreeDSMesh.MaterialMapping ReadMESHMATERIAL(FileStream file, Chunk chunk)
        {
            ThreeDSMesh.MaterialMapping mapping = new ThreeDSMesh.MaterialMapping();
            int length = 0;

            while (file.ReadByte() != 0)
            {
                length++;
            }
            length++;
            file.Seek(-length, SeekOrigin.Current);

            byte[] name = new byte[length];
            file.Read(name, 0, length);

            mapping.name = ASCIIEncoding.ASCII.GetString(name);

            byte[] buffer = new byte[length];
            file.Read(buffer, 0, 2);
            ushort numFaces = BitConverter.ToUInt16(buffer, 0);

            mapping.mappedFaces = new ushort[numFaces];

            buffer = new byte[sizeof(ushort)];
            for (int i = 0; i < numFaces; i++)
            {
                file.Read(buffer, 0, sizeof(ushort));
                mapping.mappedFaces[i] = BitConverter.ToUInt16(buffer, 0);
            }

            return(mapping);
        }
Пример #2
0
        private static ThreeDSMesh.MaterialMapping ParseMeshMaterial(DataReader3DS subSegment)
        {
            ThreeDSMesh.MaterialMapping mapping = new ThreeDSMesh.MaterialMapping();
            mapping.name = subSegment.GetString();

            // Read mapped faces
            mapping.mappedFaces = new ushort[subSegment.GetUShort()];
            for (int face = 0; face < mapping.mappedFaces.Length; face++)
            {
                mapping.mappedFaces[face] = subSegment.GetUShort();
            }

            return(mapping);
        }
Пример #3
0
        private static ThreeDSMesh.MaterialMapping ParseMeshMaterial(DataReader3DS subSegment)
        {
            ThreeDSMesh.MaterialMapping mapping = new ThreeDSMesh.MaterialMapping();
            mapping.name = subSegment.GetString();

            // Read mapped faces
            mapping.mappedFaces = new ushort[subSegment.GetUShort()];
            for (int face = 0; face < mapping.mappedFaces.Length; face++)
            {
                mapping.mappedFaces[face] = subSegment.GetUShort();
            }

            return mapping;
        }