Beispiel #1
0
        public static Model Load(Arguments args)
        {
            string extension = Path.GetExtension(args.input_path);
            Model  output    = null;

            if (extension == ".bmd" || extension == ".bdl")
            {
                using (FileStream str = new FileStream(args.input_path, FileMode.Open, FileAccess.Read))
                {
                    EndianBinaryReader reader = new EndianBinaryReader(str, Endian.Big);
                    output = new Model(reader, args);
                }
            }
            else
            {
                Assimp.AssimpContext cont = new Assimp.AssimpContext();

                // AssImp adds dummy nodes for pivots from FBX, so we'll force them off
                cont.SetConfig(new Assimp.Configs.FBXPreservePivotsConfig(false));

                Assimp.PostProcessSteps postprocess = Assimp.PostProcessSteps.Triangulate | Assimp.PostProcessSteps.JoinIdenticalVertices;

                if (args.tristrip_mode == "none")
                {
                    // By not joining identical vertices, the Tri Strip algorithm we use cannot make tristrips,
                    // effectively disabling tri stripping
                    postprocess = Assimp.PostProcessSteps.Triangulate;
                }
                Assimp.Scene aiScene = cont.ImportFile(args.input_path, postprocess);

                output = new Model(aiScene, args);
            }

            return(output);
        }
Beispiel #2
0
        public static void Export(Ai.Scene aiScene, string fileName, Ai.PostProcessSteps postProcessSteps = Ai.PostProcessSteps.None)
        {
            var aiContext = new Ai.AssimpContext();

            var formatExtension = Path.GetExtension(fileName).Substring(1);
            var formatId        = aiContext.GetSupportedExportFormats()
                                  .First(x => x.FileExtension.Equals(formatExtension, StringComparison.OrdinalIgnoreCase)).FormatId;

            aiContext.ExportFile(aiScene, fileName, formatId, postProcessSteps);
        }
Beispiel #3
0
    public CustomAssetImporter()
    {
        // Import Settings
        importer = new Assimp.AssimpContext();
        importer.SetConfig(new Assimp.Configs.MeshVertexLimitConfig(60000));
        importer.SetConfig(new Assimp.Configs.MeshTriangleLimitConfig(60000));
        importer.SetConfig(new Assimp.Configs.RemoveDegeneratePrimitivesConfig(true));
        importer.SetConfig(new Assimp.Configs.SortByPrimitiveTypeConfig(Assimp.PrimitiveType.Line | Assimp.PrimitiveType.Point));

        postProcessSteps = Assimp.PostProcessPreset.TargetRealTimeMaximumQuality | Assimp.PostProcessSteps.MakeLeftHanded | Assimp.PostProcessSteps.FlipWindingOrder;
    }
Beispiel #4
0
        public static Model Load(
            string filePath, List <Materials.Material> mat_presets = null,
            TristripOption triopt = TristripOption.DoNotTriStrip,
            bool flipAxis         = false, bool fixNormals = false, string additionalTexPath = null)
        {
            string extension = Path.GetExtension(filePath);
            Model  output    = null;

            if (extension == ".bmd" || extension == ".bdl")
            {
                using (FileStream str = new FileStream(filePath, FileMode.Open, FileAccess.Read))
                {
                    EndianBinaryReader reader = new EndianBinaryReader(str, Endian.Big);
                    output = new Model(reader, mat_presets);
                }
            }
            else
            {
                Assimp.AssimpContext cont = new Assimp.AssimpContext();

                // AssImp adds dummy nodes for pivots from FBX, so we'll force them off
                cont.SetConfig(new Assimp.Configs.FBXPreservePivotsConfig(false));

                Assimp.PostProcessSteps postprocess = Assimp.PostProcessSteps.Triangulate | Assimp.PostProcessSteps.JoinIdenticalVertices;

                if (triopt == TristripOption.DoNotTriStrip)
                {
                    // By not joining identical vertices, the Tri Strip algorithm we use cannot make tristrips,
                    // effectively disabling tri stripping
                    postprocess = Assimp.PostProcessSteps.Triangulate;
                }
                Assimp.Scene aiScene = cont.ImportFile(filePath, postprocess);

                output = new Model(aiScene, filePath, mat_presets, triopt, flipAxis, fixNormals, additionalTexPath);
            }

            return(output);
        }