/// <summary> /// Adds the SlaveSubsets to the map /// </summary> /// <param name="map">Contains the MMATs that should be added</param> /// <param name="fullmap">Contains a List of all available MMATs</param> /// <remarks>The slave MMAT files will be added to the map</remarks> protected void AddSlavesSubsets(Hashtable map, Hashtable fullmap) { Hashtable slavemap = Scenegraph.GetSlaveSubsets(package); Hashtable newmap = new Hashtable(); int ct = 0; foreach (string k in map.Keys) { if (!fullmap.ContainsKey(k)) { if (slavemap.ContainsKey(k)) { if (map.ContainsKey(k)) { ArrayList slaves = (ArrayList)slavemap[k]; Hashtable families = (Hashtable)map[k]; foreach (ArrayList list in families.Values) { foreach (SimPe.Plugin.MmatWrapper mmat in list) { foreach (string subset in slaves) { ArrayList slavemmat = this.FindTxtrMatchingMmat(mmat, fullmap, subset); if (slavemmat != null) { Hashtable slaveht = new Hashtable(); slaveht["simpe_slave_loader_" + subset + "-" + ct.ToString()] = slavemmat; newmap[subset] = slaveht; ct++; } } //foreach subset } //foreach mmat } //foreach list } //if (map.ContainsKey(k)) } } } Hashtable nmap = new Hashtable(); foreach (string k in newmap.Keys) { if (!map.ContainsKey(k)) { nmap[k] = newmap[k]; } } if (newmap.Count > 0) { AddSlavesSubsets(nmap, fullmap); } foreach (string k in nmap.Keys) { map[k] = nmap[k]; } }
/// <summary> /// Adds the MMAT Files specified in the map to the new package /// </summary> /// <param name="newpkg"></param> /// <param name="map">Contains the MMATs that should be added</param> /// <param name="fullmap">Contains a List of all available MMATs</param> public void ProcessMmatMap(IPackageFile newpkg, Hashtable map, Hashtable fullmap) { if (WaitingScreen.Running) { WaitingScreen.UpdateMessage("Loading Slave Subsets"); } AddSlavesSubsets(map, fullmap); Hashtable slaves = Scenegraph.GetSlaveSubsets(package); uint inst = 0x6000; string unique = RenameForm.GetUniqueName(true); foreach (Hashtable ht in map.Values) { foreach (ArrayList list in ht.Values) { string family = System.Guid.NewGuid().ToString(); if (unique == null) { unique = family; } foreach (SimPe.Plugin.MmatWrapper mmat in list) { mmat.FileDescriptor = Scenegraph.Clone(mmat.FileDescriptor); mmat.FileDescriptor.Instance = inst++; mmat.FileDescriptor.Group = Data.MetaData.LOCAL_GROUP; mmat.Family = family; mmat.DefaultMaterial = false; GenericRcol txmt = mmat.TXMT; GenericRcol txtr = mmat.TXTR; this.AddTxmt(newpkg, mmat, txmt, txtr, unique, slaves); mmat.SynchronizeUserData(); newpkg.Add(mmat.FileDescriptor); } } } }
/// <summary> /// Clone a InGane Object based on the relations of the RCOL Files /// </summary> /// <param name="onlydefault">true if you only want default MMAT Files</param> /// <param name="exclude">List of ReferenceNames that should be excluded</param> public void RcolModelClone(string[] modelnames, ArrayList exclude) { if (modelnames == null) { return; } Scenegraph.FileExcludeList = Scenegraph.DefaultFileExcludeList; SimPe.FileTable.FileIndex.Load(); if (WaitingScreen.Running) { WaitingScreen.UpdateMessage("Walking Scenegraph"); } Scenegraph sg = new Scenegraph(modelnames, exclude, this.setup); if ((Setup.BaseResource & CloneSettings.BaseResourceType.Ref) == CloneSettings.BaseResourceType.Ref) { if (WaitingScreen.Running) { WaitingScreen.UpdateMessage("Reading 3IDR References"); } sg.AddFrom3IDR(package); } if ((Setup.BaseResource & CloneSettings.BaseResourceType.Xml) == CloneSettings.BaseResourceType.Xml) { if (WaitingScreen.Running) { WaitingScreen.UpdateMessage("Reading XObject Definition"); } sg.AddFromXml(package); } if (Setup.IncludeWallmask) { if (WaitingScreen.Running) { WaitingScreen.UpdateMessage("Scanning for Wallmasks"); } sg.AddWallmasks(modelnames); } if (Setup.PullResourcesByStr) { if (WaitingScreen.Running) { WaitingScreen.UpdateMessage("Scanning for #Str-linked Resources"); } sg.AddStrLinked(package, Setup.StrInstances); } if (Setup.IncludeAnimationResources) { if (WaitingScreen.Running) { WaitingScreen.UpdateMessage("Scanning for Animations"); } sg.AddAnims(this.GetAnimNames()); } if (WaitingScreen.Running) { WaitingScreen.UpdateMessage("Collect Slave TXMTs"); } sg.AddSlaveTxmts(sg.GetSlaveSubsets()); if (WaitingScreen.Running) { WaitingScreen.UpdateMessage("Building Package"); } sg.BuildPackage(package); if (WaitingScreen.Running) { WaitingScreen.UpdateMessage("Collect MMAT Files"); } sg.AddMaterialOverrides(package, setup.OnlyDefaultMmats, true, setup.ThrowExceptions); if (WaitingScreen.Running) { WaitingScreen.UpdateMessage("Collect Slave TXMTs"); } Scenegraph.AddSlaveTxmts(package, Scenegraph.GetSlaveSubsets(package)); if (setup.UpdateMmatGuids) { if (WaitingScreen.Running) { WaitingScreen.UpdateMessage("Fixing MMAT Files"); } this.UpdateMMATGuids(this.GetGuidList(), this.GetPrimaryGuid()); } }