assimp icon indicating copy to clipboard operation
assimp copied to clipboard

Using on Android

Open DsVortex opened this issue 7 years ago • 11 comments

Hi when loading the library on android i get the following error.

Caused by: java.lang.ClassNotFoundException: Didn't find class "java.nio.file.Paths"

When i do this call.

        Importer importer = new Importer();
        AiScene scene = importer.readFile(new URI(path), 1 | 8);

DsVortex avatar Apr 01 '17 17:04 DsVortex

Are you using raw or assets?

elect86 avatar Apr 05 '17 14:04 elect86

Im doing something weird and i cant remember why...

AssetFileDescriptor assetFileDescriptor = assetManager.openFd("cube.obj");
FileDescriptor fileDescriptor = assetFileDescriptor.getFileDescriptor();
FileInputStream raw = new FileInputStream(fileDescriptor);
final File tempFile = File.createTempFile("cube", ".obj");
tempFile.deleteOnExit();
try (FileOutputStream out = new FileOutputStream(tempFile)) {
      IOUtils.copy(raw, out);
}

Model plain = new Model(tempFile.getAbsolutePath(), false);

Model just calls

Importer importer = new Importer();
AiScene scene = importer.readFile(new URI(path), 1 | 8);

DsVortex avatar Apr 05 '17 14:04 DsVortex

Try this

elect86 avatar Apr 06 '17 18:04 elect86

This Importer importer = new Importer().readFile(); doesnt support an input stream...

DsVortex avatar Apr 10 '17 07:04 DsVortex

So, apparently there are some classes, such as java.nio.files.*, that are not present on Android..

I am investigating for a solution...

Would you prefer loading your meshes from your res or assets folder?

elect86 avatar May 02 '17 14:05 elect86

Yea its a pain at times. Either, currently I'm trying use assets folder but either are fine.

DsVortex avatar May 02 '17 15:05 DsVortex

Ok, I am evaluating to make a branch for Android.

In the meanwhile, could you confirm me that the lenght you get on the files loaded from assets it's not UNKNOWN for you? If you test one of your assets file length, do you get the right size?

For reference

elect86 avatar May 02 '17 16:05 elect86

An update, I am planning to pass the AssetManager (retrievable via getAssets() from within the activity) to the readFile together with the path of the main file in order for assimp to read additional adjacent files. Is this compatible with your app?

elect86 avatar May 08 '17 11:05 elect86

You do as you see fit, I will modify my app to sit in with your changes. :-)

DsVortex avatar May 08 '17 13:05 DsVortex

Has there been a solution for this? We are using assimp-all.jar and are getting the Didn't find class "java.nio.file.Paths" error also. I don't see any AssetManager support in readFile() as of yet.

kurtzmarc avatar Nov 09 '18 22:11 kurtzmarc

Hi, unfortunately no.

I have a lot of other things with higher priority on my todo list right now and I also lack android experience: deadly combo.

However, we are totally open for contributions: this is the majoy point of this organization :)

If you want to help push the project forward, don't hesitate :)

elect86 avatar Nov 11 '18 12:11 elect86