Пример #1
0
 public void LoadBodySetup(int setup)
 {
     if (setup == -1) return;
     BodySetup = setup - 1;
     if (BodySetup < 0 || BodySetup >= Pcc.Header.ExportCount) return;
     byte[] buff = Pcc.EntryToBuff(BodySetup);
     string c = Pcc.getClassName(Pcc.Export[BodySetup].Class);
     UnrealObject UOb = new UnrealObject(buff, c, Pcc.names);
     string l = Path.GetDirectoryName(Application.ExecutablePath);
     if (File.Exists(l + "\\exec\\DefaultProp.xml"))
         UOb.UUkn.UPR.ImportDefinitionsXML(l + "\\exec\\DefaultProp.xml");
     List<UPropertyReader.Property> p = UOb.UUkn.Properties;
     for (int i = 0; i < p.Count; i++)
     { }
 }
Пример #2
0
 public void LoadTextures()
 {
     DialogResult r = MessageBox.Show("Load textures too?","", MessageBoxButtons.YesNo);
     if (r == DialogResult.No)
     {
         for (int i = 0; i < UStat.Count; i++)
             UStat[i].LP.textureindex = -1;
         return;
     }
     r = MessageBox.Show("Load from tfcs?", "", MessageBoxButtons.YesNo);
     string ptex = "", pctex = "";
     if (r == DialogResult.Yes)
     {
         OpenFileDialog d = new OpenFileDialog();
         d.Filter = "Textures.tfc|Textures.tfc";
         if (d.ShowDialog() == DialogResult.OK)
             ptex = d.FileName;
         d.Filter = "CharTextures.tfc|CharTextures.tfc";
         if (d.ShowDialog() == DialogResult.OK)
             pctex = d.FileName;
     }
     int count = 50;
     int counttex = 0;
     int countmat = 0;
     for (int i = 0; i < UStat.Count; i++)
         if (UStat[i].Materials == null || UStat[i].Materials.Count() == 0)
         {
             if (count < 49)
                 count++;
             else
             {
                 count = 0;
                 TextOut("\n" + i.ToString() + "\t");
             }
             TextOut("x");
             UStat[i].LP.textureindex = -1;
         }
         else
         {                    
             if (count < 49)
                 count++;
             else
             {
                 count = 0;
                 TextOut("\n" + i.ToString() + "\t");
             }
             UStat[i].LP.textureindex = -1;
             int stype = -1;//0=MIC 1=MAT
             int index = -1;
             for (int k = 0; k < UStat[i].Materials.Count; k++)
             {
                 byte[] buff = UStat[i].Materials[k].raw;                        
                 for (int j = 0; j < 11; j++)
                 {
                     int idx = BitConverter.ToInt32(buff, j * 4);
                     if (idx > 0 && idx < pcc.Header.ExportCount)
                     {
                         string s = pcc.getClassName(pcc.Export[idx].Class);
                         if (s == "MaterialInstanceConstant")
                         {
                             index = idx;
                             stype = 0;
                             break;
                         }
                         if (s == "Material")
                         {
                             index = idx;
                             stype = 1;
                             break;
                         }
                     }
                 }
             }
             if (index < 0)
             {
                 TextOut("?");
                 continue;
             }
             #region MIC
             if (stype == 0)
             {
                 UnrealObject UOb = new UnrealObject(pcc.EntryToBuff(index), pcc.getClassName(pcc.Export[index].Class), pcc.names);
                 string l = Path.GetDirectoryName(Application.ExecutablePath);
                 UOb.UUkn.UPR = UPR;
                 UOb.UUkn.Deserialize();
                 int entry = UPR.FindProperty("TextureParameterValues", UOb.UUkn.Properties);
                 if (entry != -1)
                 {
                     entry += 4;
                     index = -1;
                     bool stopme = false;
                     while (entry < UOb.UUkn.Properties.Count() && UOb.UUkn.Properties[entry].name == "ParameterValue" && !stopme)
                     {
                         entry++;
                         int n = BitConverter.ToInt32(UOb.UUkn.Properties[entry].raw, UOb.UUkn.Properties[entry].raw.Length - 4) - 1;
                         if (n > 0)
                         {
                             index = n;
                             if (pcc.names[pcc.Export[n].Name].ToLower().Contains("diff"))
                                 stopme = true;
                         }
                         entry += 5;
                     }
                     if (index != -1)
                     {
                         bool found = false;
                         for (int j = 0; j < Tex.Count(); j++)
                             if (index == Tex[j].index)
                             {
                                 UStat[i].LP.textureindex = j;
                                 TextOut("f");
                                 found = true;
                                 break;
                             }
                         if (!found)
                         {
                             UOb = new UnrealObject(pcc.EntryToBuff(index), "Texture2D", pcc.names);
                             TextureEntry t = new TextureEntry();
                             int tfc = -1;
                             for (int j = 0; j < UOb.UTex2D.TextureTFCs.Count; j++)
                                 if (UOb.UTex2D.TextureTFCs[j].size > 0 &&
                                     UOb.UTex2D.TextureTFCs[j].offset > 0 &&
                                     UOb.UTex2D.TextureTFCs[j].size != UOb.UTex2D.TextureTFCs[j].offset)
                                 {
                                     tfc = j;
                                     break;
                                 }
                             t.tex = UOb.UTex2D.ExportToTexture(device, tfc, ptex, pctex);
                             t.index = index;
                             t.name = pcc.names[pcc.Export[t.index].Name];
                             t.name = t.name.Substring(0, t.name.Length - 1);
                             Tex.Add(t);
                             UStat[i].LP.textureindex = Tex.Count - 1;
                             TextOut("l");
                             counttex++;
                         }
                     }
                     else TextOut("?");
                 }
                 else TextOut("?");
             }
             #endregion
             if (stype == 1)
             {
                 UnrealObject UOb = new UnrealObject(pcc.EntryToBuff(index), pcc.getClassName(pcc.Export[index].Class), pcc.names);
                 string l = Path.GetDirectoryName(Application.ExecutablePath);
                 UOb.UMat.UPR = UPR;
                 UOb.UMat.Deserialize();
                 int entry = UPR.FindProperty("Expressions", UOb.UMat.props);
                 if (entry == 0)
                 {
                     entry ++;
                     int len = UOb.UMat.props[1].raw.Length;
                     int cnt = (len - 20) / 4;
                     index =-1;
                     for(int j=0;j<cnt;j++)
                     {
                         index = BitConverter.ToInt32(UOb.UMat.props[1].raw, 20 + j * 4)-1;
                         if (pcc.getClassName(pcc.Export[index].Class) == "MaterialExpressionTextureSampleParamter2D")
                             break;
                     }
                     if (index == -1)
                     {
                         TextOut("?");
                         continue;
                     }
                     UnrealObject UUOb2 = new UnrealObject(pcc.EntryToBuff(index), "MaterialExpressionTextureSampleParameter2D",pcc.names);
                     UUOb2.UUkn.UPR = UPR;
                     UUOb2.UUkn.Deserialize();
                     index = -1;
                     for (int j = 0; j < UUOb2.UUkn.Properties.Count; j++)
                         if (UUOb2.UUkn.Properties[j].name == "Texture")
                             index = PropToInt(UUOb2.UUkn.Properties[j].raw);
                     if (index != -1 && !(index<0))
                     {
                         index--;
                         bool found = false;
                         for (int j = 0; j < Tex.Count(); j++)
                             if (index == Tex[j].index)
                             {
                                 UStat[i].LP.textureindex = j;
                                 TextOut("F");
                                 found = true;
                                 break;
                             }
                         if (!found)
                         {
                             UOb = new UnrealObject(pcc.EntryToBuff(index), "Texture2D", pcc.names);
                             TextureEntry t = new TextureEntry();
                             int tfc = -1;
                             for (int j = 0; j < UOb.UTex2D.TextureTFCs.Count; j++)
                                 if (UOb.UTex2D.TextureTFCs[j].size > 0 &&
                                     UOb.UTex2D.TextureTFCs[j].offset > 0 &&
                                     UOb.UTex2D.TextureTFCs[j].size != UOb.UTex2D.TextureTFCs[j].offset)
                                 {
                                     tfc = j;
                                     break;
                                 }
                             t.tex = UOb.UTex2D.ExportToTexture(device, tfc, ptex, pctex);
                             t.index = index;
                             t.name = pcc.names[pcc.Export[t.index].Name];
                             t.name = t.name.Substring(0, t.name.Length - 1);
                             Tex.Add(t);
                             UStat[i].LP.textureindex = Tex.Count - 1;
                             TextOut("M");
                             countmat++;
                         }
                     }
                     else TextOut("?");
                 }
                 else TextOut("?");
             }
         }
     TextOut("\nLoaded Textures: " + counttex.ToString());
     TextOut("\nLoaded Materials: " + countmat.ToString());
 }