Example #1
0
 public MeshTreeNode(Unreal.MESkeletalMesh aMesh, IExportEntry exp)
 {
     mesh = aMesh;
     Text = exp.ObjectName;
 }
Example #2
0
        public TreeNode BuildPccTree(string pcc)
        {
            if (!_isPackageHandlerInitialized)
            {
                MEPackageHandler.Initialize();
                _isPackageHandlerInitialized = true;;
            }

            // check first if this pcc has already been added in the tree
            bool IsPccAlreadyInTree = PccList.Find(ptn => ptn.pcc.FileName == pcc) != null;

            if (IsPccAlreadyInTree)
            {
                return(null);
            }

            var Pcc = MEPackageHandler.OpenMEPackage(pcc);

            /*
             * ME3Package me3Pcc = Pcc as ME3Package;
             *
             * if (me3Pcc == null)
             * {
             *  // supports only ME3 for the time being
             *  throw new ArgumentException("This is not a ME3 package. The tool only supports ME3 at this time.");
             * }
             * */

            PccTreeNode pccRootNode = null;

            var MorphExpIndexes = Pcc.Exports.Select((value, index) => new { value, index })
                                  .Where(z => z.value.ClassName == "BioMorphFace")
                                  .Select(z => z.index);

            if (MorphExpIndexes.Count() > 0)
            {
                pccRootNode = new PccTreeNode(Pcc);

                // Morphs
                TreeNode ParentMorphNode = new TreeNode();
                ParentMorphNode.Text = "BioMorphFace";

                foreach (int morphIndex in MorphExpIndexes)
                {
                    var           morph     = new Unreal.BioMorphFace(Pcc, morphIndex);
                    MorphTreeNode morphNode = new MorphTreeNode(morph);
                    ParentMorphNode.Nodes.Add(morphNode);
                }

                // Meshes
                TreeNode ParentMeshNode = new TreeNode();
                ParentMeshNode.Text = "SkeletalMesh";

                var MeshExpIndexes = Pcc.Exports.Select((value, index) => new { value, index })
                                     .Where(z => z.value.ClassName == "SkeletalMesh")
                                     .Select(z => z.index);

                foreach (int meshIndex in MeshExpIndexes)
                {
                    IExportEntry exp = Pcc.Exports[meshIndex];
                    //SkeletalMesh skMesh = new SkeletalMesh((ME3Package)Pcc, meshIndex);
                    var          skMesh   = new Unreal.MESkeletalMesh(Pcc, meshIndex);
                    MeshTreeNode meshNode = new MeshTreeNode(skMesh, exp);
                    ParentMeshNode.Nodes.Add(meshNode);
                }

                // build hierarchy
                pccRootNode.Nodes.Add(ParentMeshNode);
                pccRootNode.Nodes.Add(ParentMorphNode);

                // add in the list
                PccList.Add(pccRootNode);
            }
            else
            {
                Pcc = null;
            }
            return(pccRootNode);
        }
Example #3
0
        public BioMorphFace(IMEPackage Pcc, int Index) : base(Pcc, Index)
        {
            if (pcc.isExport(Index))
            {
                data = pcc.Exports[Index].Data;
                IExportEntry export = pcc.Exports[MyIndex];
                Props = PropertyReader.getPropList(export);

                int startVerticesIndex = -1;
                foreach (PropertyReader.Property prop in Props)
                {
                    string propName = pcc.getNameEntry(prop.Name);
                    switch (propName)
                    {
                    case "m_aMorphFeatures":
                        ReadMorphFeatures(prop);
                        break;

                    case "m_aFinalSkeleton":
                        ReadFinalSkeleton(prop);
                        break;

                    case "m_oBaseHead":
                        int objIndex = prop.Value.IntValue;
                        if (pcc.isExport(objIndex - 1))
                        {
                            m_oBaseHead = new MESkeletalMesh(pcc, objIndex - 1);
                        }
                        else if (pcc.isImport(-objIndex - 1))
                        {
                            // look for a package actually containing the object
                            IMEPackage nPcc     = null;
                            int        expIndex = -1;
                            LookupObjectInImports(-objIndex - 1, out nPcc, out expIndex);
                            if (nPcc != null && expIndex > -1)
                            {
                                m_oBaseHead = new MESkeletalMesh(nPcc, expIndex);
                            }
                        }
                        break;

                    case "m_oHairMesh":
                        int objHairIndex = prop.Value.IntValue;
                        if (pcc.isExport(objHairIndex - 1))
                        {
                            m_oHairMesh = new MESkeletalMesh(pcc, objHairIndex - 1);
                        }
                        else if (pcc.isImport(-objHairIndex - 1))
                        {
                            IMEPackage nPcc     = null;
                            int        expIndex = -1;
                            LookupObjectInImports(-objHairIndex - 1, out nPcc, out expIndex);
                            if (nPcc != null && expIndex > -1)
                            {
                                m_oHairMesh = new MESkeletalMesh(nPcc, expIndex);
                            }
                        }
                        break;

                    case "m_nInternalMorphFaceContentVersion":
                        break;

                    case "m_oMaterialOverrides":
                        int objMatOIndex = prop.Value.IntValue;
                        if (pcc.isExport(objMatOIndex - 1))
                        {
                            m_oMaterialOverrides = new MaterialOverrides(pcc, objMatOIndex - 1);
                        }
                        else if (pcc.isImport(-objMatOIndex - 1))
                        {
                            IMEPackage nPcc     = null;
                            int        expIndex = -1;
                            LookupObjectInImports(-objMatOIndex - 1, out nPcc, out expIndex);
                            if (nPcc != null && expIndex > -1)
                            {
                                m_oMaterialOverrides = new MaterialOverrides(nPcc, expIndex);
                            }
                        }
                        break;

                    case "CurrentMorphFaceContentVersion":
                    case "bRequiresDynamicUpdates":
                        break;

                    case "None":
                        startVerticesIndex = prop.offsetval + prop.raw.Length;
                        break;

                    default:
                        Console.WriteLine("Unknow property for BioMorphFace: " + pcc.getNameEntry(prop.Name));
                        break;
                    }
                }
                ReadVertices(startVerticesIndex);
            }
        }