Asset Importer throws null on import with model most of the time.
#1
Hello, I am getting a null ref when attempting to load a model via Assimp about 95% of the time. The other 5% it loads fine. The model is fine, loads fine in Blender or Unity, but dies out attempting to load into Ab3d via Assimp. The error is rather unhelpful so I'm not sure where to look next. The code I'm using is essentially the AssimpWpfImporterSample but in my own code. I can replicate the same issue in the PowerToys sample version. I cannot find another model with the similar problem...yet.

I am new to AB4D and evaluating this software for purchase. Any help is appreciated. Thanks!


Code:
System.NullReferenceException
  HResult=0x80004003
  Message=Object reference not set to an instance of an object.
  Source=AssimpNet
  StackTrace:
   at Assimp.MemoryHelper.Read[T](IntPtr pSrc, T[] data, Int32 startIndexInArray, Int32 count)
   at Assimp.MemoryHelper.FromNativeArray[T](IntPtr nativeArray, Int32 length)
   at Assimp.MeshAnimationAttachment.Assimp.IMarshalable<Assimp.MeshAnimationAttachment,Assimp.Unmanaged.AiAnimMesh>.FromNative(AiAnimMesh& nativeValue)
   at Assimp.MemoryHelper.FromNativeArray[Managed,Native](IntPtr nativeArray, Int32 length, Boolean arrayOfPointers)
   at Assimp.Mesh.Assimp.IMarshalable<Assimp.Mesh,Assimp.Unmanaged.AiMesh>.FromNative(AiMesh& nativeValue)
   at Assimp.MemoryHelper.FromNativeArray[Managed,Native](IntPtr nativeArray, Int32 length, Boolean arrayOfPointers)
   at Assimp.Scene.Assimp.IMarshalable<Assimp.Scene,Assimp.Unmanaged.AiScene>.FromNative(AiScene& nativeValue)
   at Assimp.MemoryHelper.FromNativePointer[Managed,Native](IntPtr ptr)
   at Assimp.Scene.FromUnmanagedScene(IntPtr scenePtr)
   at Assimp.AssimpContext.ImportFile(String file, PostProcessSteps postProcessFlags)
   at Ab3d.Assimp.AssimpWpfImporter.ReadFileToAssimpScene(String fileName)
   at Ab3d.Assimp.AssimpWpfImporter.ReadModel3D(String fileName, String texturesPath)
   at VirtualAvatarPerfTest.MainWindow.LoadModel(String fileName) in C:\dev\bhive-launchpad\src\VirtualAvatarPerfTest\VirtualAvatarPerfTest\MainWindow.xaml.cs:line 75

   
#2
I see that the call stack from the exception shows that the error happens in the Assimp namespace. This namespace is part of the Assimp.Net project that is a third-party wrapper for the native assimp library. I cannot support that library because I am not the author of that library.

Anyway, I assume that the native assimp library cannot correctly read your file and this then produces a null reference exception in the Assimp.Net library. I would advise you to save your model in some different file format. From the attached image I see that the model is quite simple so you may also save it into the obj file format. In this case you would not need to use assimp importer but can simply use ReaderObj class from Ab3d.PowerToys library to read your file.
Andrej Benedik
#3
(09-10-2020, 08:48 AM)abenedik Wrote: I see that the call stack from the exception shows that the error happens in the Assimp namespace. This namespace is part of the Assimp.Net project that is a third-party wrapper for the native assimp library. I cannot support that library because I am not the author of that library.

Anyway, I assume that the native assimp library cannot correctly read your file and this then produces a null reference exception in the Assimp.Net library. I would advise you to save your model in some different file format. From the attached image I see that the model is quite simple so you may also save it into the obj file format. In this case you would not need to use assimp importer but can simply use ReaderObj class from Ab3d.PowerToys library to read your file.

I’ll check out the .OBJ and see if that imports correctly. The reason I was using the Assimp library was because I need blend shapes and skeletal animations and I think this is the only way to import them. Is there any other way to get the animation data into Ab3d? Afaik obj is just model data only.

Thanks
C
#4
Yes, obj can store only simple models. To read skeletal animation you will need assimp importer.

What file format are you using? Maybe you can try to save into another file format - fbx and dae (Collada) should both support skeletal animations.


The assimp library is constantly under development. Therefore I have got the latest version from GitHub source and compiled it. When I tried to use that with the skeletal animation that is part of the Ab3d.PowerToys samples I got the same exception as you got. So it looks like there is some bug in the latest source of a breaking change.

I do not get that exception when using the assimp library that comes with the Ab3d.PowerToys library.

So I have another question? Do you also use a newer version of assimp library? If you do, then try with the official v5.0 that also comes with Ab3d.PowerToys library.
Andrej Benedik
#5
I am using the Assimp version that is in the PowerToys samples project. I simply copied the lib/ from there into my test project. It looks like the issue is blend shapes. I have not yet rigged the model, so it has no bones. I deleted all the shape keys in Blender and bam, the model loads. So it looks like, for some reason Assimp or Ab4d doesn't support blend shapes. I need blend shapes for facial key poses *and* skeletal animation. 

I am able to repro this issue with the attached model which is a simple cube with a single shape key. This issue occurs in both the Ab4d PowerToys project's 'Assimp Model Viewer' example and in my own project. Again, this isn't a 100% repro rate. It might work the first time, then break. I also fully recognize that you aren't the developer of Assimp and you can't necessarily do much here to fix the issue.

I'm a little confused by this thread because it looks like maybe assimp supports blend shapes via aiAnimMesh...or it doesn't. 
https://github.com/assimp/assimp/issues/2368


Thanks,
Chris


Attached Files
.zip   cube_with_shape_key.zip (Size: 4.21 KB / Downloads: 1)
  


Forum Jump:


Users browsing this thread:
1 Guest(s)