private void SerialiseMappedData(IwSerialise serialise) { ushort median = 8; serialise.Serialise(ref median); ushort[] data = new ushort[8]; serialise.Serialise(ref data); }
/// <summary> /// The serialise. /// </summary> /// <param name="serialise"> /// The serialise. /// </param> public override void Serialise(IwSerialise serialise) { base.Serialise(serialise); serialise.Bool(ref this.serialiseGrayscale); if (this.serialiseGrayscale) { this.colors = new Color[this.numItems]; var buf = new byte[this.numItems]; serialise.Serialise(ref buf); for (int i = 0; i < this.numItems; ++i) { this.Colors[i] = Color.FromArgb(255, buf[i], buf[i], buf[i]); } } else { this.colors = new Color[this.numItems]; var buf = new byte[this.numItems * 4]; serialise.Serialise(ref buf); for (int i = 0; i < this.numItems; ++i) { this.Colors[i] = Color.FromArgb( buf[i + this.numItems * 3], buf[i + this.numItems * 0], buf[i + this.numItems * 1], buf[i + this.numItems * 2]); } } }
/// <summary> /// The serialise. /// </summary> /// <param name="serialise"> /// The serialise. /// </param> public override void Serialise(IwSerialise serialise) { base.Serialise(serialise); serialise.Serialise(ref this.VertIDOfs); serialise.Serialise(ref this.NormIDOfs); serialise.Serialise(ref this.ColIDOfs); serialise.Serialise(ref this.UV0IDOfs); this.TupleSize = 0; if (this.TupleSize < this.VertIDOfs) { this.TupleSize = this.VertIDOfs; } if (this.TupleSize < this.NormIDOfs) { this.TupleSize = this.NormIDOfs; } if (this.TupleSize < this.ColIDOfs) { this.TupleSize = this.ColIDOfs; } if (this.TupleSize < this.UV0IDOfs) { this.TupleSize = this.UV0IDOfs; } if (serialise.IsReading()) { ++this.TupleSize; this.Tuples = new ushort[this.TupleSize * this.numItems]; } serialise.Serialise(ref this.Tuples); ////var buf = new byte[Math.Min(256, serialise.Length-serialise.Position)]; ////serialise.Serialise(ref buf); ////StringBuilder sb = new StringBuilder(); ////int i = 0; ////foreach (var b in buf) ////{ //// if (b < 16) //// sb.Append("0"); //// sb.Append(string.Format("{0:x} ", b)); //// ++i; //// if (i == 8) //// sb.Append("| "); //// if (i == 16) //// { //// sb.Append("\n"); //// i = 0; //// } ////} ////Debug.WriteLine(sb.ToString()); ////throw new NotImplementedException(); }
/// <summary> /// The serialise. /// </summary> /// <param name="serialise"> /// The serialise. /// </param> public void Serialise(IwSerialise serialise) { if (serialise.IsReading()) { this.m_IGIDs = new ushort[4]; this.m_U0 = new short[8]; } serialise.UInt32(ref this.m_Flags); int numVerts = 4; if (0 == (this.m_Flags & IW_MODEL_PRIM_QUAD_F) && serialise.IsVersionOlderThen(3, 5, 6)) { numVerts = 3; } serialise.Serialise(ref this.m_IGIDs, numVerts); if (this.IsTextured) { // serialise.Int16(ref this.m_U0[0 * 2]); // serialise.Int16(ref this.m_U0[0 * 2 + 1]); // serialise.Int16(ref this.m_U0[1 * 2]); // serialise.Int16(ref this.m_U0[1 * 2 + 1]); // serialise.Int16(ref this.m_U0[2 * 2]); // serialise.Int16(ref this.m_U0[2 * 2 + 1]); // serialise.Int16(ref this.m_U0[3 * 2]); // serialise.Int16(ref this.m_U0[3 * 2 + 1]); if (0 != (this.m_Flags & IW_MODEL_PRIM_QUAD_F)) { serialise.Int16(ref this.m_U0[0 * 2]); serialise.Int16(ref this.m_U0[0 * 2 + 1]); serialise.Int16(ref this.m_U0[2 * 2]); serialise.Int16(ref this.m_U0[2 * 2 + 1]); serialise.Int16(ref this.m_U0[3 * 2]); serialise.Int16(ref this.m_U0[3 * 2 + 1]); serialise.Int16(ref this.m_U0[1 * 2]); serialise.Int16(ref this.m_U0[1 * 2 + 1]); } else { serialise.Int16(ref this.m_U0[0 * 2]); serialise.Int16(ref this.m_U0[0 * 2 + 1]); serialise.Int16(ref this.m_U0[2 * 2]); serialise.Int16(ref this.m_U0[2 * 2 + 1]); serialise.Int16(ref this.m_U0[1 * 2]); serialise.Int16(ref this.m_U0[1 * 2 + 1]); serialise.Int16(ref this.m_U0[3 * 2]); serialise.Int16(ref this.m_U0[3 * 2 + 1]); } } }
/// <summary> /// The serialise. /// </summary> /// <param name="serialise"> /// The serialise. /// </param> public override void Serialise(IwSerialise serialise) { base.Serialise(serialise); serialise.UInt32(ref this.materialId); this.inds = new ushort[this.numItems]; serialise.Serialise(ref this.inds); { serialise.UInt16(ref this.streamIdBegin); } { serialise.UInt16(ref this.streamIdEnd); } }
/// <summary> /// The serialise len str z. /// </summary> /// <param name="serialise"> /// The serialise. /// </param> /// <param name="str"> /// The str. /// </param> /// <exception cref="NotImplementedException"> /// </exception> public static void SerialiseLenStrZ(IwSerialise serialise, ref string str) { if (serialise.IsReading()) { int len = 0; serialise.Int32(ref len); byte[] b = new byte[len + 1]; serialise.Serialise(ref b); str = Encoding.ASCII.GetString(b); } else { throw new NotImplementedException(); } }
/// <summary> /// The serialise. /// </summary> /// <param name="serialise"> /// The serialise. /// </param> /// <exception cref="NotImplementedException"> /// </exception> public override void Serialise(IwSerialise serialise) { base.Serialise(serialise); { serialise.UInt16(ref this.uniqueValues); } short mediane = 0; serialise.Int16(ref mediane); var len = this.uniqueValues; // this.numItems; // this.Resize(this.numItems); if (serialise.IsWriting()) { throw new NotImplementedException(); } for (int i = 0; i < len; ++i) { short x = (short)(this.verts[i].X - mediane); serialise.Int16(ref x); this.verts[i].X = x + mediane; } for (int i = 0; i < len; ++i) { short y = (short)(this.verts[i].Y - mediane); serialise.Int16(ref y); this.verts[i].Y = y + mediane; } for (int i = 0; i < len; ++i) { short z = (short)(this.verts[i].Z - mediane); serialise.Int16(ref z); this.verts[i].Z = z + mediane; } ushort[] links = new ushort[this.numItems - this.uniqueValues]; serialise.Serialise(ref links); for (int i = this.uniqueValues; i < this.numItems; ++i) { this.verts[i] = this.verts[links[i - this.uniqueValues]]; } }
/// <summary> /// The serialise. /// </summary> /// <param name="serialise"> /// The serialise. /// </param> public override void Serialise(IwSerialise serialise) { base.Serialise(serialise); serialise.UInt32(ref this.m_MaterialID); serialise.UInt16(ref this.m_NumTupleIDs); if (serialise.IsReading()) { this.m_TupleIDs = new ushort[this.m_NumTupleIDs]; this.prims = new _IwModelPrim[this.numItems]; } serialise.Serialise(ref this.m_TupleIDs); for (int i = 0; i < this.numItems; ++i) { this.prims[i].Serialise(serialise); } }
private bool m_WorldSet; // !< True if this set is a world file only set #endregion #region Public Methods and Operators /// <summary> /// The serialise. /// </summary> /// <param name="serialise"> /// The serialise. /// </param> public override void Serialise(IwSerialise serialise) { base.Serialise(serialise); ////serialise.DebugWrite(256); // serialise.UInt8(ref m_Flags); serialise.Bool(ref this.m_WorldSet); serialise.UInt8(ref this.m_FlagsSW); serialise.UInt8(ref this.m_FlagsHW); serialise.UInt32(ref this.m_NumFaces); serialise.Int8(ref this.m_OTZOfsSW); this.m_FaceIDs.SerialiseHeader(serialise); this.m_FaceIDs.ForEach( (ref ushort v) => { serialise.Serialise(ref v); return(true); }); ////serialise.DebugWrite(256); }
private bool m_WorldSet; // !< True if this set is a world file only set #endregion Fields #region Methods /// <summary> /// The serialise. /// </summary> /// <param name="serialise"> /// The serialise. /// </param> public override void Serialise(IwSerialise serialise) { base.Serialise(serialise); ////serialise.DebugWrite(256); // serialise.UInt8(ref m_Flags); serialise.Bool(ref this.m_WorldSet); serialise.UInt8(ref this.m_FlagsSW); serialise.UInt8(ref this.m_FlagsHW); serialise.UInt32(ref this.m_NumFaces); serialise.Int8(ref this.m_OTZOfsSW); this.m_FaceIDs.SerialiseHeader(serialise); this.m_FaceIDs.ForEach( (ref ushort v) => { serialise.Serialise(ref v); return true; }); ////serialise.DebugWrite(256); }
/// <summary> /// The serialise. /// </summary> /// <param name="serialise"> /// The serialise. /// </param> /// <exception cref="NotImplementedException"> /// </exception> /// <exception cref="NotImplementedException"> /// </exception> public void Serialise(IwSerialise serialise) { SerialiseLenStr(serialise, ref this.name); serialise.UInt32(ref this.type); serialise.Int32(ref this.arraySize); serialise.UInt32(ref this.flags); if (serialise.IsReading()) { if (this.IsFloat) { this.floatData = new float[this.arraySize * this.NumberOfComponents]; serialise.Serialise(ref this.floatData); } else { throw new NotImplementedException(); } } else { throw new NotImplementedException(); } }