Example #1
0
        public bool ImportFromPSA(string path)
        {
            PSAFile psa = new PSAFile();

            psa.ImportPSA(path);
            PSAFile.PSAData d = psa.data;
            DebugOutput.PrintLn("Checking data...");
            if (d.Bones.Count != SetData.TrackBoneNames.Count)
            {
                MessageBox.Show("Cant import: different count of bones");
                return(false);
            }
            for (int i = 0; i < SetData.TrackBoneNames.Count; i++)
            {
                if (d.Bones[i].name != SetData.TrackBoneNames[i])
                {
                    MessageBox.Show("Cant import: couldnt match all bones");
                    return(false);
                }
            }
            if (d.Infos.Count != Sequences.Count)
            {
                MessageBox.Show("Cant import: different count of sequences");
                return(false);
            }
            for (int i = 0; i < Sequences.Count; i++)
            {
                AnimSequence ans = new AnimSequence(pcc, Sequences[i]);
                if (d.Infos[i].name != pcc.getNameEntry(ans.SequenceName))
                {
                    MessageBox.Show("Cant import: couldnt match all sequences");
                    return(false);
                }
            }
            int pos = 0;

            for (int i = 0; i < Sequences.Count; i++)
            {
                DebugOutput.PrintLn("Importing into AnimSequence #" + Sequences[i] + " ...");
                AnimSequence        ans = new AnimSequence(pcc, Sequences[i]);
                PSAFile.PSAAnimInfo inf = d.Infos[i];
                List <Vector3>      loc = new List <Vector3>();
                List <Vector4>      rot = new List <Vector4>();
                for (int j = 0; j < inf.TotalBones; j++)
                {
                    PSAFile.PSAAnimKeys key = d.Keys[pos + j];
                    loc.Add(key.location.ToVector3());
                    rot.Add(key.rotation.ToVector4());
                }
                ans.ImportKeys(loc.ToArray(), rot.ToArray(), inf.NumRawFrames);
                ans.SaveChanges();
                pos += inf.KeyQuotum;
            }
            pcc.save();
            return(true);
        }
Example #2
0
 public void SaveChanges()
 {
     foreach (StaticMeshCollectionActor stmca in STM_CA)
     {
         stmca.SaveChanges();
     }
     foreach (StaticMeshActor stma in STM_A)
     {
         stma.SaveChanges();
     }
     foreach (InterpActor ia in IA)
     {
         ia.SaveChanges();
     }
     foreach (BlockingVolume bv in BV)
     {
         bv.SaveChanges();
     }
     foreach (SplineActor sp in SPA)
     {
         sp.SaveChanges();
     }
     foreach (TargetPoint tp in TP)
     {
         tp.SaveChanges();
     }
     foreach (LightVolume lv in LV)
     {
         lv.SaveChanges();
     }
     foreach (MantleMarker mm in MM)
     {
         mm.SaveChanges();
     }
     foreach (PathNode pn in PN)
     {
         pn.SaveChanges();
     }
     foreach (CoverLink cl in CL)
     {
         cl.SaveChanges();
     }
     foreach (CoverSlotMarker csm in CSM)
     {
         csm.SaveChanges();
     }
     foreach (Emitter em in EM)
     {
         em.SaveChanges();
     }
     foreach (BioPlaypenVolumeAdditive bpva in BPVA)
     {
         bpva.SaveChanges();
     }
     foreach (BioTriggerVolume btv in BTV)
     {
         btv.SaveChanges();
     }
     foreach (BioPathPoint bpp in BPP)
     {
         bpp.SaveChanges();
     }
     foreach (WwiseAmbientSound was in WAS)
     {
         was.SaveChanges();
     }
     foreach (WwiseAudioVolume wav in WAV)
     {
         wav.SaveChanges();
     }
     foreach (WwiseEnvironmentVolume wev in WEV)
     {
         wev.SaveChanges();
     }
     DebugOutput.PrintLn("Saving \"" + Path.GetFileName(pcc.FileName) + "\" ...");
     pcc.save();
 }
Example #3
0
        private void importLODToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ME3Package pcc = null;

            try
            {
                int n = listBox1.SelectedIndex;
                if (n == -1)
                {
                    return;
                }
                int m = listBox2.SelectedIndex;
                if (m == -1)
                {
                    return;
                }
                TreeNode t1 = treeView1.SelectedNode;
                if (t1 == null || t1.Parent == null || t1.Name == "")
                {
                    return;
                }
                SkeletalMesh skm = new SkeletalMesh();
                EntryStruct  en;
                string       loc = Path.GetDirectoryName(Application.ExecutablePath) + "\\exec\\";
                if (DisplayStyle == 0)
                {
                    int o = 0;
                    if (!Int32.TryParse(t1.Name, out o))
                    {
                        return;
                    }
                    en = Entries[o];
                    if (!en.isDLC)
                    {
                        if (en.isSkeletal)
                        {
                            pcc = MEPackageHandler.OpenME3Package(ME3Directory.cookedPath + en.Filename);
                            skm = new SkeletalMesh(pcc, en.Index);
                        }
                        else
                        {
                            return;
                        }
                    }
                    else
                    {
                        string dirDLC = ME3Directory.DLCPath;
                        dirDLC += en.DLCName;
                        dirDLC += "\\CookedPCConsole\\Default.sfar";
                        DLCBase dlc = new DLCBase(dirDLC);
                        foreach (sfarFile file in dlc.fileList)
                        {
                            try
                            {
                                string filename = Path.GetFileName(file.fileName);
                                if (Path.GetExtension(filename).ToLower().EndsWith(".pcc") && filename == en.Filename)
                                {
                                    if (File.Exists(loc + "dlc.pcc"))
                                    {
                                        File.Delete(loc + "dlc.pcc");
                                    }
                                    using (Stream input = File.OpenRead(dirDLC), output = File.Create(loc + "dlc.pcc"))
                                    {
                                        AmaroK86.MassEffect3.DLCUnpack.DecompressEntry(file, input, output, dlc.CompressionScheme);
                                    }
                                    if (File.Exists(loc + "dlc.pcc"))
                                    {
                                        try
                                        {
                                            if (en.isSkeletal)
                                            {
                                                pcc = MEPackageHandler.OpenME3Package(loc + "dlc.pcc");
                                                skm = new SkeletalMesh(pcc, en.Index);
                                                break;
                                            }
                                            else
                                            {
                                                return;
                                            }
                                        }
                                        catch (Exception)
                                        {
                                            return;
                                        }
                                    }
                                }
                            }
                            catch (Exception)
                            {
                                return;
                            }
                        }
                    }
                }
                else
                {
                    return;
                }
                if (!skm.Loaded || pcc == null)
                {
                    return;
                }
                SkeletalMesh.LODModelStruct          lodpcc = skm.LODModels[0];
                UDKExplorer.UDK.Classes.SkeletalMesh skmudk = new UDKExplorer.UDK.Classes.SkeletalMesh(udk, Objects[n]);
                UDKExplorer.UDK.Classes.SkeletalMesh.LODModelStruct lodudk = skmudk.LODModels[m];
                lodpcc.Sections = new List <SkeletalMesh.SectionStruct>();
                foreach (UDKExplorer.UDK.Classes.SkeletalMesh.SectionStruct secudk in lodudk.Sections)
                {
                    SkeletalMesh.SectionStruct secpcc = new SkeletalMesh.SectionStruct();
                    secpcc.BaseIndex     = secudk.BaseIndex;
                    secpcc.ChunkIndex    = secudk.ChunkIndex;
                    secpcc.MaterialIndex = secudk.MaterialIndex;
                    secpcc.NumTriangles  = secudk.NumTriangles;
                    lodpcc.Sections.Add(secpcc);
                }
                lodpcc.IndexBuffer            = new SkeletalMesh.MultiSizeIndexContainerStruct();
                lodpcc.IndexBuffer.IndexCount = lodudk.IndexBuffer.IndexCount;
                lodpcc.IndexBuffer.IndexSize  = lodudk.IndexBuffer.IndexSize;
                lodpcc.IndexBuffer.Indexes    = new List <ushort>();
                foreach (ushort Idx in lodudk.IndexBuffer.Indexes)
                {
                    lodpcc.IndexBuffer.Indexes.Add(Idx);
                }
                List <int> BoneMap = new List <int>();
                for (int i = 0; i < skmudk.Bones.Count; i++)
                {
                    string udkb  = udk.GetName(skmudk.Bones[i].Name);
                    bool   found = false;
                    for (int j = 0; j < skm.Bones.Count; j++)
                    {
                        string pccb = pcc.getNameEntry(skm.Bones[j].Name);
                        if (pccb == udkb)
                        {
                            found = true;
                            BoneMap.Add(j);
                            if (importBonesToolStripMenuItem.Checked)
                            {
                                SkeletalMesh.BoneStruct bpcc = skm.Bones[j];
                                UDKExplorer.UDK.Classes.SkeletalMesh.BoneStruct budk = skmudk.Bones[i];
                                bpcc.Orientation = budk.Orientation;
                                bpcc.Position    = budk.Position;
                                skm.Bones[j]     = bpcc;
                            }
                        }
                    }
                    if (!found)
                    {
                        DebugOutput.PrintLn("ERROR: Cant Match Bone \"" + udkb + "\"");
                        BoneMap.Add(0);
                    }
                }

                lodpcc.ActiveBones = new List <ushort>();
                foreach (ushort Idx in lodudk.ActiveBones)
                {
                    lodpcc.ActiveBones.Add((ushort)BoneMap[Idx]);
                }
                lodpcc.Chunks = new List <SkeletalMesh.SkelMeshChunkStruct>();
                foreach (UDKExplorer.UDK.Classes.SkeletalMesh.SkelMeshChunkStruct chunkudk in lodudk.Chunks)
                {
                    SkeletalMesh.SkelMeshChunkStruct chunkpcc = new SkeletalMesh.SkelMeshChunkStruct();
                    chunkpcc.BaseVertexIndex   = chunkudk.BaseVertexIndex;
                    chunkpcc.MaxBoneInfluences = chunkudk.MaxBoneInfluences;
                    chunkpcc.NumRigidVertices  = chunkudk.NumRigidVertices;
                    chunkpcc.NumSoftVertices   = chunkudk.NumSoftVertices;
                    chunkpcc.BoneMap           = new List <ushort>();
                    chunkpcc.RiginSkinVertices = new List <SkeletalMesh.RigidSkinVertexStruct>();
                    chunkpcc.SoftSkinVertices  = new List <SkeletalMesh.SoftSkinVertexStruct>();
                    foreach (ushort Idx in chunkudk.BoneMap)
                    {
                        chunkpcc.BoneMap.Add((ushort)BoneMap[Idx]);
                    }
                    lodpcc.Chunks.Add(chunkpcc);
                }
                lodpcc.Size          = lodudk.Size;
                lodpcc.NumVertices   = lodudk.NumVertices;
                lodpcc.RequiredBones = new List <byte>();
                foreach (byte b in lodudk.RequiredBones)
                {
                    lodpcc.RequiredBones.Add(b);
                }
                lodpcc.VertexBufferGPUSkin = new SkeletalMesh.VertexBufferGPUSkinStruct();
                lodpcc.VertexBufferGPUSkin.NumTexCoords = lodudk.VertexBufferGPUSkin.NumTexCoords;
                lodpcc.VertexBufferGPUSkin.Extension    = lodudk.VertexBufferGPUSkin.Extension;
                lodpcc.VertexBufferGPUSkin.Origin       = lodudk.VertexBufferGPUSkin.Origin;
                lodpcc.VertexBufferGPUSkin.VertexSize   = lodudk.VertexBufferGPUSkin.VertexSize;
                lodpcc.VertexBufferGPUSkin.Vertices     = new List <SkeletalMesh.GPUSkinVertexStruct>();
                foreach (UDKExplorer.UDK.Classes.SkeletalMesh.GPUSkinVertexStruct vudk in lodudk.VertexBufferGPUSkin.Vertices)
                {
                    SkeletalMesh.GPUSkinVertexStruct vpcc = new SkeletalMesh.GPUSkinVertexStruct();
                    vpcc.TangentX         = vudk.TangentX;
                    vpcc.TangentZ         = vudk.TangentZ;
                    vpcc.Position         = vudk.Position;
                    vpcc.InfluenceBones   = vudk.InfluenceBones;
                    vpcc.InfluenceWeights = vudk.InfluenceWeights;
                    vpcc.U = vudk.U;
                    vpcc.V = vudk.V;
                    lodpcc.VertexBufferGPUSkin.Vertices.Add(vpcc);
                }
                for (int i = 0; i < skm.LODModels.Count; i++)
                {
                    skm.LODModels[i] = lodpcc;
                }
                SerializingContainer con = new SerializingContainer();
                con.Memory    = new MemoryStream();
                con.isLoading = false;
                skm.Serialize(con);
                int          end = skm.GetPropertyEnd();
                MemoryStream mem = new MemoryStream();
                mem.Write(pcc.Exports[en.Index].Data, 0, end);
                mem.Write(con.Memory.ToArray(), 0, (int)con.Memory.Length);
                pcc.Exports[en.Index].Data = mem.ToArray();
                pcc.save();
                if (!en.isDLC)
                {
                    MessageBox.Show("Done");
                }
                else
                {
                    MessageBox.Show("Done. The file is now in following folder, please replace it back to DLC :\n" + loc + "dlc.pcc");
                }
                globalTreeToolStripMenuItem.Visible       =
                    optionsToolStripMenuItem.Visible      =
                        transferToolStripMenuItem.Visible =
                            splitContainer1.Visible       = true;
                fileToolStripMenuItem.Visible             =
                    importLODToolStripMenuItem.Visible    =
                        splitContainer3.Visible           = false;
            }
            finally
            {
                pcc?.Dispose();
            }
        }