Hi and thanks in advance to anyone who can help me or give me some suggestions.
I was working on the Google ARCore demo, specifically the "Hellosceneform
" one, where user can put a 3D model on a plane.
To test the import of different 3D assets, I changed the default "Andy" 3D model with another 3D model made by me, in the usual .sfb
format and I tested the demo on Android Emulator.
The problem is this:
raw
" directory into the demo works perfectly...appath
of 'sceneform
' demo) the ModelRenderable
(called andyRenderable
in my code) in onTapListener
is always null! More importantly: the demo works perfectly on a real phone, in both situation (raw
and device file system).
The code that loads the 3D asset is this:
File fsfb = new File(local_path + "/" + "prova3.sfb");
Uri usfb = Uri.fromFile(fsfb);
ModelRenderable.builder()
.setSource(this, usfb)
.build()
.thenAccept(renderable -> andyRenderable = renderable)
.exceptionally(
throwable -> {
Toast toast =
Toast.makeText(this, "Unable to load andy renderable", Toast.LENGTH_LONG);
toast.setGravity(Gravity.CENTER, 0, 0);
toast.show();
return null;
});
And the onTapListener code is this:
arFragment.setOnTapArPlaneListener(
(HitResult hitResult, Plane plane, MotionEvent motionEvent) -> {
if(nn >= 3 || andyRenderable == null)
{
return;
}
nn++;
Solved.
It was a matter of wrong permissions for the raw directory (it was impossible to load the model, it needed "rw
" settings).