public static ModelPack ConvertFromAssimpScene(string filePath, ModelPackConverterOptions options)
        {
            // For importing textures
            string baseDirectoryPath = Path.GetDirectoryName(filePath);

            // Import scene
            var aiScene = AssimpSceneImporter.ImportFile(filePath);

            // Build textures & Materials
            var model = new ModelPack(options.Version);

            model.Textures  = new TextureDictionary(options.Version);
            model.Materials = new MaterialDictionary(options.Version);

            foreach (var aiSceneMaterial in aiScene.Materials)
            {
                var material = ConvertMaterialAndTextures(aiSceneMaterial, options, baseDirectoryPath, model.Textures);
                model.Materials.Add(material);
            }

            // Create scene
            var sceneConverterOptions = new ModelConverterOptions()
            {
                Version                 = options.Version,
                ConvertSkinToZUp        = options.ConvertSkinToZUp,
                GenerateVertexColors    = options.GenerateVertexColors,
                MinimalVertexAttributes = options.MinimalVertexAttributes,
            };

            model.Model = ModelConverter.ConvertFromAssimpScene(aiScene, sceneConverterOptions);

            return(model);
        }
Example #2
0
        public static Model ConvertFromAssimpScene(string filePath, ModelConverterOptions options)
        {
            var aiScene = AssimpSceneImporter.ImportFile(filePath);

            return(ConvertFromAssimpScene(aiScene, options));
        }