Esempio n. 1
0
        private static void ParseHeader(Stream stream, out ParserLocalInfo localInfo, PMXObject pmx)
        {
            stream.NextBytes(4, out var magicWord);
            PMXValidator.ValidateMagicWord(magicWord);

            var version = (PMXVersion)(int)(stream.NextSingle() * 10);

            PMXValidator.ValidateVersion((int)version);

            var infoLen = stream.NextByte();

            stream.NextBytes(infoLen, out var info);
            PMXValidator.ValidateHeaderInfo(info);
            localInfo   = new ParserLocalInfo(version, info);
            pmx.Version = localInfo.Version;
        }
Esempio n. 2
0
        public static PMXVersion GetVersion(Stream stream)
        {
            if (stream is null)
            {
                throw new ArgumentNullException(nameof(stream));
            }
            try {
                stream.NextBytes(4, out var magicWord);
                PMXValidator.ValidateMagicWord(magicWord);

                var version = (PMXVersion)(int)(stream.NextSingle() * 10);
                PMXValidator.ValidateVersion((int)version);
                return(version);
            }
            finally {
                StreamHelper.ReleaseBuffer();
            }
        }