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); }
public static unsafe ModelInfo ReadData(byte *pData, PmxHeader header, out byte *offset) { return(new ModelInfo { CharacterName = PmxUtils.ReadString(header.TextEncoding, pData, out pData), UniversalCharacterName = PmxUtils.ReadString(header.TextEncoding, pData, out pData), Comment = PmxUtils.ReadString(header.TextEncoding, pData, out pData), UniversalComment = PmxUtils.ReadString(header.TextEncoding, pData, out offset) }); }
public static unsafe PmxTextureData ReadData(byte *pData, PmxHeader header, out byte *offset) { var textureData = new PmxTextureData(); var texCount = *((int *)PmxUtils.ReadAndIncrement(ref pData, sizeof(int))); textureData.Textures = new string[texCount]; offset = pData; for (int i = 0; i < texCount; i++) { textureData.Textures[i] = PmxUtils.ReadString(header.TextEncoding, offset, out offset); } return(textureData); }