void MergeFrame(odfFrame newFrame, int destParentIdx) { odfFrame srcParent = new odfFrame(new ObjectName("A new frame", null), ObjectID.INVALID, 1); srcParent.AddChild(newFrame); odfFrame destParent; if (destParentIdx < 0) { destParent = new odfFrame(new ObjectName("Another new frame", null), ObjectID.INVALID, 1); destParent.AddChild(Parser.FrameSection.RootFrame); } else { destParent = Frames[destParentIdx]; } MergeFrame(srcParent, destParent); if (destParentIdx < 0) { Parser.FrameSection.RootFrame = srcParent[0]; srcParent.RemoveChild(0); } Frames.Clear(); InitFrames(Parser.FrameSection.RootFrame); }
public static odfFrame CreateFrame(ImportedFrame frame, odfParser parser) { odfFrame newFrame = new odfFrame(new ObjectName(frame.Name, null), null, frame.Count); newFrame.MeshId = ObjectID.INVALID; newFrame.Matrix = frame.Matrix; for (int i = 0; i < frame.Count; i++) { newFrame.AddChild(CreateFrame(frame[i], parser)); } return(newFrame); }
private bool loadFRAM(BinaryReader reader, odfFileSection fileSec) { odfFrameSection objSection = new odfFrameSection(); for (int secOffset = 0; secOffset < fileSec.Size; secOffset += 64 + 4 + 16 * 4 + 44 + 4 + 4 + 216 + 4 + 8 * 4 + 12 + 4 + 0x1FC + 4 + 8 + 4) { ObjectName name = new ObjectName(reader.ReadBytes(64)); ObjectID id = new ObjectID(reader.ReadBytes(4)); odfFrame frame = new odfFrame(name, id, 4); frame.Matrix = reader.ReadMatrix(); frame.AlwaysZero1 = reader.ReadBytes(44); frame.ParentId = new ObjectID(reader.ReadBytes(4)); frame.MeshId = new ObjectID(reader.ReadBytes(4)); frame.AlwaysZero2 = reader.ReadBytes(216); frame.Unknown3 = reader.ReadInt32(); frame.Unknown4 = reader.ReadSingleArray(8); frame.Unknown5 = reader.ReadUInt32(); frame.Unknown6 = reader.ReadInt32(); frame.AlwaysZero7 = reader.ReadBytes(4); frame.Unknown8 = reader.ReadSingle(); frame.AlwaysZero9 = reader.ReadBytes(0x1FC); frame.Unknown10 = reader.ReadSingle(); frame.AlwaysZero11 = reader.ReadBytes(8); frame.Unknown12 = reader.ReadSingle(); if (objSection.Count > 0) { odfFrame parentFrame = odf.FindFrame(frame.ParentId, objSection.RootFrame); if (parentFrame == null) { Console.WriteLine("Error in FRAM : ParentId " + frame.ParentId + " not found for frame " + frame.Name); return(false); } else { parentFrame.AddChild(frame); } } else { objSection.AddChild(frame); } } fileSec.Section = objSection; this.FrameSection = objSection; return(true); }
void MergeFrame(odfFrame srcParent, odfFrame destParent) { for (int i = 0; i < destParent.Count; i++) { var dest = destParent[i]; for (int j = 0; j < srcParent.Count; j++) { var src = srcParent[j]; if (src.Name.ToString() == dest.Name.ToString()) { MergeFrame(src, dest); srcParent.RemoveChild(j); if (dest.MeshId != null && (int)dest.MeshId != 0) { odfMesh mesh = odf.FindMeshListSome(dest.MeshId, Parser.MeshSection); odf.RemoveMesh(Parser, mesh, dest, false); } destParent.RemoveChild(i); destParent.InsertChild(i, src); break; } } } if (srcParent.Name.ToString() == destParent.Name.ToString()) { while (destParent.Count > 0) { var dest = destParent[0]; destParent.RemoveChild(0); srcParent.AddChild(dest); } } else { while (srcParent.Count > 0) { var src = srcParent[0]; srcParent.RemoveChild(0); destParent.AddChild(src); } } }