AreonDev / assimp-net

Managed wrapper around the assimp open asset import library
2 stars 1 forks source link

Unable to open Lightwave LWS file from stream #7

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Open a FileStream to scenes/fenris.lws
2. Create a new AssimpImporter and call ImportFileFromStream(stream, ".lws")
3. Crash due to AssimpException

What is the expected output? What do you see instead?
Expected output would be a valid scene just like you get by using the 
ImportFile method instead. However, ImportFileFromStream is unable to resolve 
the external file dependencies to the referenced LWO files. These files contain 
the actual geometry in the scene and without them no geometry is ever loaded.

What version of the product are you using? On what operating system?
Assimp.Net 3.1

Please provide any additional information below.
I didn't find any way to supply custom file handling to Assimp to resolve those 
external file dependencies. There is a IOSystem class in Assimp, which is 
supposed to be used for that, but this doesn't seem to be exposed in Assimp.Net.

Original issue reported on code.google.com by arpa...@googlemail.com on 28 Feb 2013 at 1:55

Attachments:

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Forgot to mention: ImportFile actually fails to resolve the references as well, 
but you can fix that by temporarily setting Environment.CurrentDirectory to the 
proper content directory (parent folder of the "objects" and "scenes" 
subfolders in this case). CurrentDirectory basically must be set to the same 
folder set as content directory in LightWave when creating the LWS/LWO files:

    Environment.CurrentDirectory = @"C:\Content";
    AssimpImporter importer = new AssimpImporter();
    Scene scene = importer.ImportFile(@"C:\Content\scenes\fenris.lws");

This doesn't work with ImportFileFromStream, though.

Original comment by arpa...@googlemail.com on 28 Feb 2013 at 2:27

GoogleCodeExporter commented 9 years ago
Yeah, the custom file handling was never exposed. I'll look into adding support.

Original comment by nicholas.woodfield on 28 Feb 2013 at 10:16

GoogleCodeExporter commented 9 years ago
I've implemented the IOSystem/IOStream. There's a simple implementation, 
"FileIOSystem" that you can specify multiple search paths that can handle 
finding input files that are spread out beyond the model's root folder.

There is one caveat though, the custom file IO will only work with ImportFile 
or ConvertFile API's. You will continue hitting the exception when using the 
ImportFileFromStream API.

This s because none of the Assimp "ImportFromMemory" C functions take in an 
aiFileIO structure. I'm waiting a response from the Assimp developers regarding 
this.

Original comment by nicholas.woodfield on 10 Mar 2013 at 4:39

GoogleCodeExporter commented 9 years ago
FYI, an update on the caveat: 

If you need to use custom file IO, you need to do so from the API that 
imports/converts from a File source. Custom file IO is not supported from 
importing from a memory buffer in the Assimp C API, and therefore is not 
supported by AssimpNet.

https://sourceforge.net/projects/assimp/forums/forum/817653/topic/6973982/index/
page/1

Original comment by nicholas.woodfield on 10 Mar 2013 at 7:20