Example #1
0
 public void Serialize(SerializingContainer con)
 {
     v0 = con + v0;
     v1 = con + v1;
     v2 = con + v2;
     mat = con + mat;
 }
 void SerializeHeader(SerializingContainer Container)
 {
     if (Container.isLoading)
         header = new ME2HeaderStruct();
     header.Magic = Container + header.Magic;
     header.unk1 = Container + header.unk1;
     int count = 0;
     if (!Container.isLoading)
         count = header.Licensee.Length;
     else
         header.Licensee = "";
     header.Licensee = SerializeString(Container, header.Licensee);
     count = 0;
     if (!Container.isLoading)
         count = header.Project.Length;
     else
         header.Project = "";
     header.Project = SerializeString(Container, header.Project);
     header.unk3 = Container + header.unk3;
     header.unk4 = Container + header.unk4;
     count = 0;
     if (!Container.isLoading)
         count = header.Names.Length;
     count = Container + count;
     if (Container.isLoading)
         header.Names = new string[count];
     ushort unk = 0;
     for (int i = 0; i < count; i++)
     {
         unk = Container + unk;
         header.Names[i] = SerializeString(Container, header.Names[i]);
     }
 }
Example #3
0
 public void Serialize(SerializingContainer Container)
 {
     MaterialIndex = Container + MaterialIndex;
     ChunkIndex = Container + ChunkIndex;
     BaseIndex = Container + BaseIndex;
     NumTriangles = Container + NumTriangles;
     TriangleSorting = Container + TriangleSorting;
 }
 public ME3FaceFXAnimSet(IMEPackage Pcc, IExportEntry Entry)
 {
     
     pcc = Pcc;
     export = Entry;
     List<PropertyReader.Property> props = PropertyReader.getPropList(export);
     int start = props[props.Count - 1].offend + 4;
     SerializingContainer Container = new SerializingContainer(new MemoryStream(export.Data.Skip(start).ToArray()));
     Container.isLoading = true;
     Serialize(Container);
 }
Example #5
0
 public void Serialize(SerializingContainer Container)
 {
     if (Container.isLoading)
         Bounding = new BoundingStruct();
     Bounding.Serialize(Container);
     BodySetup = Container + BodySetup;
     SerializeMinMax(Container);
     SerializekDOPTree(Container);
     SerializeRawTriangles(Container);
     InternalVersion = Container + InternalVersion;
     ReadEnd = Container.GetPos();
 }
Example #6
0
 public StaticMesh(UDKObject udk, int Index)
 {
     MyIndex = Index;
     Owner = udk;
     int start = GetPropertyEnd(Index);
     byte[] buff = new byte[udk.Exports[Index].data.Length - start];
     for (int i = 0; i < udk.Exports[Index].data.Length - start; i++)
         buff[i] = udk.Exports[Index].data[i + start];
     MemoryStream m = new MemoryStream(buff);
     SerializingContainer Container = new SerializingContainer(m);
     Container.isLoading = true;
     Serialize(Container);
 }
Example #7
0
 public void Serialize(SerializingContainer Container)
 {
     NeedsCPUAccess = Container + NeedsCPUAccess;
     DataTypeSize = Container + DataTypeSize;
     IndexSize = Container + IndexSize;
     IndexCount = Container + IndexCount;
     if (Container.isLoading)
     {
         Indexes = new List<ushort>();
         for (int i = 0; i < IndexCount; i++)
             Indexes.Add(0);
     }
     for (int i = 0; i < IndexCount; i++)
         Indexes[i] = Container + Indexes[i];
 }
 void SerializeHeader(SerializingContainer Container)
 {
     if (Container.isLoading)
         header = new ME3HeaderStruct();
     header.Magic = Container + header.Magic;
     header.unk1 = Container + header.unk1;
     header.unk2 = Container + header.unk2;
     int count = 0;
     if (!Container.isLoading)
         count = header.Licensee.Length;
     else
         header.Licensee = "";
     header.Licensee = SerializeString(Container, header.Licensee);
     count = 0;
     if (!Container.isLoading)
         count = header.Project.Length;
     else
         header.Project = "";
     header.Project = SerializeString(Container, header.Project);
     header.unk3 = Container + header.unk3;
     header.unk4 = Container + header.unk4;
     count = 0;
     if (!Container.isLoading)
         count = header.Nodes.Length;
     count = Container + count;
     if (Container.isLoading)
         header.Nodes = new HNodeStruct[count];
     for (int i = 0; i < count; i++)
     {
         if (Container.isLoading)
             header.Nodes[i] = new HNodeStruct();
         HNodeStruct t = header.Nodes[i];
         t.unk1 = Container + t.unk1;
         t.unk2 = Container + t.unk2;
         t.Name = SerializeString(Container, t.Name);
         t.unk3 = Container + t.unk3;
         header.Nodes[i] = t;
     }
     count = 0;
     if (!Container.isLoading)
         count = header.Names.Length;
     count = Container + count;
     if (Container.isLoading)
         header.Names = new string[count];
     for (int i = 0; i < count; i++)
         header.Names[i] = SerializeString(Container, header.Names[i]);
 }
Example #9
0
 public void Serialize(SerializingContainer Container)
 {
     Position.X = Container + Position.X;
     Position.Y = Container + Position.Y;
     Position.Z = Container + Position.Z;
     TangentX = Container + TangentX;
     TangentY = Container + TangentY;
     TangentZ = Container + TangentZ;                
     if (Container.isLoading)
         UV = new Vector2[4];
     for (int i = 0; i < 4; i++)
     {
         UV[i].X = Container + UV[i].X;
         UV[i].Y = Container + UV[i].Y;
     }
     Color = Container + Color;
     Bone = Container + Bone;  
 }
 public void Serialize(SerializingContainer Container)
 {
     Position.X = Container + Position.X;
     Position.Y = Container + Position.Y;
     Position.Z = Container + Position.Z;
     TangentX   = Container + TangentX;
     TangentY   = Container + TangentY;
     TangentZ   = Container + TangentZ;
     if (Container.isLoading)
     {
         UV = new Vector2[4];
     }
     for (int i = 0; i < 4; i++)
     {
         UV[i].X = Container + UV[i].X;
         UV[i].Y = Container + UV[i].Y;
     }
     Color = Container + Color;
     Bone  = Container + Bone;
 }
Example #11
0
        private void SerializeRawTriangles(SerializingContainer Container)
        {
            int size  = 8;
            int count = 0;

            if (!Container.isLoading)
            {
                count = RawTriangles.Length;
            }
            size  = Container + size;
            count = Container + count;
            if (Container.isLoading)
            {
                RawTriangles = new Face[count];
            }
            for (int i = 0; i < RawTriangles.Length; i++)
            {
                RawTriangles[i].Serialize(Container);
            }
        }
Example #12
0
        public SkeletalMesh(PCCObject pcc, int Index)
        {
            Loaded  = true;
            MyIndex = Index;
            Owner   = pcc;
            Flags   = (int)(pcc.Exports[Index].ObjectFlags >> 32);
            int start = GetPropertyEnd();

            byte[] buff = new byte[pcc.Exports[Index].Data.Length - start];
            for (int i = 0; i < pcc.Exports[Index].Data.Length - start; i++)
            {
                buff[i] = pcc.Exports[Index].Data[i + start];
            }
            MemoryStream         m         = new MemoryStream(buff);
            SerializingContainer Container = new SerializingContainer(m);

            Container.isLoading = true;
            Serialize(Container);
            GenerateDXMeshes();
        }
Example #13
0
        public FaceFXAnimSet(PCCObject Pcc, int Index)
        {
            BitConverter.IsLittleEndian = true;
            pcc     = Pcc;
            MyIndex = Index;
            byte[] buff = pcc.Exports[Index].Data;
            List <PropertyReader.Property> props = PropertyReader.getPropList(pcc, pcc.Exports[Index]);
            int start = props[props.Count - 1].offend + 4;

            Memory = new byte[buff.Length - start];
            for (int i = 0; i < buff.Length - start; i++)
            {
                Memory[i] = buff[i + start];//Skip Props and size int
            }
            MemoryStream         m         = new MemoryStream(Memory);
            SerializingContainer Container = new SerializingContainer(m);

            Container.isLoading = true;
            Serialize(Container);
        }
Example #14
0
        public void Save()
        {
            BitConverter.IsLittleEndian = true;
            MemoryStream         m         = new MemoryStream();
            SerializingContainer Container = new SerializingContainer(m);

            Container.isLoading = false;
            Serialize(Container);
            m = Container.Memory;
            MemoryStream res = new MemoryStream();

            byte[] buff = pcc.Exports[MyIndex].Data;
            List <PropertyReader.Property> props = PropertyReader.getPropList(pcc, pcc.Exports[MyIndex]);
            int start = props[props.Count - 1].offend;

            res.Write(buff, 0, start);
            res.Write(BitConverter.GetBytes((int)m.Length), 0, 4);
            res.Write(m.ToArray(), 0, (int)m.Length);
            pcc.Exports[MyIndex].Data = res.ToArray();
        }
            public void Serialize(SerializingContainer Container, MEVersion version)
            {
                if (version == MEVersion.ME2)
                {
                    Position.X = Container + Position.X;
                    Position.Y = Container + Position.Y;
                    Position.Z = Container + Position.Z;
                }
                TangentX = Container + TangentX;
                TangentZ = Container + TangentZ;
                if (Container.isLoading)
                {
                    InfluenceBones   = new byte[4];
                    InfluenceWeights = new byte[4];
                }
                for (int i = 0; i < 4; i++)
                {
                    InfluenceBones[i] = Container + InfluenceBones[i];
                }
                for (int i = 0; i < 4; i++)
                {
                    InfluenceWeights[i] = Container + InfluenceWeights[i];
                }
                if (version == MEVersion.ME3)
                {
                    Position.X = Container + Position.X;
                    Position.Y = Container + Position.Y;
                    Position.Z = Container + Position.Z;
                }

                ushort sU = 0;
                ushort sV = 0;

                sU = Container + sU;
                sV = Container + sV;
                U  = HalfToFloat(sU);
                V  = HalfToFloat(sV);

                Normals  = UnpackNormal(TangentZ);
                Tangents = UnpackNormal(TangentX);
            }
Example #16
0
        private void MaterialIndexApplyButton_Click(object sender, EventArgs e)
        {
            TreeNode t = treeView1.SelectedNode;

            if (skm != null && t != null && t.Parent != null && t.Parent.Parent != null && t.Parent.Text == "Sections")
            {
                SkeletalMesh.SectionStruct section = skm.LODModels[t.Parent.Parent.Index].Sections[t.Index];
                section.MaterialIndex = (short)MaterialIndexBox.SelectedIndex;
                skm.LODModels[t.Parent.Parent.Index].Sections[t.Index] = section;

                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[skm.MyIndex].Data, 0, end);
                mem.Write(con.Memory.ToArray(), 0, (int)con.Memory.Length);
                Pcc.Exports[skm.MyIndex].Data = mem.ToArray();
            }
        }
Example #17
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            int idx;

            if (stm != null)
            {
                idx = stm.index;
            }
            else if (skm != null)
            {
                idx = skm.MyIndex;
            }
            else
            {
                return;
            }
            int      n = toolStripComboBox1.SelectedIndex;
            TreeNode t = treeView1.SelectedNode;

            if (n == -1 || pcc == null || t == null || t.Parent == null || t.Parent.Text != "Materials")
            {
                return;
            }
            if (pcc.Exports[idx].ClassName == "StaticMesh")
            {
                return;
            }
            skm.Materials[t.Index] = Materials[n] + 1;
            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[idx].Data, 0, end);
            mem.Write(con.Memory.ToArray(), 0, (int)con.Memory.Length);
            pcc.Exports[idx].Data = mem.ToArray();
        }
        private void SerializeMaterials(SerializingContainer Container)
        {
            int count = 0;

            if (!Container.isLoading)
            {
                count = Materials.Count();
            }
            count = Container + count;
            if (Container.isLoading)
            {
                Materials = new List <int>();
                for (int i = 0; i < count; i++)
                {
                    Materials.Add(0);
                }
            }
            for (int i = 0; i < count; i++)
            {
                Materials[i] = Container + Materials[i];
            }
        }
 public void Serialize(SerializingContainer Container)
 {
     TangentX = Container + TangentX;
     TangentZ = Container + TangentZ;
     if (Container.isLoading)
     {
         InfluenceBones   = new byte[4];
         InfluenceWeights = new byte[4];
     }
     for (int i = 0; i < 4; i++)
     {
         InfluenceBones[i] = Container + InfluenceBones[i];
     }
     for (int i = 0; i < 4; i++)
     {
         InfluenceWeights[i] = Container + InfluenceWeights[i];
     }
     Position.X = Container + Position.X;
     Position.Y = Container + Position.Y;
     Position.Z = Container + Position.Z;
     U          = Container + U;
     V          = Container + V;
 }
        private void SerializeBones(SerializingContainer Container)
        {
            int count = 0;

            if (!Container.isLoading)
            {
                count = Bones.Count();
            }
            count = Container + count;
            if (Container.isLoading)
            {
                Bones = new List <BoneStruct>();
                for (int i = 0; i < count; i++)
                {
                    Bones.Add(new BoneStruct());
                }
            }
            for (int i = 0; i < count; i++)
            {
                BoneStruct b = Bones[i];
                b.Name          = Container + b.Name;
                b.Flags         = Container + b.Flags;
                b.Unk1          = Container + b.Unk1;
                b.Orientation.X = Container + b.Orientation.X;
                b.Orientation.Y = Container + b.Orientation.Y;
                b.Orientation.Z = Container + b.Orientation.Z;
                b.Orientation.W = Container + b.Orientation.W;
                b.Position.X    = Container + b.Position.X;
                b.Position.Y    = Container + b.Position.Y;
                b.Position.Z    = Container + b.Position.Z;
                b.NumChildren   = Container + b.NumChildren;
                b.Parent        = Container + b.Parent;
                b.BoneColor     = Container + b.BoneColor;
                Bones[i]        = b;
            }
            SkeletonDepth = Container + SkeletonDepth;
        }
Example #21
0
        private void serializeToFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int n = listBox1.SelectedIndex;

            if (n == -1 | pcc == null)
            {
                return;
            }
            if (pcc.Exports[Objects[n].index].ClassName == "StaticMesh")
            {
                SaveFileDialog d = new SaveFileDialog();
                d.Filter   = "*.bin|*.bin";
                d.FileName = pcc.Exports[Objects[n].index].ObjectName + ".bin";
                if (d.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    stm.SerializeToFile(d.FileName);
                    MessageBox.Show("Done.");
                }
            }
            if (pcc.Exports[Objects[n].index].ClassName == "SkeletalMesh")
            {
                SaveFileDialog d = new SaveFileDialog();
                d.Filter   = "*.bin|*.bin";
                d.FileName = pcc.Exports[Objects[n].index].ObjectName + ".bin";
                if (d.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    SerializingContainer c = new SerializingContainer();
                    c.Memory    = new MemoryStream();
                    c.isLoading = false;
                    skm.Serialize(c);
                    FileStream fs = new FileStream(d.FileName, FileMode.Create, FileAccess.Write);
                    fs.Write(c.Memory.ToArray(), 0, (int)c.Memory.Length);
                    fs.Close();
                    MessageBox.Show("Done.");
                }
            }
        }
Example #22
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            int      n = MaterialBox.SelectedIndex;
            TreeNode t = treeView1.SelectedNode;

            if (n == -1 || Pcc == null || t == null || t.Parent == null)
            {
                return;
            }

            if (stm != null && t.Parent.Text == "Sections")
            {
                stm.SetSectionMaterial(CurrentLOD, t.Index, Materials[n] + 1);
                //SerializingCont
                MemoryStream ms = new MemoryStream();
                Pcc.Exports[stm.index].Data = stm.SerializeToBuffer();
                // Update treeview

                // Update preview
                preview.Dispose();
                preview = new ModelPreview(view.Device, stm, view.TextureCache);
            }
            else if (skm != null && t.Parent.Text == "Materials")
            {
                skm.Materials[t.Index] = Materials[n] + 1;
                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[skm.MyIndex].Data, 0, end);
                mem.Write(con.Memory.ToArray(), 0, (int)con.Memory.Length);
                Pcc.Exports[skm.MyIndex].Data = mem.ToArray();
            }
        }
        private void SerializeLODs(SerializingContainer Container)
        {
            int count = 0;

            if (!Container.isLoading)
            {
                count = LODModels.Count();
            }
            count = Container + count;
            // this is the actual number of lods but we only care about lod0 (and it prevents us from looking for other lods in ME1/ME2)
            // so we force count to 1.
            count = 1;
            if (Container.isLoading)
            {
                LODModels = new List <LODModelStruct>();
                for (int i = 0; i < count; i++)
                {
                    LODModels.Add(new LODModelStruct());
                }
            }
            for (int i = 0; i < count; i++)
            {
                LODModelStruct lod     = LODModels[i];
                MEVersion      version = MEVersion.ME1;
                if (Owner is ME2Package)
                {
                    version = MEVersion.ME2;
                }
                else if (Owner is ME3Package)
                {
                    version = MEVersion.ME3;
                }
                lod.Serialize(Container, version);
                LODModels[i] = lod;
            }
        }
Example #24
0
        private void SerializeLODs(SerializingContainer Container)
        {
            int count = 0;

            if (!Container.isLoading)
            {
                count = LODModels.Count();
            }
            count = Container + count;
            if (Container.isLoading)
            {
                LODModels = new List <LODModelStruct>();
                for (int i = 0; i < count; i++)
                {
                    LODModels.Add(new LODModelStruct());
                }
            }
            for (int i = 0; i < count; i++)
            {
                LODModelStruct lod = LODModels[i];
                lod.Serialize(Container);
                LODModels[i] = lod;
            }
        }
Example #25
0
            public List <uint> Indexes; // modded

            public void Serialize(SerializingContainer Container)
            {
                NeedsCPUAccess = Container + NeedsCPUAccess;
                DataTypeSize   = Container + DataTypeSize;
                IndexSize      = Container + IndexSize;
                IndexCount     = Container + IndexCount;
                if (Container.isLoading)
                {
                    Indexes = new List <uint>();
                    for (int i = 0; i < IndexCount; i++)
                    {
                        Indexes.Add(0);
                    }
                }
                if (IndexSize == 1)
                {
                    for (int i = 0; i < IndexCount; i++)
                    {
                        Indexes[i] = Container + (byte)Indexes[i];
                    }
                }
                else if (IndexSize == 2)
                {
                    for (int i = 0; i < IndexCount; i++)
                    {
                        Indexes[i] = Container + (ushort)Indexes[i];
                    }
                }
                else if (IndexSize == 4)
                {
                    for (int i = 0; i < IndexCount; i++)
                    {
                        Indexes[i] = Container + (uint)Indexes[i];
                    }
                }
            }
Example #26
0
 public void Serialize(SerializingContainer Container)
 {
     //basevertex
     BaseVertexIndex = Container + BaseVertexIndex;
     //rigid vertices
     int count = 0;
     if (!Container.isLoading)
         count = RiginSkinVertices.Count();
     count = Container + count;
     if (Container.isLoading)
     {
         RiginSkinVertices = new List<RigidSkinVertexStruct>();
         for (int i = 0; i < count; i++)
             RiginSkinVertices.Add(new RigidSkinVertexStruct());
     }
     for (int i = 0; i < count; i++)
     {
         RigidSkinVertexStruct v = RiginSkinVertices[i];
         v.Serialize(Container);
         RiginSkinVertices[i] = v;
     }
     //soft vertices
     if (!Container.isLoading)
         count = SoftSkinVertices.Count();
     count = Container + count;
     if (Container.isLoading)
     {
         SoftSkinVertices = new List<SoftSkinVertexStruct>();
         for (int i = 0; i < count; i++)
             SoftSkinVertices.Add(new SoftSkinVertexStruct());
     }
     for (int i = 0; i < count; i++)
     {
         SoftSkinVertexStruct v = SoftSkinVertices[i];
         v.Serialize(Container);
         SoftSkinVertices[i] = v;
     }
     //bonemap
     if (!Container.isLoading)
         count = BoneMap.Count();
     count = Container + count;
     if (Container.isLoading)
     {
         BoneMap = new List<ushort>();
         for (int i = 0; i < count; i++)
             BoneMap.Add(0);
     }
     for (int i = 0; i < count; i++)
         BoneMap[i] = Container + BoneMap[i];
     //rest
     NumRigidVertices = Container + NumRigidVertices;
     NumSoftVertices = Container + NumSoftVertices;
     MaxBoneInfluences = Container + MaxBoneInfluences;
 }
Example #27
0
 public void Serialize(SerializingContainer Container)
 {
     SerializeBoundings(Container);
     SerializeMaterials(Container);
     SerializeOrgRot(Container);
     SerializeBones(Container);
     SerializeLODs(Container);
 }
Example #28
0
        private void importLODToolStripMenuItem_Click(object sender, EventArgs e)
        {
            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;
            PCCObject pcc = new PCCObject();
            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)
                {
                    pcc = new PCCObject(ME3Directory.cookedPath + en.Filename);
                    if (en.isSkeletal)
                    {
                        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
                                    {
                                        pcc = new PCCObject(loc + "dlc.pcc");
                                        if (en.isSkeletal)
                                        {
                                            skm = new SkeletalMesh(pcc, en.Index);
                                            break;
                                        }
                                        else
                                        {
                                            return;
                                        }
                                    }
                                    catch (Exception)
                                    {
                                        return;
                                    }
                                }
                            }
                        }
                        catch (Exception)
                        {
                            return;
                        }
                }
            }
            else
                return;
            if (!skm.Loaded || !pcc.Loaded)
                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.altSaveToFile(pcc.pccFileName, true);
            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;
        }
Example #29
0
 public void Serialize(SerializingContainer con)
 {
     origin = con + origin;
     size = con + size;
     r = con + r;
 }
Example #30
0
 private void SerializeMaterials(SerializingContainer Container)
 {
     int count = 0;
     if (!Container.isLoading)
         count = Materials.Count();
     count = Container + count;
     if (Container.isLoading)
     {
         Materials = new List<int>();
         for (int i = 0; i < count; i++)
             Materials.Add(0);
     }
     for (int i = 0; i < count; i++)
         Materials[i] = Container + Materials[i];
 }
 void Serialize(SerializingContainer Container)
 {
     SerializeHeader(Container);
     SerializeData(Container);
 }
Example #32
0
 public void Serialize(SerializingContainer Container)
 {
     Name = Container + Name;
     Unk1 = Container + Unk1;
     Unk2 = Container + Unk2;
 }
Example #33
0
        void SerializeHeader(SerializingContainer Container)
        {
            if (Container.isLoading)
            {
                header = new ME3HeaderStruct();
            }
            header.Magic = Container + header.Magic;
            header.unk1  = Container + header.unk1;
            header.unk2  = Container + header.unk2;
            int count = 0;

            if (!Container.isLoading)
            {
                count = header.Licensee.Length;
            }
            else
            {
                header.Licensee = "";
            }
            header.Licensee = SerializeString(Container, header.Licensee);
            count           = 0;
            if (!Container.isLoading)
            {
                count = header.Project.Length;
            }
            else
            {
                header.Project = "";
            }
            header.Project = SerializeString(Container, header.Project);
            header.unk3    = Container + header.unk3;
            header.unk4    = Container + header.unk4;
            count          = 0;
            if (!Container.isLoading)
            {
                count = header.Nodes.Length;
            }
            count = Container + count;
            if (Container.isLoading)
            {
                header.Nodes = new HNodeStruct[count];
            }
            for (int i = 0; i < count; i++)
            {
                if (Container.isLoading)
                {
                    header.Nodes[i] = new HNodeStruct();
                }
                HNodeStruct t = header.Nodes[i];
                t.unk1          = Container + t.unk1;
                t.unk2          = Container + t.unk2;
                t.Name          = SerializeString(Container, t.Name);
                t.unk3          = Container + t.unk3;
                header.Nodes[i] = t;
            }
            count = 0;
            if (!Container.isLoading)
            {
                count = header.Names.Length;
            }
            count = Container + count;
            if (Container.isLoading)
            {
                header.Names = new string[count];
            }
            for (int i = 0; i < count; i++)
            {
                header.Names[i] = SerializeString(Container, header.Names[i]);
            }
        }
Example #34
0
 private void SerializeMinMax(SerializingContainer Container)
 {
     Min = Container + Min;
     Max = Container + Max;
 }
Example #35
0
        private void importLODToolStripMenuItem_Click(object sender, EventArgs e)
        {
            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;
            }
            PCCObject    pcc = new PCCObject();
            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)
                {
                    pcc = new PCCObject(ME3Directory.cookedPath + en.Filename);
                    if (en.isSkeletal)
                    {
                        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
                                    {
                                        pcc = new PCCObject(loc + "dlc.pcc");
                                        if (en.isSkeletal)
                                        {
                                            skm = new SkeletalMesh(pcc, en.Index);
                                            break;
                                        }
                                        else
                                        {
                                            return;
                                        }
                                    }
                                    catch (Exception)
                                    {
                                        return;
                                    }
                                }
                            }
                        }
                        catch (Exception)
                        {
                            return;
                        }
                    }
                }
            }
            else
            {
                return;
            }
            if (!skm.Loaded || !pcc.Loaded)
            {
                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.altSaveToFile(pcc.pccFileName, true);
            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;
        }
Example #36
0
        private void ImportMeshToolStripMenuItem_Click(object sender, System.EventArgs e)
        {
            if (MeshListBox.SelectedIndex == -1)
            {
                return;
            }

            SkeletalMesh newMesh = new SkeletalMesh();
            SkeletalMesh oldMesh = new SkeletalMesh(pcc, SelectedObject);

            UDKExplorer.UDK.Classes.SkeletalMesh sourceMesh = new UDKExplorer.UDK.Classes.SkeletalMesh(udk, Objects[MeshListBox.SelectedIndex]);

            // Fill out data in newMesh
            newMesh.MyIndex = SelectedObject;
            newMesh.Owner   = pcc;
            newMesh.Flags   = (int)(pcc.Exports[SelectedObject].ObjectFlags >> 32); // Keep the flags from the overwritten mesh

            // Bounding
            newMesh.Bounding = new SkeletalMesh.BoundingStruct(sourceMesh.Bounding);

            // Materials
            newMesh.Materials = new List <int>();
            foreach (int materialObjectIndex in sourceMesh.Materials)
            {
                newMesh.Materials.Add(0); // Don't bother copying IDs that will be invalid anyways.
            }
            // The materials are all entered as zero, nothing we can do now.

            /*for (int i = 0; i < newMesh.Materials.Count; i++)
             * {
             *  newMesh.MatInsts.Add(new MaterialInstanceConstant(pcc, newMesh.Materials[i] - 1));
             * }*/

            // OrgRot
            newMesh.Origin   = sourceMesh.Origin;
            newMesh.Rotation = sourceMesh.Rotation;

            // Bones
            newMesh.Bones = new List <SkeletalMesh.BoneStruct>();
            foreach (UDKExplorer.UDK.Classes.SkeletalMesh.BoneStruct bone in sourceMesh.Bones)
            {
                newMesh.Bones.Add(SkeletalMesh.BoneStruct.ImportFromUDK(bone, udk, pcc));
            }
            newMesh.SkeletonDepth = sourceMesh.SkeletonDepth;

            // LODs
            newMesh.LODModels = new List <SkeletalMesh.LODModelStruct>();
            foreach (UDKExplorer.UDK.Classes.SkeletalMesh.LODModelStruct lod in sourceMesh.LODModels)
            {
                SkeletalMesh.LODModelStruct newLOD = new SkeletalMesh.LODModelStruct();

                newLOD.Sections = new List <SkeletalMesh.SectionStruct>();
                foreach (UDKExplorer.UDK.Classes.SkeletalMesh.SectionStruct secudk in lod.Sections)
                {
                    SkeletalMesh.SectionStruct secpcc = new SkeletalMesh.SectionStruct();
                    secpcc.BaseIndex     = secudk.BaseIndex;
                    secpcc.ChunkIndex    = secudk.ChunkIndex;
                    secpcc.MaterialIndex = secudk.MaterialIndex;
                    secpcc.NumTriangles  = secudk.NumTriangles;
                    newLOD.Sections.Add(secpcc);
                }
                newLOD.IndexBuffer            = new SkeletalMesh.MultiSizeIndexContainerStruct();
                newLOD.IndexBuffer.IndexCount = lod.IndexBuffer.IndexCount;
                newLOD.IndexBuffer.IndexSize  = lod.IndexBuffer.IndexSize;
                newLOD.IndexBuffer.Indexes    = new List <ushort>();
                foreach (ushort Idx in lod.IndexBuffer.Indexes)
                {
                    newLOD.IndexBuffer.Indexes.Add(Idx);
                }
                // TODO: Unk1
                newLOD.Unk1 = 0;

                /* We don't need to change bone indexes, because the skeleton is coming along for the ride.
                 *
                 * List<int> BoneMap = new List<int>(); // Maps source bone i to existing bone index BoneMap[i]
                 * for (int i = 0; i < sourceMesh.Bones.Count; i++)
                 * {
                 *  string sourceName = udk.GetName(sourceMesh.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 == sourceName)
                 *      {
                 *          found = true;
                 *          BoneMap.Add(j);
                 *          if (MPOpt.SKM_importbones)
                 *          {
                 *              SkeletalMesh.BoneStruct bpcc = skm.Bones[j];
                 *              UDKExplorer.UDK.Classes.SkeletalMesh.BoneStruct budk = sourceMesh.Bones[i];
                 *              bpcc.Orientation = budk.Orientation;
                 *              bpcc.Position = budk.Position;
                 *              skm.Bones[j] = bpcc;
                 *          }
                 *      }
                 *  }
                 *  if (!found)
                 *  {
                 *      DebugOutput.PrintLn("ERROR: Cant Match Bone \"" + sourceName + "\"");
                 *      BoneMap.Add(0);
                 *  }
                 * }*/

                newLOD.ActiveBones = new List <ushort>();
                foreach (ushort Idx in lod.ActiveBones)
                {
                    newLOD.ActiveBones.Add(/*(ushort)BoneMap[Idx]*/ Idx);
                }
                // TODO: Unk2
                newLOD.Unk2   = 0;
                newLOD.Chunks = new List <SkeletalMesh.SkelMeshChunkStruct>();
                foreach (UDKExplorer.UDK.Classes.SkeletalMesh.SkelMeshChunkStruct chunkudk in lod.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]*/ Idx);
                    }
                    newLOD.Chunks.Add(chunkpcc);
                }
                newLOD.Size        = lod.Size;
                newLOD.NumVertices = lod.NumVertices;
                // TODO: Unk3
                newLOD.Unk3          = 0;
                newLOD.RequiredBones = new List <byte>();
                foreach (byte b in lod.RequiredBones)
                {
                    newLOD.RequiredBones.Add(b);
                }
                newLOD.RawPointIndicesFlag   = lod.RawPointIndicesFlag;
                newLOD.RawPointIndicesCount  = lod.RawPointIndicesCount;
                newLOD.RawPointIndicesSize   = lod.RawPointIndicesSize;
                newLOD.RawPointIndicesOffset = lod.RawPointIndicesOffset;
                newLOD.RawPointIndices       = new List <int>();
                foreach (int i in lod.RawPointIndices)
                {
                    newLOD.RawPointIndices.Add(i);
                }
                newLOD.NumTexCoords        = lod.NumTexCoords;
                newLOD.VertexBufferGPUSkin = new SkeletalMesh.VertexBufferGPUSkinStruct();
                newLOD.VertexBufferGPUSkin.NumTexCoords = lod.VertexBufferGPUSkin.NumTexCoords;
                newLOD.VertexBufferGPUSkin.Extension    = lod.VertexBufferGPUSkin.Extension;
                newLOD.VertexBufferGPUSkin.Origin       = lod.VertexBufferGPUSkin.Origin;
                newLOD.VertexBufferGPUSkin.VertexSize   = lod.VertexBufferGPUSkin.VertexSize;
                newLOD.VertexBufferGPUSkin.Vertices     = new List <SkeletalMesh.GPUSkinVertexStruct>();
                foreach (UDKExplorer.UDK.Classes.SkeletalMesh.GPUSkinVertexStruct vudk in lod.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;
                    newLOD.VertexBufferGPUSkin.Vertices.Add(vpcc);
                }
                // TODO: Unk4
                newLOD.Unk4 = 0;
                //skm.LODModels[SelectedLOD] = newLOD;
                newMesh.LODModels.Add(newLOD);
            }

            // Tail
            newMesh.TailNames = new List <SkeletalMesh.TailNamesStruct>();
            for (int i = 0; i < newMesh.Bones.Count; i++)
            {
                newMesh.TailNames.Add(new SkeletalMesh.TailNamesStruct(newMesh.Bones[i].Name, i));
            }
            newMesh.Unk1 = oldMesh.Unk1;
            newMesh.Unk2 = oldMesh.Unk2;
            newMesh.Unk3 = new List <int>();
            foreach (int i in oldMesh.Unk3)
            {
                newMesh.Unk3.Add(i);
            }

            // Write mesh data to temporary buffer
            SerializingContainer serializer = new SerializingContainer();

            serializer.Memory    = new MemoryStream();
            serializer.isLoading = false;
            newMesh.Serialize(serializer);

            // Copy in the properties from the old mesh
            int          propertyEnd = newMesh.GetPropertyEnd();
            MemoryStream finalData   = new MemoryStream();

            finalData.Write(pcc.Exports[SelectedObject].Data, 0, propertyEnd);

            // Copy in the data from the new mesh
            finalData.Write(serializer.Memory.ToArray(), 0, (int)serializer.Memory.Length);

            // Upload final data
            pcc.Exports[SelectedObject].Data = finalData.ToArray();
            MessageBox.Show("Mesh replaced.");
            Close();
        }
Example #37
0
 private void SerializeBones(SerializingContainer Container)
 {
     int count = 0;
     if (!Container.isLoading)
         count = Bones.Count();
     count = Container + count;
     if (Container.isLoading)
     {
         Bones = new List<BoneStruct>();
         for (int i = 0; i < count; i++)
             Bones.Add(new BoneStruct());
     }
     for (int i = 0; i < count; i++)
     {
         BoneStruct b = Bones[i];
         b.Name = Container + b.Name;
         b.Flags = Container + b.Flags;
         b.Unk1 = Container + b.Unk1;
         b.Orientation.X = Container + b.Orientation.X;
         b.Orientation.Y = Container + b.Orientation.Y;
         b.Orientation.Z = Container + b.Orientation.Z;
         b.Orientation.W = Container + b.Orientation.W;
         b.Position.X = Container + b.Position.X;
         b.Position.Y = Container + b.Position.Y;
         b.Position.Z = Container + b.Position.Z;
         b.NumChildren = Container + b.NumChildren;
         b.Parent = Container + b.Parent;
         b.BoneColor = Container + b.BoneColor;
         Bones[i] = b;
     }
     SkeletonDepth = Container + SkeletonDepth;
 }
Example #38
0
 private void SerializeOrgRot(SerializingContainer Container)
 {
     Origin.X = Container + Origin.X;
     Origin.Y = Container + Origin.Y;
     Origin.Z = Container + Origin.Z;
     Rotation.X = Container + Rotation.X;
     Rotation.Y = Container + Rotation.Y;
     Rotation.Z = Container + Rotation.Z;
     
 }
Example #39
0
        void SerializeData(SerializingContainer Container)
        {
            if (Container.isLoading)
            {
                data = new ME3DataAnimSetStruct();
            }
            data.unk1 = Container + data.unk1;
            data.unk2 = Container + data.unk2;
            data.unk3 = Container + data.unk3;
            data.unk4 = Container + data.unk4;
            int count = 0;

            if (!Container.isLoading)
            {
                count = data.Data.Length;
            }
            count = Container + count;
            if (Container.isLoading)
            {
                data.Data = new ME3FaceFXLine[count];
            }
            for (int i = 0; i < count; i++)
            {
                if (Container.isLoading)
                {
                    data.Data[i] = new ME3FaceFXLine();
                }
                ME3FaceFXLine d = data.Data[i];
                d.Name = Container + d.Name;
                if (Container.isLoading)
                {
                    d.NameAsString = header.Names[d.Name];
                }
                int count2 = 0;
                if (!Container.isLoading)
                {
                    count2 = d.animations.Length;
                }
                count2 = Container + count2;
                if (Container.isLoading)
                {
                    d.animations = new ME3NameRef[count2];
                }
                for (int j = 0; j < count2; j++)
                {
                    if (Container.isLoading)
                    {
                        d.animations[j] = new ME3NameRef();
                    }
                    ME3NameRef u = d.animations[j];
                    u.index         = Container + u.index;
                    u.unk2          = Container + u.unk2;
                    d.animations[j] = u;
                }
                count2 = 0;
                if (!Container.isLoading)
                {
                    count2 = d.points.Length;
                }
                count2 = Container + count2;
                if (Container.isLoading)
                {
                    d.points = new ControlPoint[count2];
                }
                for (int j = 0; j < count2; j++)
                {
                    if (Container.isLoading)
                    {
                        d.points[j] = new ControlPoint();
                    }
                    ControlPoint u = d.points[j];
                    u.time         = Container + u.time;
                    u.weight       = Container + u.weight;
                    u.inTangent    = Container + u.inTangent;
                    u.leaveTangent = Container + u.leaveTangent;
                    d.points[j]    = u;
                }
                if (d.animations.Length > 0)
                {
                    count2 = 0;
                    if (!Container.isLoading)
                    {
                        count2 = d.numKeys.Length;
                    }
                    count2 = Container + count2;
                    if (Container.isLoading)
                    {
                        d.numKeys = new int[count2];
                    }
                    for (int j = 0; j < count2; j++)
                    {
                        d.numKeys[j] = Container + d.numKeys[j];
                    }
                }
                else if (Container.isLoading)
                {
                    d.numKeys = new int[0];
                }
                d.FadeInTime  = Container + d.FadeInTime;
                d.FadeOutTime = Container + d.FadeOutTime;
                d.unk2        = Container + d.unk2;
                d.path        = SerializeString(Container, d.path);
                d.ID          = SerializeString(Container, d.ID);
                d.index       = Container + d.index;
                data.Data[i]  = d;
            }
        }
 string SerializeString(SerializingContainer Container, string s)
 {
     int len = 0;
     byte t = 0;
     if (Container.isLoading)
     {
         s = "";
         len = Container + len;
         for (int i = 0; i < len; i++)
             s += (char)(Container + (byte)0);
     }
     else
     {
         len = s.Length;
         len = Container + len;
         foreach (char c in s)
             t = Container + (byte)c;
     }
     return s;
 }
Example #41
0
 void Serialize(SerializingContainer Container)
 {
     SerializeHeader(Container);
     SerializeData(Container);
 }
 public void Save()
 {
     
     MemoryStream m = new MemoryStream();
     SerializingContainer Container = new SerializingContainer(m);
     Container.isLoading = false;
     Serialize(Container);
     m = Container.Memory;
     MemoryStream res = new MemoryStream();
     List<PropertyReader.Property> props = PropertyReader.getPropList(export);
     int start = props[props.Count - 1].offend;
     res.Write(export.Data, 0, start);
     res.WriteValueS32((int)m.Length);
     res.WriteStream(m);
     export.Data = res.ToArray();
 }
 void SerializeData(SerializingContainer Container)
 {
     if (Container.isLoading)
         data = new ME3DataAnimSetStruct();
     data.unk1 = Container + data.unk1;
     data.unk2 = Container + data.unk2;
     data.unk3 = Container + data.unk3;
     data.unk4 = Container + data.unk4;
     int count = 0;
     if (!Container.isLoading)
         count = data.Data.Length;
     count = Container + count;
     if (Container.isLoading)
         data.Data = new ME3FaceFXLine[count];
     for (int i = 0; i < count; i++)
     {
         if (Container.isLoading)
             data.Data[i] = new ME3FaceFXLine();
         ME3FaceFXLine d = data.Data[i];
         d.Name = Container + d.Name;
         if (Container.isLoading)
         {
             d.NameAsString = header.Names[d.Name];
         }
         int count2 = 0;
         if (!Container.isLoading)
             count2 = d.animations.Length;
         count2 = Container + count2;
         if (Container.isLoading)
             d.animations = new ME3NameRef[count2];
         for (int j = 0; j < count2; j++)
         {
             if (Container.isLoading)
                 d.animations[j] = new ME3NameRef();
             ME3NameRef u = d.animations[j];
             u.index = Container + u.index;
             u.unk2 = Container + u.unk2;
             d.animations[j] = u;
         }
         count2 = 0;
         if (!Container.isLoading)
             count2 = d.points.Length;
         count2 = Container + count2;
         if (Container.isLoading)
             d.points = new ControlPoint[count2];
         for (int j = 0; j < count2; j++)
         {
             if (Container.isLoading)
                 d.points[j] = new ControlPoint();
             ControlPoint u = d.points[j];
             u.time = Container + u.time;
             u.weight = Container + u.weight;
             u.inTangent = Container + u.inTangent;
             u.leaveTangent = Container + u.leaveTangent;
             d.points[j] = u;
         }
         if (d.animations.Length > 0)
         {
             count2 = 0;
             if (!Container.isLoading)
                 count2 = d.numKeys.Length;
             count2 = Container + count2;
             if (Container.isLoading)
                 d.numKeys = new int[count2];
             for (int j = 0; j < count2; j++)
                 d.numKeys[j] = Container + d.numKeys[j]; 
         }
         else if (Container.isLoading)
         {
             d.numKeys = new int[0];
         }
         d.FadeInTime = Container + d.FadeInTime;
         d.FadeOutTime = Container + d.FadeOutTime;
         d.unk2 = Container + d.unk2;
         d.path = SerializeString(Container, d.path);
         d.ID = SerializeString(Container, d.ID);
         d.index = Container + d.index;
         data.Data[i] = d;
     }
 }
Example #44
0
 private void SerializeBoundings(SerializingContainer Container)
 {
     Bounding.origin.X = Container + Bounding.origin.X;
     Bounding.origin.Y = Container + Bounding.origin.Y;
     Bounding.origin.Z = Container + Bounding.origin.Z;
     Bounding.size.X = Container + Bounding.size.X;
     Bounding.size.Y = Container + Bounding.size.Y;
     Bounding.size.Z = Container + Bounding.size.Z;
     Bounding.r = Container + Bounding.r;
 }
 public void DumpToFile(string path)
 {
     
     MemoryStream m = new MemoryStream();
     SerializingContainer Container = new SerializingContainer(m);
     Container.isLoading = false;
     Serialize(Container);
     m = Container.Memory;
     File.WriteAllBytes(path, m.ToArray());
 }
Example #46
0
 public void Serialize(SerializingContainer con)
 {
     origin = con + origin;
     size   = con + size;
     r      = con + r;
 }
        void SerializeData(SerializingContainer Container)
        {
            if (Container.isLoading)
            {
                data = new ME2DataAnimSetStruct();
            }
            data.unk1 = Container + data.unk1;
            data.unk2 = Container + data.unk2;
            data.unk3 = Container + data.unk3;
            data.unk4 = Container + data.unk4;
            data.unk5 = Container + data.unk5;
            data.unk6 = Container + data.unk6;
            data.unk7 = Container + data.unk7;
            data.unk8 = Container + data.unk8;
            data.unk9 = Container + data.unk9;
            int count = 0;

            if (!Container.isLoading)
            {
                count = data.Data.Length;
            }
            count = Container + count;
            if (Container.isLoading)
            {
                data.Data = new ME2FaceFXLine[count];
            }
            for (int i = 0; i < count; i++)
            {
                if (Container.isLoading)
                {
                    data.Data[i] = new ME2FaceFXLine();
                }
                ME2FaceFXLine d = (ME2FaceFXLine)data.Data[i];
                d.unk0 = Container + d.unk0;
                d.unk1 = Container + d.unk1;
                d.Name = Container + d.Name;
                if (Container.isLoading)
                {
                    d.NameAsString = header.Names[d.Name];
                }
                d.unk6 = Container + d.unk6;
                int animationCount = 0;
                if (!Container.isLoading)
                {
                    animationCount = d.animations.Length;
                }
                animationCount = Container + animationCount;
                if (Container.isLoading)
                {
                    d.animations = new ME2NameRef[animationCount];
                }
                for (int j = 0; j < animationCount; j++)
                {
                    if (Container.isLoading)
                    {
                        d.animations[j] = new ME2NameRef();
                    }
                    ME2NameRef u = d.animations[j] as ME2NameRef;
                    u.unk0          = Container + u.unk0;
                    u.unk1          = Container + u.unk1;
                    u.index         = Container + u.index;
                    u.unk2          = Container + u.unk2;
                    u.unk3          = Container + u.unk3;
                    d.animations[j] = u;
                }
                int pointCount = 0;
                if (!Container.isLoading)
                {
                    pointCount = d.points.Length;
                }
                pointCount = Container + pointCount;
                if (Container.isLoading)
                {
                    d.points = new ControlPoint[pointCount];
                }
                for (int j = 0; j < pointCount; j++)
                {
                    if (Container.isLoading)
                    {
                        d.points[j] = new ControlPoint();
                    }
                    ControlPoint u = d.points[j];
                    u.time         = Container + u.time;
                    u.weight       = Container + u.weight;
                    u.inTangent    = Container + u.inTangent;
                    u.leaveTangent = Container + u.leaveTangent;
                    d.points[j]    = u;
                }

                if (pointCount > 0)
                {
                    d.unk4 = Container + d.unk4;
                    int numKeysCount = 0;
                    if (!Container.isLoading)
                    {
                        numKeysCount = d.numKeys.Length;
                    }
                    numKeysCount = Container + numKeysCount;
                    if (Container.isLoading)
                    {
                        d.numKeys = new int[numKeysCount];
                    }
                    for (int j = 0; j < numKeysCount; j++)
                    {
                        d.numKeys[j] = Container + d.numKeys[j];
                    }
                }
                else if (Container.isLoading)
                {
                    d.numKeys = new int[d.animations.Length];
                }
                d.FadeInTime  = Container + d.FadeInTime;
                d.FadeOutTime = Container + d.FadeOutTime;
                d.unk2        = Container + d.unk2;
                d.unk5        = Container + d.unk5;
                d.path        = SerializeString(Container, d.path);
                d.ID          = SerializeString(Container, d.ID);
                d.index       = Container + d.index;
                data.Data[i]  = d;
            }
        }
            public void Serialize(SerializingContainer Container)
            {
                //basevertex
                BaseVertexIndex = Container + BaseVertexIndex;
                //rigid vertices
                int count = 0;

                if (!Container.isLoading)
                {
                    count = RiginSkinVertices.Count();
                }
                count = Container + count;
                if (Container.isLoading)
                {
                    RiginSkinVertices = new List <RigidSkinVertexStruct>();
                    for (int i = 0; i < count; i++)
                    {
                        RiginSkinVertices.Add(new RigidSkinVertexStruct());
                    }
                }
                for (int i = 0; i < count; i++)
                {
                    RigidSkinVertexStruct v = RiginSkinVertices[i];
                    v.Serialize(Container);
                    RiginSkinVertices[i] = v;
                }
                //soft vertices
                if (!Container.isLoading)
                {
                    count = SoftSkinVertices.Count();
                }
                count = Container + count;
                if (Container.isLoading)
                {
                    SoftSkinVertices = new List <SoftSkinVertexStruct>();
                    for (int i = 0; i < count; i++)
                    {
                        SoftSkinVertices.Add(new SoftSkinVertexStruct());
                    }
                }
                for (int i = 0; i < count; i++)
                {
                    SoftSkinVertexStruct v = SoftSkinVertices[i];
                    v.Serialize(Container);
                    SoftSkinVertices[i] = v;
                }
                //bonemap
                if (!Container.isLoading)
                {
                    count = BoneMap.Count();
                }
                count = Container + count;
                if (Container.isLoading)
                {
                    BoneMap = new List <ushort>();
                    for (int i = 0; i < count; i++)
                    {
                        BoneMap.Add(0);
                    }
                }
                for (int i = 0; i < count; i++)
                {
                    BoneMap[i] = Container + BoneMap[i];
                }
                //rest
                NumRigidVertices  = Container + NumRigidVertices;
                NumSoftVertices   = Container + NumSoftVertices;
                MaxBoneInfluences = Container + MaxBoneInfluences;
            }
Example #49
0
 public void Serialize(SerializingContainer Container)
 {
     SerializeHeader(Container);
     SerializeData(Container);
     ReadEnd = Container.GetPos();
 }
Example #50
0
 private void SerializeMinMax(SerializingContainer Container)
 {
     Min = Container + Min;
     Max = Container + Max;
 }
Example #51
0
 private void SerializeRawTriangles(SerializingContainer Container)
 {
     int size = 8;
     int count = 0;
     if (!Container.isLoading)
         count = RawTriangles.Length;
     size = Container + size;
     count = Container + count;
     if (Container.isLoading)
         RawTriangles = new Face[count];
     for (int i = 0; i < RawTriangles.Length; i++)
         RawTriangles[i].Serialize(Container);
 }
Example #52
0
 public void Serialize(SerializingContainer Container)
 {
     Position.X = Container + Position.X;
     Position.Y = Container + Position.Y;
     Position.Z = Container + Position.Z;
     TangentX = Container + TangentX;
     TangentY = Container + TangentY;
     TangentZ = Container + TangentZ;
     if (Container.isLoading)
     {
         UV = new Vector2[4];
         InfluenceBones = new byte[4];
         InfluenceWeights = new byte[4];
     }
     for (int i = 0; i < 4; i++)
     {
         UV[i].X = Container + UV[i].X;
         UV[i].Y = Container + UV[i].Y;
     }
     Color = Container + Color;
     for (int i = 0; i < 4; i++)
         InfluenceBones[i] = Container + InfluenceBones[i];
     for (int i = 0; i < 4; i++)
         InfluenceWeights[i] = Container + InfluenceWeights[i];
 }
Example #53
0
        public void SerializeData(SerializingContainer Container)
        {
            if (Container.isLoading)
            {
                Data = new DataAnimSetStruct();
            }
            Data.unk1 = Container + Data.unk1;
            Data.unk2 = Container + Data.unk2;
            Data.unk3 = Container + Data.unk3;
            Data.unk4 = Container + Data.unk4;
            int count = 0;

            if (!Container.isLoading)
            {
                count = Data.Data.Length;
            }
            count = Container + count;
            if (Container.isLoading)
            {
                Data.Data = new DataAnimSetDataStruct[count];
            }
            for (int i = 0; i < count; i++)
            {
                if (Container.isLoading)
                {
                    Data.Data[i] = new DataAnimSetDataStruct();
                }
                DataAnimSetDataStruct d = Data.Data[i];
                d.unk1 = Container + d.unk1;
                int count2 = 0;
                if (!Container.isLoading)
                {
                    count2 = d.unklist1.Length;
                }
                count2 = Container + count2;
                if (Container.isLoading)
                {
                    d.unklist1 = new UnkStruct1[count2];
                }
                for (int j = 0; j < count2; j++)
                {
                    if (Container.isLoading)
                    {
                        d.unklist1[j] = new UnkStruct1();
                    }
                    UnkStruct1 u = d.unklist1[j];
                    u.unk1        = Container + u.unk1;
                    u.unk2        = Container + u.unk2;
                    d.unklist1[j] = u;
                }
                count2 = 0;
                if (!Container.isLoading)
                {
                    count2 = d.unklist2.Length;
                }
                count2 = Container + count2;
                if (Container.isLoading)
                {
                    d.unklist2 = new UnkStruct2[count2];
                }
                for (int j = 0; j < count2; j++)
                {
                    if (Container.isLoading)
                    {
                        d.unklist2[j] = new UnkStruct2();
                    }
                    UnkStruct2 u = d.unklist2[j];
                    u.unk1        = Container + u.unk1;
                    u.unk2        = Container + u.unk2;
                    u.unk3        = Container + u.unk3;
                    u.unk4        = Container + u.unk4;
                    d.unklist2[j] = u;
                }
                count2 = 0;
                if (!Container.isLoading)
                {
                    count2 = d.unklist3.Length;
                }
                count2 = Container + count2;
                if (Container.isLoading)
                {
                    d.unklist3 = new int[count2];
                }
                for (int j = 0; j < count2; j++)
                {
                    d.unklist3[j] = Container + d.unklist3[j];
                }
                d.FadeInTime  = Container + d.FadeInTime;
                d.FadeOutTime = Container + d.FadeOutTime;
                d.unk2        = Container + d.unk2;
                d.Path        = SerializeString(Container, d.Path);
                d.ID          = SerializeString(Container, d.ID);
                d.unk3        = Container + d.unk3;
                Data.Data[i]  = d;
            }
        }
Example #54
0
 public void Serialize(SerializingContainer Container)
 {
     //NumTexCoords
     NumTexCoords = Container + NumTexCoords;
     //UseFullPrecisionUVs
     UseFullPrecisionUVs = Container + UseFullPrecisionUVs;
     //UsePackedPosition
     UsePackedPosition = Container + UsePackedPosition;
     //Extension
     Extension.X = Container + Extension.X;
     Extension.Y = Container + Extension.Y;
     Extension.Z = Container + Extension.Z;
     //origin
     Origin.X = Container + Origin.X;
     Origin.Y = Container + Origin.Y;
     Origin.Z = Container + Origin.Z;
     //vertexsize
     VertexSize = Container + VertexSize;
     int count = 0;
     if (!Container.isLoading)
         count = Vertices.Count();
     count = Container + count;
     if (Container.isLoading)
     {
         Vertices = new List<GPUSkinVertexStruct>();
         for (int i = 0; i < count; i++)
             Vertices.Add(new GPUSkinVertexStruct());
     }
     int VertexDiff = VertexSize - 32;
     for (int i = 0; i < count; i++)
     {
         GPUSkinVertexStruct v = Vertices[i];
         v.Serialize(Container);
         
         if(VertexDiff > 0)
         {
             byte b = 0;
             for (int j = 0; j < VertexDiff; j++)
                 b = Container + b;
         }
         Vertices[i] = v;
     }
 }
Example #55
0
 public void Serialize(SerializingContainer Container)
 {
     TangentX = Container + TangentX;
     TangentZ = Container + TangentZ;
     if (Container.isLoading)
     {
         InfluenceBones = new byte[4];
         InfluenceWeights = new byte[4];
     }
     for (int i = 0; i < 4; i++)
         InfluenceBones[i] = Container + InfluenceBones[i];
     for (int i = 0; i < 4; i++)
         InfluenceWeights[i] = Container + InfluenceWeights[i];
     Position.X = Container + Position.X;
     Position.Y = Container + Position.Y;
     Position.Z = Container + Position.Z;
     U = Container + U;
     V = Container + V;
 }
Example #56
0
 public void Serialize(SerializingContainer Container)
 {
     //Sections
     int count = 0;
     if (!Container.isLoading)
         count = Sections.Count();
     count = Container + count;
     if (Container.isLoading)
     {
         Sections = new List<SectionStruct>();
         for (int i = 0; i < count; i++)
             Sections.Add(new SectionStruct());
     }
     for (int i = 0; i < count; i++)
     {
         SectionStruct sec = Sections[i];
         sec.Serialize(Container);
         Sections[i] = sec;
     }
     //IndexBuffer
     if (Container.isLoading)
         IndexBuffer = new MultiSizeIndexContainerStruct();
     IndexBuffer.Serialize(Container);
     //Active Bones
     if (!Container.isLoading)
         count = ActiveBones.Count();
     count = Container + count;
     if (Container.isLoading)
     {
         ActiveBones = new List<ushort>();
         for (int i = 0; i < count; i++)
             ActiveBones.Add(0);
     }
     for (int i = 0; i < count; i++)
         ActiveBones[i] = Container + ActiveBones[i];
     //Chunks
     if (!Container.isLoading)
         count = Chunks.Count();
     count = Container + count;
     if (Container.isLoading)
     {
         Chunks = new List<SkelMeshChunkStruct>();
         for (int i = 0; i < count; i++)
             Chunks.Add(new SkelMeshChunkStruct());
     }
     for (int i = 0; i < count; i++)
     {
         SkelMeshChunkStruct c = Chunks[i];
         c.Serialize(Container);
         Chunks[i] = c;
     }
     //Size
     Size = Container + Size;
     //NumVertices
     NumVertices = Container + NumVertices;
     //RequiredBones
     if (!Container.isLoading)
         count = RequiredBones.Count();
     count = Container + count;
     if (Container.isLoading)
     {
         RequiredBones = new List<byte>();
         for (int i = 0; i < count; i++)
             RequiredBones.Add(0);
     }
     for (int i = 0; i < count; i++)
         RequiredBones[i] = Container + RequiredBones[i];
     //RawPointIndicesFlag
     RawPointIndicesFlag = Container + RawPointIndicesFlag;
     //RawPointIndicesCount
     RawPointIndicesCount = Container + RawPointIndicesCount;
     //RawPointIndicesSize
     RawPointIndicesSize = Container + RawPointIndicesSize;
     //RawPointIndicesOffset
     RawPointIndicesOffset = Container + RawPointIndicesOffset;
     //RawPointIndices
     if (Container.isLoading)
     {
         RawPointIndices = new List<int>();
         for (int i = 0; i < RawPointIndicesCount; i++)
             RawPointIndices.Add(0);
     }
     for (int i = 0; i < RawPointIndicesCount; i++)
         RawPointIndices[i] = Container + RawPointIndices[i];
     //NumTexCoords
     NumTexCoords = Container + NumTexCoords;
     //VertexBufferGPUSkin
     if (Container.isLoading)
         VertexBufferGPUSkin = new VertexBufferGPUSkinStruct();
     VertexBufferGPUSkin.Serialize(Container);
     //unknown stuff
     Unk1 = Container + Unk1;
     Unk2 = Container + Unk2;
     Unk3 = Container + Unk3;
     //GPU index buffer
     IndexSize = Container + IndexSize;
     if (!Container.isLoading)
         count = IndexBufferGPUSkin.Count();
     count = Container + count;
     if (Container.isLoading)
     {
         IndexBufferGPUSkin = new List<ushort>();
         for (int i = 0; i < count; i++)
             IndexBufferGPUSkin.Add(0);
     }
     for (int i = 0; i < count; i++)
         IndexBufferGPUSkin[i] = Container + IndexBufferGPUSkin[i];
 }
Example #57
0
 private void SerializekDOPTree(SerializingContainer Container)
 {
     int size = 0;
     int count = 0;
     if (!Container.isLoading)
     {
         size = kDOPTree[0].Length;
         count = kDOPTree.Count;
     }
     size = Container + size;
     count = Container + count;
     if (Container.isLoading)
         kDOPTree = new List<byte[]>();
     for (int i = 0; i < count; i++)
     {
         if (Container.isLoading)
             kDOPTree.Add(new byte[size]);
         for (int j = 0; j < size; j++)
         {
             byte[] temp = kDOPTree[i];
             temp[j] = Container + temp[j];
             kDOPTree[i] = temp;
         }
     }
 }
            public void Serialize(SerializingContainer Container)
            {
                //Sections
                int count = 0;

                if (!Container.isLoading)
                {
                    count = Sections.Count();
                }
                count = Container + count;
                if (Container.isLoading)
                {
                    Sections = new List <SectionStruct>();
                    for (int i = 0; i < count; i++)
                    {
                        Sections.Add(new SectionStruct());
                    }
                }
                for (int i = 0; i < count; i++)
                {
                    SectionStruct sec = Sections[i];
                    sec.Serialize(Container);
                    Sections[i] = sec;
                }
                //IndexBuffer
                if (Container.isLoading)
                {
                    IndexBuffer = new MultiSizeIndexContainerStruct();
                }
                IndexBuffer.Serialize(Container);
                //Active Bones
                if (!Container.isLoading)
                {
                    count = ActiveBones.Count();
                }
                count = Container + count;
                if (Container.isLoading)
                {
                    ActiveBones = new List <ushort>();
                    for (int i = 0; i < count; i++)
                    {
                        ActiveBones.Add(0);
                    }
                }
                for (int i = 0; i < count; i++)
                {
                    ActiveBones[i] = Container + ActiveBones[i];
                }
                //Chunks
                if (!Container.isLoading)
                {
                    count = Chunks.Count();
                }
                count = Container + count;
                if (Container.isLoading)
                {
                    Chunks = new List <SkelMeshChunkStruct>();
                    for (int i = 0; i < count; i++)
                    {
                        Chunks.Add(new SkelMeshChunkStruct());
                    }
                }
                for (int i = 0; i < count; i++)
                {
                    SkelMeshChunkStruct c = Chunks[i];
                    c.Serialize(Container);
                    Chunks[i] = c;
                }
                //Size
                Size = Container + Size;
                //NumVertices
                NumVertices = Container + NumVertices;
                //RequiredBones
                if (!Container.isLoading)
                {
                    count = RequiredBones.Count();
                }
                count = Container + count;
                if (Container.isLoading)
                {
                    RequiredBones = new List <byte>();
                    for (int i = 0; i < count; i++)
                    {
                        RequiredBones.Add(0);
                    }
                }
                for (int i = 0; i < count; i++)
                {
                    RequiredBones[i] = Container + RequiredBones[i];
                }
                //RawPointIndicesFlag
                RawPointIndicesFlag = Container + RawPointIndicesFlag;
                //RawPointIndicesCount
                RawPointIndicesCount = Container + RawPointIndicesCount;
                //RawPointIndicesSize
                RawPointIndicesSize = Container + RawPointIndicesSize;
                //RawPointIndicesOffset
                RawPointIndicesOffset = Container + RawPointIndicesOffset;
                //RawPointIndices
                if (Container.isLoading)
                {
                    RawPointIndices = new List <int>();
                    for (int i = 0; i < RawPointIndicesCount; i++)
                    {
                        RawPointIndices.Add(0);
                    }
                }
                for (int i = 0; i < RawPointIndicesCount; i++)
                {
                    RawPointIndices[i] = Container + RawPointIndices[i];
                }
                //NumTexCoords
                NumTexCoords = Container + NumTexCoords;
                //VertexBufferGPUSkin
                if (Container.isLoading)
                {
                    VertexBufferGPUSkin = new VertexBufferGPUSkinStruct();
                }
                VertexBufferGPUSkin.Serialize(Container);
                //unknown stuff
                Unk1 = Container + Unk1;
                Unk2 = Container + Unk2;
                Unk3 = Container + Unk3;
                //GPU index buffer
                IndexSize = Container + IndexSize;
                if (!Container.isLoading)
                {
                    count = IndexBufferGPUSkin.Count();
                }
                count = Container + count;
                if (Container.isLoading)
                {
                    IndexBufferGPUSkin = new List <ushort>();
                    for (int i = 0; i < count; i++)
                    {
                        IndexBufferGPUSkin.Add(0);
                    }
                }
                for (int i = 0; i < count; i++)
                {
                    IndexBufferGPUSkin[i] = Container + IndexBufferGPUSkin[i];
                }
            }
Example #59
0
        private void importLODToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int n = MeshListBox.SelectedIndex;

            if (n == -1)
            {
                return;
            }
            int m = LODListBox.SelectedIndex;

            if (m == -1)
            {
                return;
            }
            SkeletalMesh skm = new SkeletalMesh(pcc, SelectedObject);

            SkeletalMesh.LODModelStruct          lodpcc = skm.LODModels[SelectedLOD];
            UDKExplorer.UDK.Classes.SkeletalMesh skmudk = new UDKExplorer.UDK.Classes.SkeletalMesh(udk, Objects[n]);
            if (skm.Bones.Count != skmudk.Bones.Count)
            {
                if (MessageBox.Show("Your imported mesh has a different count of Bones! This would crash your game, proceed?", "UDK Skeleton Import", MessageBoxButtons.YesNo) == DialogResult.No)
                {
                    return;
                }
            }
            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 (MPOpt.SKM_importbones)
                        {
                            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);
            }
            skm.LODModels[SelectedLOD] = 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[SelectedObject].Data, 0, end);
            mem.Write(con.Memory.ToArray(), 0, (int)con.Memory.Length);
            pcc.Exports[SelectedObject].Data = mem.ToArray();
            MessageBox.Show("Done");
            Close();
        }
Example #60
0
 private void SerializeLODs(SerializingContainer Container)
 {
     int count = 0;
     if (!Container.isLoading)
         count = LODModels.Count();
     count = Container + count;
     if (Container.isLoading)
     {
         LODModels = new List<LODModelStruct>();
         for (int i = 0; i < count; i++)
             LODModels.Add(new LODModelStruct());
     }
     for (int i = 0; i < count; i++)
     {
         LODModelStruct lod = LODModels[i];
         lod.Serialize(Container);
         LODModels[i] = lod;
     }
     //ReadEnd = Container.GetPos();
 }