internal CoordinateReferenceTuple(OptReader reader) { for (int i = 0; i < values.Length; i++) { values[i] = reader.ReadInt32(); } }
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); }
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); }
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); } }
internal override object Read(OptReader reader) { return((TVector2)vector3Cotr.Invoke(new object[] { reader.ReadSingle(), reader.ReadSingle() })); }