コード例 #1
0
        public ImdConverter(string path, ImdConverterSettings settings = null)
        {
            _settings = settings ?? new ImdConverterSettings();

            var context = new AssimpContext();

            //Magnify model
            context.Scale = _settings.Magnify;

            if (_settings.CompressNodeMode == "unite_combine")
            {
                _scene = context.ImportFile(path, PostProcessSteps.PreTransformVertices);
            }
            else
            {
                _scene = context.ImportFile(path);
            }

            _imd = new LibNitro.Intermediate.Imd.Imd
            {
                Head = { GeneratorInfo = GeneratorInfo },
                Body = { OriginalGeneratorInfo = GeneratorInfo }
            };

            _modelDirectory                       = Path.GetDirectoryName(path);
            _imd.Head.CreateInfo.Source           = Path.GetFileName(path);
            _imd.Body.ModelInfo.Magnify           = _settings.Magnify;
            _imd.Body.ModelInfo.UsePrimitiveStrip = _settings.UsePrimitiveStrip ? "on" : "off";
            _imd.Body.ModelInfo.CompressNode      = _settings.CompressNodeMode;

            GetTextures();
            var matMap = GetMaterials();

            GetMatrices();
            GetNodes(_scene.RootNode);
            GetPosScales();
            GetPolygons(matMap);
        }
コード例 #2
0
        public static ImdConverterSettings GetArguments(string[] args, out string outPath)
        {
            outPath = null;
            var settings = new ImdConverterSettings();

            for (int i = 1; i < args.Length; i++)
            {
                switch (args[i])
                {
                case "-o":
                case "--output":
                    try
                    {
                        outPath = Path.GetFullPath(args[i + 1].Replace("\"", String.Empty));
                    }
                    catch
                    {
                        throw new Exception("Invalid/Missing Output Path");
                    }
                    i++;
                    break;

                case "-m":
                case "--mag":
                    try
                    {
                        settings.Magnify = float.Parse(args[i + 1]);
                    }
                    catch
                    {
                        throw new Exception("Invalid/Missing Magnification Factor");
                    }
                    i++;
                    break;

                case "-f":
                case "--flipYZ":
                    settings.FlipYZ = true;
                    break;

                case "-r":
                case "--rot180":
                    settings.RotateX180 = true;
                    break;

                case "-l":
                case "--light":
                    settings.NoLightOnMaterials = false;
                    break;

                case "-n":
                case "--nostrip":
                    settings.UsePrimitiveStrip = false;
                    break;

                case "-c":
                case "--compressnode":
                    settings.CompressNodeMode = args[i + 1];
                    i++;
                    break;

                case "-v":
                case "--verbose":
                    settings.Verbose = true;
                    break;
                }
            }

            return(settings);
        }