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); }
public unsafe PmxModel(Stream model) { var buffer = new byte[model.Length]; model.Read(buffer, 0, (int)model.Length); fixed(byte *p = buffer) { var mp = p; this.Header = *((PmxHeader *)mp); mp += sizeof(PmxHeader); this.ModelInfo = ModelInfo.ReadData(mp, this.Header, out mp); this.VertexData = VertexData.ReadData(mp, this.Header, out mp); this.FaceData = FaceData.ReadData(mp, this.Header, out mp); this.TextureData = PmxTextureData.ReadData(mp, this.Header, out mp); this.MaterialData = PmxMaterialData.ReadData(mp, this.Header, out mp); } }