public override byte[] Serialize(bool partofsomethingelse) { int currentIndex = 0, length = 0; bool hasmetacomponents = false; byte[] thischunk, scratch1, scratch2; List <byte[]> pieces = new List <byte[]>(); GCHandle h; //header if (header == null) { header = new Header(); } pieces.Add(header.Serialize(true)); //pose if (pose == null) { pose = new Pose(); } pieces.Add(pose.Serialize(true)); //twist if (twist == null) { twist = new Twist(); } pieces.Add(twist.Serialize(true)); //wrench if (wrench == null) { wrench = new Wrench(); } pieces.Add(wrench.Serialize(true)); //combine every array in pieces into one array and return it int __a_b__f = pieces.Sum((__a_b__c) => __a_b__c.Length); int __a_b__e = 0; byte[] __a_b__d = new byte[__a_b__f]; foreach (var __p__ in pieces) { Array.Copy(__p__, 0, __a_b__d, __a_b__e, __p__.Length); __a_b__e += __p__.Length; } return(__a_b__d); }
public override byte[] Serialize(bool partofsomethingelse) { int currentIndex = 0, length = 0; bool hasmetacomponents = false; byte[] thischunk, scratch1, scratch2; List <byte[]> pieces = new List <byte[]>(); GCHandle h; //body_name if (body_name == null) { body_name = ""; } scratch1 = Encoding.ASCII.GetBytes((string)body_name); thischunk = new byte[scratch1.Length + 4]; scratch2 = BitConverter.GetBytes(scratch1.Length); Array.Copy(scratch1, 0, thischunk, 4, scratch1.Length); Array.Copy(scratch2, thischunk, 4); pieces.Add(thischunk); //reference_frame if (reference_frame == null) { reference_frame = ""; } scratch1 = Encoding.ASCII.GetBytes((string)reference_frame); thischunk = new byte[scratch1.Length + 4]; scratch2 = BitConverter.GetBytes(scratch1.Length); Array.Copy(scratch1, 0, thischunk, 4, scratch1.Length); Array.Copy(scratch2, thischunk, 4); pieces.Add(thischunk); //reference_point if (reference_point == null) { reference_point = new Point(); } pieces.Add(reference_point.Serialize(true)); //wrench if (wrench == null) { wrench = new Wrench(); } pieces.Add(wrench.Serialize(true)); //start_time pieces.Add(BitConverter.GetBytes(start_time.data.sec)); pieces.Add(BitConverter.GetBytes(start_time.data.nsec)); //duration pieces.Add(BitConverter.GetBytes(duration.data.sec)); pieces.Add(BitConverter.GetBytes(duration.data.nsec)); //combine every array in pieces into one array and return it int __a_b__f = pieces.Sum((__a_b__c) => __a_b__c.Length); int __a_b__e = 0; byte[] __a_b__d = new byte[__a_b__f]; foreach (var __p__ in pieces) { Array.Copy(__p__, 0, __a_b__d, __a_b__e, __p__.Length); __a_b__e += __p__.Length; } return(__a_b__d); }
public override byte[] Serialize(bool partofsomethingelse) { int currentIndex = 0, length = 0; bool hasmetacomponents = false; byte[] thischunk, scratch1, scratch2; List <byte[]> pieces = new List <byte[]>(); GCHandle h; //info if (info == null) { info = ""; } scratch1 = Encoding.ASCII.GetBytes((string)info); thischunk = new byte[scratch1.Length + 4]; scratch2 = BitConverter.GetBytes(scratch1.Length); Array.Copy(scratch1, 0, thischunk, 4, scratch1.Length); Array.Copy(scratch2, thischunk, 4); pieces.Add(thischunk); //collision1_name if (collision1_name == null) { collision1_name = ""; } scratch1 = Encoding.ASCII.GetBytes((string)collision1_name); thischunk = new byte[scratch1.Length + 4]; scratch2 = BitConverter.GetBytes(scratch1.Length); Array.Copy(scratch1, 0, thischunk, 4, scratch1.Length); Array.Copy(scratch2, thischunk, 4); pieces.Add(thischunk); //collision2_name if (collision2_name == null) { collision2_name = ""; } scratch1 = Encoding.ASCII.GetBytes((string)collision2_name); thischunk = new byte[scratch1.Length + 4]; scratch2 = BitConverter.GetBytes(scratch1.Length); Array.Copy(scratch1, 0, thischunk, 4, scratch1.Length); Array.Copy(scratch2, thischunk, 4); pieces.Add(thischunk); //wrenches hasmetacomponents |= true; if (wrenches == null) { wrenches = new Wrench[0]; } pieces.Add(BitConverter.GetBytes(wrenches.Length)); for (int i = 0; i < wrenches.Length; i++) { //wrenches[i] if (wrenches[i] == null) { wrenches[i] = new Wrench(); } pieces.Add(wrenches[i].Serialize(true)); } //total_wrench if (total_wrench == null) { total_wrench = new Wrench(); } pieces.Add(total_wrench.Serialize(true)); //contact_positions hasmetacomponents |= true; if (contact_positions == null) { contact_positions = new Vector3[0]; } pieces.Add(BitConverter.GetBytes(contact_positions.Length)); for (int i = 0; i < contact_positions.Length; i++) { //contact_positions[i] if (contact_positions[i] == null) { contact_positions[i] = new Vector3(); } pieces.Add(contact_positions[i].Serialize(true)); } //contact_normals hasmetacomponents |= true; if (contact_normals == null) { contact_normals = new Vector3[0]; } pieces.Add(BitConverter.GetBytes(contact_normals.Length)); for (int i = 0; i < contact_normals.Length; i++) { //contact_normals[i] if (contact_normals[i] == null) { contact_normals[i] = new Vector3(); } pieces.Add(contact_normals[i].Serialize(true)); } //depths hasmetacomponents |= false; if (depths == null) { depths = new double[0]; } pieces.Add(BitConverter.GetBytes(depths.Length)); for (int i = 0; i < depths.Length; i++) { //depths[i] scratch1 = new byte[Marshal.SizeOf(typeof(double))]; h = GCHandle.Alloc(scratch1, GCHandleType.Pinned); Marshal.StructureToPtr(depths[i], h.AddrOfPinnedObject(), false); h.Free(); pieces.Add(scratch1); } //combine every array in pieces into one array and return it int __a_b__f = pieces.Sum((__a_b__c) => __a_b__c.Length); int __a_b__e = 0; byte[] __a_b__d = new byte[__a_b__f]; foreach (var __p__ in pieces) { Array.Copy(__p__, 0, __a_b__d, __a_b__e, __p__.Length); __a_b__e += __p__.Length; } return(__a_b__d); }