digitalmars.D.learn - Loading assimp
- Dlearner (8/8) Jan 09 2017 I'm trying to use assimp to load models in a program. I see the
- Mike Parker (3/8) Jan 09 2017 Use version 1.1.1 of DerelictASSIMP3. It's implemented against
- Dlearner (2/11) Jan 10 2017 A-haa, thank you!
- Dlearner (12/12) Jan 29 2017 Need to rez this thread because I ran into a wall. Two little
- Dlearner (27/27) Mar 26 2017 I came back to this project and realised my mistakes (Importer is
- ag0aep6g (15/27) Mar 26 2017 The data is "glass_dif.png", followed by a null terminator,
- Dlearner (13/41) Mar 26 2017 Ahh this did help! I practically followed your advice, then
- Dlearner (15/17) Mar 26 2017 I don't know why, but when I get to the 8th texture, the filename
- ag0aep6g (16/28) Mar 26 2017 How do you construct `filename`? Looks like it's not properly
- Dlearner (7/42) Mar 27 2017 Ahh you were absolutely right. I concatenated a '\0' and it
- Eric_DD (9/9) Sep 28 2021 I am trying to use a newer version of Assimp.
- russhy (2/11) Sep 28 2021 try to rename it to Assimp64.dll
- Eric_DD (3/17) Sep 28 2021 Nah :) Already tried that. It just swaps the file names in the
- russhy (9/28) Sep 29 2021 Derelict is kinda old anyways, to make sure we use up to date
- Mike Parker (6/15) Sep 28 2021 I'm not maintaining the package anymore, but this is an error
- russhy (3/21) Sep 29 2021 why my messages are not sent?
- Guillaume Piolat (7/16) Sep 29 2021 If using dub you can build your D programs with
I'm trying to use assimp to load models in a program. I see the Derelict binding is for version 3.3, but the assimp site has no binaries for this, just source. So I try to use version 3.1.1 and I get this error: derelict.util.exception.SymbolLoadException ..\..\AppData\Roaming\dub\packages\derelict-util-2.0.6\derelict-util\source\derelict\u il\exception.d(35): Failed to load symbol aiReleaseExportFormatDescription from shared library assimp.dll Is this a version problem that I need 3.3 for? If so, I don't know how to build the .dll since I'm still new to programming. Please send help! :)
Jan 09 2017
On Monday, 9 January 2017 at 18:13:03 UTC, Dlearner wrote:I'm trying to use assimp to load models in a program. I see the Derelict binding is for version 3.3, but the assimp site has no binaries for this, just source. So I try to use version 3.1.1 and I get this error: derelict.util.exception.SymbolLoadException ..\..\AppData\Roaming\dub\packages\derelict-util-2.0.6\derelict-util\source\derelict\u il\exception.d(35): Failed to load symbol aiReleaseExportFormatDescription from shared library assimp.dllUse version 1.1.1 of DerelictASSIMP3. It's implemented against ASSIMP 3.1.
Jan 09 2017
On Tuesday, 10 January 2017 at 00:10:12 UTC, Mike Parker wrote:On Monday, 9 January 2017 at 18:13:03 UTC, Dlearner wrote:A-haa, thank you!I'm trying to use assimp to load models in a program. I see the Derelict binding is for version 3.3, but the assimp site has no binaries for this, just source. So I try to use version 3.1.1 and I get this error: derelict.util.exception.SymbolLoadException ..\..\AppData\Roaming\dub\packages\derelict-util-2.0.6\derelict-util\source\derelict\u il\exception.d(35): Failed to load symbol aiReleaseExportFormatDescription from shared library assimp.dllUse version 1.1.1 of DerelictASSIMP3. It's implemented against ASSIMP 3.1.
Jan 10 2017
Need to rez this thread because I ran into a wall. Two little things: 1) Can't seem to get the Importer class to work ("undefined identifier 'Importer' ", etc), and 2) GetTexture and GetTextureCount for aiMaterial don't seem to work (source\model.d(105,28): Error: no property 'GetTextureCount' for type 'aiMaterial*' source\model.d(107,6): Error: no property 'GetTexture' for type 'aiMaterial*') There are some const issues, too, but I can hack around them. Does anyone have any experience with these?
Jan 29 2017
I came back to this project and realised my mistakes (Importer is a class for the C++ API, and we're using the C API). So I fixed all my errors, but now I get an access violation. As far as I can tell, it seems to be an issue with `aiGetMaterialTexture`. It is meant to return an aiString with a filename (default value of "$texture.png"), I believe. But I get: aiString(13, x"67 6C 61 73 73 5F 64 69 66 2E 70 6E 67 00 FF FF FF ... FF"c) [shortened for brevity] I'm meant to add this on to a directory string so I can load an image, but obviously this wouldn't work. I thought it might be a problem with converting from D-strings to C-strings. I sent a string to `aiImportFile` as `toStringz(path)`. I tested this with some writeln debugging: ``` auto temp = path.toStringz; writeln("toStringz: ", temp); writeln("string: ", temp.to!string); ``` This gave: toStringz: 4770B6 string: Models/Nanosuit/nanosuit.obj So maybe this is a problem with using aiStrings? I'm quite confused. Sorry if this is more of an assimp question than a D question, but I don't know if it's me misusing D language features or not.
Mar 26 2017
On Sunday, 26 March 2017 at 10:34:21 UTC, Dlearner wrote:I came back to this project and realised my mistakes (Importer is a class for the C++ API, and we're using the C API). So I fixed all my errors, but now I get an access violation. As far as I can tell, it seems to be an issue with `aiGetMaterialTexture`. It is meant to return an aiString with a filename (default value of "$texture.png"), I believe. But I get: aiString(13, x"67 6C 61 73 73 5F 64 69 66 2E 70 6E 67 00 FF FF FF ... FF"c) [shortened for brevity]The data is "glass_dif.png", followed by a null terminator, followed by a bunch of 0xFFs. 13 is the length of "glass_dif.png". Judging from the definition of aiString [1], the 0xFFs are just unused space. So, this looks good.I'm meant to add this on to a directory string so I can load an image, but obviously this wouldn't work.To convert an aiString to a D string, it should be possible to slice the data with the length: aiString x; const(char)[] y = x.data[0 .. x.length]; You have to be cautiots of lifetime requirements, of course. If needed, you can make a copy with dup (mutable copy) or idup (immutable copy): const(char)[] y = x.data[0 .. x.length].dup; string z = x.data[0 .. x.length].idup; [1] http://www.assimp.org/lib_html/structai_string.html
Mar 26 2017
On Sunday, 26 March 2017 at 11:10:55 UTC, ag0aep6g wrote:On Sunday, 26 March 2017 at 10:34:21 UTC, Dlearner wrote:Ahh this did help! I practically followed your advice, then fixed a somewhat unrelated range violation, and got a similar "object.Error (0): Access Violation". But in the console I got: filename: Models/Nanosuit/glass_dif.png filename: Models/Nanosuit/leg_dif.png filename: Models/Nanosuit/leg_showroom_spec.png filename: Models/Nanosuit/hand_dif.png filename: Models/Nanosuit/hand_showroom_spec.png filename: Models/Nanosuit/arm_dif.png filename: Models/Nanosuit/arm_showroom_spec.png filename: Models/Nanosuit/helmet_diff.png About half the textures seem to load fine. Some progress!I came back to this project and realised my mistakes (Importer is a class for the C++ API, and we're using the C API). So I fixed all my errors, but now I get an access violation. As far as I can tell, it seems to be an issue with `aiGetMaterialTexture`. It is meant to return an aiString with a filename (default value of "$texture.png"), I believe. But I get: aiString(13, x"67 6C 61 73 73 5F 64 69 66 2E 70 6E 67 00 FF FF FF ... FF"c) [shortened for brevity]The data is "glass_dif.png", followed by a null terminator, followed by a bunch of 0xFFs. 13 is the length of "glass_dif.png". Judging from the definition of aiString [1], the 0xFFs are just unused space. So, this looks good.I'm meant to add this on to a directory string so I can load an image, but obviously this wouldn't work.To convert an aiString to a D string, it should be possible to slice the data with the length: aiString x; const(char)[] y = x.data[0 .. x.length]; You have to be cautiots of lifetime requirements, of course. If needed, you can make a copy with dup (mutable copy) or idup (immutable copy): const(char)[] y = x.data[0 .. x.length].dup; string z = x.data[0 .. x.length].idup; [1] http://www.assimp.org/lib_html/structai_string.html
Mar 26 2017
On Sunday, 26 March 2017 at 12:40:42 UTC, Dlearner wrote:... About half the textures seem to load fine. Some progress!I don't know why, but when I get to the 8th texture, the filename has some garbage attached. SDL_Surface* surface = IMG_Load(filename.ptr); if (surface is null) { writeln("surface is null: ", to!string(IMG_GetError())); } else { writeln(filename); } From console: surface is null: Couldn't open Models/Nanosuit/helmet_diff.pngÇ2ÿ I'm assuming the previous textures didn't experience this, but I have no idea what could be the problem here, especially as the filename seems fine when I writeln it. :(
Mar 26 2017
On 03/26/2017 11:31 PM, Dlearner wrote:SDL_Surface* surface = IMG_Load(filename.ptr); if (surface is null) { writeln("surface is null: ", to!string(IMG_GetError())); } else { writeln(filename); } From console: surface is null: Couldn't open Models/Nanosuit/helmet_diff.pngÇ2ÿ I'm assuming the previous textures didn't experience this, but I have no idea what could be the problem here, especially as the filename seems fine when I writeln it. :(How do you construct `filename`? Looks like it's not properly null-terminated. If you followed my (short-sighted) `dup` advice, that doesn't do null-termination. Since the original strings are null-terminated, just slicing one more character should do the trick. I'd put an assert that verifies that the last character is '\0'. I.e.: ---- string z = x.data[0 .. x.length + 1].idup; assert(z[$ - 1] == '\0'); ---- Generally, don't pass just the pointer of a string unless you know for sure that it's properly null-terminated. If you're using a slice directly, without `dup`-ing, then the original aiString would seem to be broken already.
Mar 26 2017
On Sunday, 26 March 2017 at 21:52:42 UTC, ag0aep6g wrote:On 03/26/2017 11:31 PM, Dlearner wrote:Ahh you were absolutely right. I concatenated a '\0' and it worked. Silly me! Most of the textures loaded and a really broken model appears, but I'm guessing that's a result of trying to follow along with a tutorial written for C++ in D. Thank you for your help. I really appreciate it. :)SDL_Surface* surface = IMG_Load(filename.ptr); if (surface is null) { writeln("surface is null: ", to!string(IMG_GetError())); } else { writeln(filename); } From console: surface is null: Couldn't open Models/Nanosuit/helmet_diff.pngÇ2ÿ I'm assuming the previous textures didn't experience this, but I have no idea what could be the problem here, especially as the filename seems fine when I writeln it. :(How do you construct `filename`? Looks like it's not properly null-terminated. If you followed my (short-sighted) `dup` advice, that doesn't do null-termination. Since the original strings are null-terminated, just slicing one more character should do the trick. I'd put an assert that verifies that the last character is '\0'. I.e.: ---- string z = x.data[0 .. x.length + 1].idup; assert(z[$ - 1] == '\0'); ---- Generally, don't pass just the pointer of a string unless you know for sure that it's properly null-terminated. If you're using a slice directly, without `dup`-ing, then the original aiString would seem to be broken already.
Mar 27 2017
I am trying to use a newer version of Assimp. I have found a assimp-vc140-mt.dll (v3.3.1) which I renamed to assimp.dll When running my executable it throws a derelict.util.exception.SharedLibLoadException: "Failed to load one or more shared libraries: assimp.dll - %1 is not a valid Win32 application. Assimp64.dll - The specified module could not be found" Any idea what's going on? Are 64bit dlls not supported?
Sep 28 2021
On Tuesday, 28 September 2021 at 16:30:09 UTC, Eric_DD wrote:I am trying to use a newer version of Assimp. I have found a assimp-vc140-mt.dll (v3.3.1) which I renamed to assimp.dll When running my executable it throws a derelict.util.exception.SharedLibLoadException: "Failed to load one or more shared libraries: assimp.dll - %1 is not a valid Win32 application. Assimp64.dll - The specified module could not be found" Any idea what's going on? Are 64bit dlls not supported?try to rename it to Assimp64.dll
Sep 28 2021
On Tuesday, 28 September 2021 at 19:59:09 UTC, russhy wrote:On Tuesday, 28 September 2021 at 16:30:09 UTC, Eric_DD wrote:Nah :) Already tried that. It just swaps the file names in the error message.I am trying to use a newer version of Assimp. I have found a assimp-vc140-mt.dll (v3.3.1) which I renamed to assimp.dll When running my executable it throws a derelict.util.exception.SharedLibLoadException: "Failed to load one or more shared libraries: assimp.dll - %1 is not a valid Win32 application. Assimp64.dll - The specified module could not be found" Any idea what's going on? Are 64bit dlls not supported?try to rename it to Assimp64.dll
Sep 28 2021
On Tuesday, 28 September 2021 at 20:09:41 UTC, Eric_DD wrote:On Tuesday, 28 September 2021 at 19:59:09 UTC, russhy wrote:Derelict is kinda old anyways, to make sure we use up to date stuff, try to migrate to bindbc one https://github.com/Sobaya007/bindbc-assimp https://code.dlang.org/packages/bindbc-assimp If i were you i'd compile the project myself, so you know what your DLL is https://github.com/assimp/assimp https://github.com/assimp/assimp/blob/master/Build.mdOn Tuesday, 28 September 2021 at 16:30:09 UTC, Eric_DD wrote:Nah :) Already tried that. It just swaps the file names in the error message.I am trying to use a newer version of Assimp. I have found a assimp-vc140-mt.dll (v3.3.1) which I renamed to assimp.dll When running my executable it throws a derelict.util.exception.SharedLibLoadException: "Failed to load one or more shared libraries: assimp.dll - %1 is not a valid Win32 application. Assimp64.dll - The specified module could not be found" Any idea what's going on? Are 64bit dlls not supported?try to rename it to Assimp64.dll
Sep 29 2021
On Tuesday, 28 September 2021 at 16:30:09 UTC, Eric_DD wrote:I am trying to use a newer version of Assimp. I have found a assimp-vc140-mt.dll (v3.3.1) which I renamed to assimp.dll When running my executable it throws a derelict.util.exception.SharedLibLoadException: "Failed to load one or more shared libraries: assimp.dll - %1 is not a valid Win32 application. Assimp64.dll - The specified module could not be found" Any idea what's going on? Are 64bit dlls not supported?I'm not maintaining the package anymore, but this is an error from the system loader and has nothing to do with the binding itself. It's the sort of error that usually pops up when trying to load a 32-bit DLL into a 64-bit program, or vice versa. Are you sure it's a 64-bit DLL?
Sep 28 2021
On Wednesday, 29 September 2021 at 02:47:09 UTC, Mike Parker wrote:On Tuesday, 28 September 2021 at 16:30:09 UTC, Eric_DD wrote:why my messages are not sent?I am trying to use a newer version of Assimp. I have found a assimp-vc140-mt.dll (v3.3.1) which I renamed to assimp.dll When running my executable it throws a derelict.util.exception.SharedLibLoadException: "Failed to load one or more shared libraries: assimp.dll - %1 is not a valid Win32 application. Assimp64.dll - The specified module could not be found" Any idea what's going on? Are 64bit dlls not supported?I'm not maintaining the package anymore, but this is an error from the system loader and has nothing to do with the binding itself. It's the sort of error that usually pops up when trying to load a 32-bit DLL into a 64-bit program, or vice versa. Are you sure it's a 64-bit DLL?
Sep 29 2021
On Tuesday, 28 September 2021 at 16:30:09 UTC, Eric_DD wrote:I am trying to use a newer version of Assimp. I have found a assimp-vc140-mt.dll (v3.3.1) which I renamed to assimp.dll When running my executable it throws a derelict.util.exception.SharedLibLoadException: "Failed to load one or more shared libraries: assimp.dll - %1 is not a valid Win32 application. Assimp64.dll - The specified module could not be found" Any idea what's going on? Are 64bit dlls not supported?If using dub you can build your D programs with dub -a x86 for a 32-bit executable dub -a x86_64 for a 64-bit executable (which is also the default thankfully). Your problem is very probably trying to load a 32-bit DLL into a 64 host program.
Sep 29 2021