Esempio n. 1
0
        private void exportMorphToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MorphTreeNode morphNode = LeftTree.SelectedNode as MorphTreeNode;

            if (morphNode != null && morphNode.morph != null && morphNode.morph.IsExportable)
            {
                var pccNode = morphNode.GetParentNode();

                SaveFileDialog sfd = new SaveFileDialog();
                sfd.Title    = "Save morph as...";
                sfd.Filter   = "*.fbx|.fbx|*.json|*.json";
                sfd.FileName = morphNode.Text + ".fbx";
                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    this.Cursor = Cursors.WaitCursor;
                    string ext = System.IO.Path.GetExtension(sfd.FileName);
                    if (ext.EndsWith("fbx"))
                    {
                        var exporter = new MEMeshMorphExporter.Exporters.MeshExporter(pccNode.pcc);
                        exporter.ExportMeshWithMorph(morphNode.morph, 0, sfd.FileName);
                    }
                    else if (ext.EndsWith("json"))
                    {
                        morphNode.morph.ExportToJson(sfd.FileName);
                    }
                    this.Cursor = Cursors.Default;
                    MessageBox.Show("Done.");
                }
            }
            else
            {
                MessageBox.Show("Sorry, this morph cannot be exported: base mesh was not found.");
            }
        }
Esempio n. 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);
        }