コード例 #1
0
ファイル: ModelCompilerTask.cs プロジェクト: loreggia/SharpDX
        protected override Diagnostics.Logger ProcessFileAndGetLogResults(string inputFilePath, string outputFilePath, string dependencyFilePath, TkItem item)
        {
            var compilerOptions = new ModelCompilerOptions()
            {
                DependencyFile = dependencyFilePath,
                Quality        = Debug ? ModelRealTimeQuality.Low : ModelRealTimeQuality.Maximum
            };

            var compilerResult = ModelCompiler.CompileAndSave(inputFilePath, outputFilePath, compilerOptions);

            return(compilerResult.Logger);
        }
コード例 #2
0
        protected override bool ProcessFile(string inputFilePath, string outputFilePath, string dependencyFilePath, OdItem item)
        {
            ModelOperation op = ModelOperation.None;
            
            if (ModelOperations != null)
                op = ModelOperations.Aggregate(ModelOperation.None, (current, t) => current | (ModelOperation) Enum.Parse(typeof (ModelOperation), t.ItemSpec));

            var compilerOptions = new ModelCompilerOptions()
            {
                DependencyFile = dependencyFilePath,
                Quality = Debug ? ModelRealTimeQuality.Low : ModelRealTimeQuality.Maximum,
                ExcludeElements = ExcludeElements != null ? ExcludeElements.Select(element => element.ItemSpec).ToArray() : new string[0],
                ModelOperations = op
            };

            var result = ModelCompiler.CompileAndSave(inputFilePath, outputFilePath, compilerOptions);

            return result.HasErrors;
        }
コード例 #3
0
        void Run(string[] args)
        {
            // Print the exe header
            PrintHeader();

            // Parse the command line
            if (!ParseCommandLine(args))
            {
                Environment.Exit(-1);
            }

            var options = this;


            bool hasErrors = false;

            // ----------------------------------------------------------------
            // Process model file
            // ----------------------------------------------------------------
            var filePath = Path.Combine(Environment.CurrentDirectory, ModelFile);

            if (!File.Exists(filePath))
            {
                ErrorColor();
                Console.Error.WriteLine("File [{0}] does not exist", filePath);
                ResetColor();
                Environment.Exit(-1);
            }

            var defaultOutputFile = Path.Combine(Path.GetDirectoryName(filePath), Path.GetFileNameWithoutExtension(filePath));

            // Compiles to SpriteData
            OutputFile = OutputFile ?? defaultOutputFile;

            string dependencyFile = null;

            if (CompileOnlyIfNewer)
            {
                dependencyFile = Path.Combine(OutputDependencyDirectory, FileDependencyList.GetDependencyFileNameFromSourcePath(Path.GetFileName(filePath)));
            }

            Console.WriteLine("Compile Model from File [{0}] => {1}", filePath, OutputFile);

            var compilerOptions = new ModelCompilerOptions()
            {
                DependencyFile = dependencyFile,
                Quality        = FastQuality ? ModelRealTimeQuality.Low : ModelRealTimeQuality.Maximum
            };

            var result = ModelCompiler.CompileAndSave(filePath, OutputFile, compilerOptions);

            if (result.HasErrors)
            {
                ErrorColor();
                Console.Error.WriteLine("Compilation has errors. Process aborted.");
                ResetColor();
                Environment.Exit(-1);
            }


            if (result.IsContentGenerated)
            {
                Console.WriteLine("Successfull");
            }
            else
            {
                Console.WriteLine("Nothing to generate. Model and Compiled Model are in sync");
            }
        }