Example #1
0
        /// <summary>
        /// Import a model
        /// </summary>
        /// <param name="path"></param>
        /// <param name="importType"></param>
        /// <returns></returns>
        public override async Task ImportModel(string path, ModelCompile importType, bool phantomFix, bool h2SelectionLogic, bool renderPRT, bool FPAnim, string characterFPPath, string weaponFPPath, bool accurateRender, bool verboseAnim, bool uncompressedAnim, bool skyRender, bool PDARender, bool resetCompression, bool autoFBX)
        {
            string type = "";

            if (verboseAnim)
            {
                type = "-verbose";
            }
            else if (uncompressedAnim)
            {
                type = "-uncompressed";
            }
            else if (resetCompression)
            {
                type = "-reset";
            }

            if (autoFBX)
            {
                await AutoFBX.Model(this, path, importType);
            }

            if (importType.HasFlag(ModelCompile.render))
            {
                if (skyRender)
                {
                    await RunTool(ToolType.Tool, new() { "render-sky", path });
                }
                else if (accurateRender)
                {
                    await RunTool(ToolType.Tool, new() { "render-accurate", path, renderPRT ? "final" : "draft" });
                }
                else
                {
                    await RunTool(ToolType.Tool, new() { "render", path, renderPRT ? "final" : "draft" });
                }
            }
            if (importType.HasFlag(ModelCompile.collision))
            {
                await RunTool(ToolType.Tool, new() { "collision", path });
            }
            if (importType.HasFlag(ModelCompile.physics))
            {
                await RunTool(ToolType.Tool, new() { "physics", path });
            }
            if (importType.HasFlag(ModelCompile.animations))
            {
                if (FPAnim)
                {
                    await RunTool(ToolType.Tool, new() { "fp-model-animations" + type, path, characterFPPath, weaponFPPath });
                }
                else
                {
                    await RunTool(ToolType.Tool, new() { "model-animations" + type, path });
                }
            }
        }
Example #2
0
 /// <summary>
 /// Import a model
 /// </summary>
 /// <param name="path"></param>
 /// <param name="importType"></param>
 /// <returns></returns>
 public override async Task ImportModel(string path, ModelCompile importType)
 {
     if (importType.HasFlag(ModelCompile.render))
     {
         await RunTool(ToolType.Tool, new() { "model-render", path });
     }
     if (importType.HasFlag(ModelCompile.collision))
     {
         await RunTool(ToolType.Tool, new() { "model-collision", path });
     }
     if (importType.HasFlag(ModelCompile.physics))
     {
         await RunTool(ToolType.Tool, new() { "model-physics", path });
     }
     if (importType.HasFlag(ModelCompile.animations))
     {
         await RunTool(ToolType.Tool, new() { "append-animations", path });
     }
 }
Example #3
0
 /// <summary>
 /// Import a model
 /// </summary>
 /// <param name="path"></param>
 /// <param name="importType"></param>
 /// <returns></returns>
 public override async Task ImportModel(string path, ModelCompile importType, bool phantomFix, bool h2SelectionLogic, bool renderPRT, bool FPAnim, string characterFPPath, string weaponFPPath, bool accurateRender, bool verboseAnim, bool uncompressedAnim, bool skyRender, bool PDARender, bool resetCompression, bool autoFBX)
 {
     if (importType.HasFlag(ModelCompile.render))
     {
         await RunTool(ToolType.Tool, new() { "model-render", path });
     }
     if (importType.HasFlag(ModelCompile.collision))
     {
         await RunTool(ToolType.Tool, new() { "model-collision", path });
     }
     if (importType.HasFlag(ModelCompile.physics))
     {
         await RunTool(ToolType.Tool, new() { "model-physics", path });
     }
     if (importType.HasFlag(ModelCompile.animations))
     {
         await RunTool(ToolType.Tool, new() { "append-animations", path });
     }
 }
Example #4
0
        public static async Task Model(ToolkitBase tk, string path, ModelCompile importType)
        {
            /* Check for x.all.fbx in root directory. */
            List <FileInfo> alls    = new List <FileInfo>();
            string          rootDir = tk.GetDataDirectory() + "\\" + path;

            if (!MainWindow.halo_ce_mcc) // Don't bother doing this for Halo 1 as the fbx-to-jms tool works differntly for that one
            {
                string[] rootFilePaths = Directory.GetFiles(rootDir, "*.all.fbx");
                foreach (string f in rootFilePaths)
                {
                    FileInfo fi = new FileInfo(f);
                    alls.Add(fi);
                }

                /* Convert x.all.fbx */
                foreach (FileInfo all in alls)
                {
                    string outPath = rootDir + "\\" + (all.Name.ToLower().Replace(".all.fbx", ".jms"));
                    await tk.RunTool(ToolType.Tool, new() { "fbx-to-jms", "all", all.FullName, outPath });
                }
            }

            /* Convert render/collision/physics */
            foreach (ImportTypeInfo importTypeInfo in GetImportTypeInfo())
            {
                if (importType.HasFlag(importTypeInfo.importType))
                {
                    string typeDir = rootDir + "\\" + importTypeInfo.folderName;

                    /* Copy x.all.fbx output if it exists */
                    if (alls.Count > 0)
                    {
                        if (!Directory.Exists(typeDir))
                        {
                            Directory.CreateDirectory(typeDir);
                        }

                        foreach (FileInfo all in alls)
                        {
                            string inPath  = rootDir + "\\" + (all.Name.ToLower().Replace(".all.fbx", "_" + importTypeInfo.folderName + ".jms")); // Lowercase enforce to avoid .FBX <-> .fbx mismatches
                            string outPath = typeDir + "\\" + (all.Name.ToLower().Replace(".all.fbx", ".jms"));

                            string checkPath = typeDir + "\\" + (all.Name.ToLower().Replace(".all.fbx", ".fbx"));
                            if (File.Exists(checkPath))
                            {
                                continue;
                            }                                         // Skip x.all.fbx if there is an x.fbx with same name in the relevant subfolder

                            if (File.Exists(outPath))
                            {
                                File.Delete(outPath);
                            }                                                   // Delete file at outpath because overwrite throws an exception

                            if (File.Exists(inPath))
                            {
                                File.Move(inPath, outPath);
                            }                                                        // Move file as long as it exists, a messed up fbx won't output a jms so we check before moving
                        }
                    }
                    /* Convert fbx in relevant sub folders */
                    if (Directory.Exists(typeDir))
                    {
                        List <FileInfo> fbxs = new List <FileInfo>();

                        string[] filePaths = Directory.GetFiles(typeDir, "*.fbx");
                        foreach (string f in filePaths)
                        {
                            FileInfo fi = new FileInfo(f);
                            fbxs.Add(fi);
                        }

                        foreach (FileInfo fbx in fbxs)
                        {
                            string outPath = typeDir + "\\" + (fbx.Name.ToLower().Replace(".fbx", ".jms")); // Lowercase enforce to avoid .FBX <-> .fbx mismatches
                            await tk.RunTool(ToolType.Tool, new() { "fbx-to-jms", importTypeInfo.commandOption, fbx.FullName, outPath });
                        }
                    }
                }
            }

            /* Delete any unused .jms files in root directory converted by 'all' */
            foreach (FileInfo all in alls)
            {
                foreach (ImportTypeInfo importTypeInfo in GetImportTypeInfo())
                {
                    string fp = rootDir + "\\" + all.Name.ToLower().Replace(".all.fbx", "_" + importTypeInfo.folderName + ".jms"); // Lowercase enforce to avoid .FBX <-> .fbx mismatches
                    if (File.Exists(fp))
                    {
                        File.Delete(fp);
                    }
                }
            }

            /* Convert animations */
            string animDir = rootDir + "\\animations";

            if (Directory.Exists(animDir) && importType.HasFlag(ModelCompile.animations))
            {
                List <FileInfo> fbxs = new List <FileInfo>();

                string[] filePaths = Directory.GetFiles(animDir, "*.fbx");
                foreach (string f in filePaths)
                {
                    FileInfo fi = new FileInfo(f);
                    fbxs.Add(fi);
                }

                foreach (FileInfo fbx in fbxs)
                {
                    string outPath = animDir + "\\" + (fbx.Name.ToLower().Replace(".fbx", ".jma")); // Lowercase enforce to avoid .FBX <-> .fbx mismatches
                    await tk.RunTool(ToolType.Tool, new() { "fbx-to-jma", fbx.FullName, outPath });
                }
            }
        }
Example #5
0
 public record ImportTypeInfo(
     ModelCompile importType,
     string folderName,
     string commandOption
     );
Example #6
0
 public abstract Task ImportModel(string path, ModelCompile importType, bool phantomFix, bool h2SelectionLogic, bool renderPRT, bool FPAnim, string characterFPPath, string weaponFPPath, bool accurateRender, bool verboseAnim, bool uncompressedAnim, bool skyRender, bool PDARender, bool resetCompression, bool autoFBX);
Example #7
0
 public abstract Task ImportModel(string path, ModelCompile importType);