AB4D Forum
assimpWpfImporter ReadModel3D from stream - Printable Version

+- AB4D Forum (https://forum.ab4d.com)
+-- Forum: Products Forums (https://forum.ab4d.com/forumdisplay.php?fid=4)
+--- Forum: Ab3d.PowerToys (https://forum.ab4d.com/forumdisplay.php?fid=9)
+--- Thread: assimpWpfImporter ReadModel3D from stream (/showthread.php?tid=4155)



assimpWpfImporter ReadModel3D from stream - kreativasas - 11-28-2019

Hi,

just a question.

I read STL file with assimpwpf importer and everything is ok.

Now i stored stl file into a database in binary mode and i need to use wpf importer not from file but from a memory stream read from my database.
How i have to do? Is it possible?

Thanks


RE: assimpWpfImporter ReadModel3D from stream - abenedik - 11-28-2019

Instead of calling ReadModel3D method that takes fileName as parameter use the overload that accepts a stream:

Code:
       /// <summary>
       /// ReadModel3D method reads 3D models from stream and returns the 3D models as Model3DGroup or GeomentryModel3D.
       /// When the model have additional textures, the resolveResourceFunc must be set a method that converts the resource name into a Stream.
       /// </summary>
       /// <param name="fileStream">file stream</param>
       /// <param name="formatHint">file extension to serve as a hint to Assimp to choose which importer to use - for example ".dae"</param>
       /// <param name="resolveResourceFunc">method that converts the resource name into Stream - used to read additional resources (materials and textures)</param>
       /// <returns>WPF Model3D object</returns>
       public Model3D ReadModel3D(Stream fileStream, string formatHint, Func<string, Stream> resolveResourceFunc = null)



RE: assimpWpfImporter ReadModel3D from stream - kreativasas - 11-28-2019

Hi,

I tried to use overload but i received the error:
Assimp.AssimpException: 'Error importing file: Invalid parameters passed to ReadFileFromMemory()'

I simply create a memorystream from a bytes array and passed to read3dmodel overlay:
mystl=assimpWpfImporter.ReadModel3D(mystream, ".stl")