示例#1
0
 internal CoordinateReferenceTuple(OptReader reader)
 {
     for (int i = 0; i < values.Length; i++)
     {
         values[i] = reader.ReadInt32();
     }
 }
示例#2
0
        internal override object ReadCollection(OptReader reader, int count)
        {
            var collection = new Collection <TVector2>();

            for (int i = 0; i < count; i++)
            {
                collection.Add((TVector2)Read(reader));
            }

            return(collection);
        }
示例#3
0
        internal override object Read(OptReader reader)
        {
            var v = vector3Cotr.Invoke(new object[] { reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle() });

            if (null != RotateFromOptSpace)
            {
                v = RotateFromOptSpace((TVector3)v);
            }

            return(v);
        }
示例#4
0
        public void Read(Stream stream)
        {
            var reader = new OptReader(stream, Logger)
            {
                Vector2T  = typeof(TVector2),
                Vector3T  = typeof(TVector3),
                V2Adapter = new Vector2Adapter <TVector2>(),
                V3Adapter = new Vector3Adapter <TVector3>()
                {
                    RotateFromOptSpace = RotateFromOptSpace,
                }
            };

            // Version is stored as negative int, or is omitted if version is 0.
            var version = reader.ReadInt32();
            int size;

            if (version < 0)
            {
                reader.version = Version = Math.Abs(version);
                size           = reader.ReadInt32() + preGlobalOffsetHeaderLength;
            }
            else
            {
                size    = version;
                version = 0;
            }

            // Sanity check file size.
            if (size != reader.BaseStream.Length)
            {
                var msg = String.Format(CultureInfo.CurrentCulture, "File length expected is {0} but actual length is {1}.  File may be corrupt.", size, reader.BaseStream.Length);
                Logger?.Invoke(msg);
                throw new InvalidDataException(msg);
            }

            // The bytes preceding this don't count when calculating the offset.
            preGlobalOffsetHeaderLength = (int)reader.BaseStream.Position;
            reader.globalOffset         = GlobalOffset = reader.ReadInt32() - preGlobalOffsetHeaderLength;

            // Usually 2 in TIE98
            UnknownWord = reader.ReadInt16();

            var partCount      = reader.ReadInt32();
            var partListOffset = reader.ReadInt32();

            RootNodes = new Collection <BaseNode>();
            foreach (var child in reader.ReadChildren(partCount, partListOffset, this))
            {
                RootNodes.Add(child);
            }
        }
示例#5
0
 internal override object Read(OptReader reader)
 {
     return((TVector2)vector3Cotr.Invoke(new object[] { reader.ReadSingle(), reader.ReadSingle() }));
 }