Esempio n. 1
0
        public static unsafe PmxMaterial ReadData(byte *pData, PmxHeader header, out byte *offset)
        {
            offset = pData;
            ToonType type;
            var      mat = new PmxMaterial();

            mat.Name             = PmxUtils.ReadString(header.TextEncoding, offset, out offset);
            mat.UniversalName    = PmxUtils.ReadString(header.TextEncoding, offset, out offset);
            mat.DiffuseColor     = *((Vec4 *)PmxUtils.ReadAndIncrement(ref offset, sizeof(Vec4)));
            mat.SpecularColor    = *((Vec3 *)PmxUtils.ReadAndIncrement(ref offset, sizeof(Vec3)));
            mat.SpecularStrength = *((float *)PmxUtils.ReadAndIncrement(ref offset, sizeof(float)));
            mat.AmbientColor     = *((Vec3 *)PmxUtils.ReadAndIncrement(ref offset, sizeof(Vec3)));
            mat.DrawingModeFlags =
                *((DrawingModeFlags *)PmxUtils.ReadAndIncrement(ref offset, sizeof(DrawingModeFlags)));
            mat.EdgeColor = *((Vec3 *)PmxUtils.ReadAndIncrement(ref offset, sizeof(Vec3)));
            mat.EdgeSize  = *((float *)PmxUtils.ReadAndIncrement(ref offset, sizeof(float)));
            var garbage = *((float *)PmxUtils.ReadAndIncrement(ref offset, sizeof(float)));

            mat.TextureIndex         = PmxUtils.ReadVarInt(ref offset, header.TextureIndexSize);
            mat.EnvironmentIndex     = PmxUtils.ReadVarInt(ref offset, header.TextureIndexSize);
            mat.EnvironmentBlendMode =
                *((EnvironmentBlendMode *)PmxUtils.ReadAndIncrement(ref offset, sizeof(EnvironmentBlendMode)));
            mat.ToonType  = (type = *((ToonType *)PmxUtils.ReadAndIncrement(ref offset, sizeof(ToonType))));
            mat.ToonIndex = type == ToonType.Internal
                ? *PmxUtils.ReadAndIncrement(ref offset, sizeof(byte))
                : *((int *)PmxUtils.ReadAndIncrement(ref offset, header.TextureIndexSize));
            mat.MetaData     = PmxUtils.ReadString(header.TextEncoding, offset, out offset);
            mat.SurfaceCount = *((int *)PmxUtils.ReadAndIncrement(ref offset, sizeof(int)));
            return(mat);
        }
Esempio n. 2
0
        public static unsafe PmxMaterialData ReadData(byte *pData, PmxHeader header, out byte *offset)
        {
            var materialData = new PmxMaterialData();
            var count        = *((int *)PmxUtils.ReadAndIncrement(ref pData, sizeof(int)));

            materialData.Materials = new PmxMaterial[count];
            offset = pData;

            for (int i = 0; i < count; i++)
            {
                materialData.Materials[i] = PmxMaterial.ReadData(offset, header, out offset);
            }

            offset = pData;
            return(materialData);
        }