public static ModelCollectionContent ConvertToContent(Assimp.Scene scene) { // create a mesh decoder for each mesh var matsBuilder = new AssimpMaterialsFactory(scene.Materials); var meshDecoders = scene.Meshes.ToXna(matsBuilder); var meshContent = MeshCollectionBuilder.CreateContent(meshDecoders); var matsContent = matsBuilder.CreateContent(); // build the armatures and models var models = new List <ModelContent>(); var armatures = new List <ArmatureContent>(); var armatureFactory = new AssimpArmatureFactory(scene); var armature = armatureFactory.CreateArmature(); armatures.Add(armature); var model = armatureFactory.CreateModelContent(scene, armatures.Count - 1); model.Name = "AssimpScene"; model.Tag = scene.Metadata; // model.ModelBounds = models.Add(model); // coalesce all resources into a container class: var content = new ModelCollectionContent(matsContent, meshContent, armatures.ToArray(), models.ToArray(), 0); content = PostProcessor.Postprocess(content); return(content); }
public static IReadOnlyList <IMeshDecoder <int> > ToXna(this IReadOnlyList <Assimp.Mesh> srcMeshes, AssimpMaterialsFactory srcMaterials) { var dstMeshes = srcMeshes .Select(item => new _MeshDecoder <int>(item, item.MaterialIndex)) .Cast <IMeshDecoder <int> >() .ToArray(); return(dstMeshes); }