RolandKoenig/SeeingSharp2

How to import .obj file ?

Closed this issue · 1 comments

Hello !

Before update 9.2 I was importing obj file like this :

var importer = new AssimpImporter();
importer.ImportModel("model.obj", new ImportOptions() { });

await BaseScene.ImportAsync(importer);

But since 9.2, the public -> internal change of AssimpImporter break that scenario, and :
await GraphicsCore.Current.ImportersAndExporters.ImportAsync support only stl and ac.

Error message when importing obj : No importer found for file type obj

Also, texture where not mapped to the 3D model.

Is there any way to import .obj file ?

Thank you !

GraphicsCore.Current.ImportersAndExporters.ImportAsync is the correct way.
I think the only thing missing is to register the AssimpImporter to SeeingSharp. You do this during GraphicsCore.Loader.Load() like the following sample from SeeingSharp.ModelViewer (see App.xaml.cs there)

GraphicsCore.Loader
    .SupportWpf()
    .RegisterAssimpImporter()
    .Load();

Instead of using GraphicsCore.Current.ImportersAndExporters.ImportAsync you can also use Scene.ImportAsync as a shortcut.