google-ar / sceneform-android-sdk

Sceneform SDK for Android
https://developers.google.com/sceneform/develop/
Apache License 2.0
1.23k stars 603 forks source link

GLTF object are grounding when loaded #551

Closed hemantkadamata closed 5 years ago

hemantkadamata commented 5 years ago

on loading GLTF files from the server, objects are not taking the origin but counting as position (0,0,0). but when the same file we check in blender all the objects are in correct order.

screenshot_20190211-234534_rederingwithoutar

bobekos commented 5 years ago

Please check your sfa file in particular the "recenter" attribute. If you want to export the original pos from the gtlf to the sfb this attribute should be set to false (more info).

hemantkadamata commented 5 years ago

@bobekos I am downloading the GLTF file and rendering it as I have multiple files which I can't include within the application

bobekos commented 5 years ago

Then you can set the recenter attribute through the "setRecenterMode" function before rendering. It is the same thing.

hemantkadamata commented 5 years ago

still the same, adding my code below let me know if I am doing anything wrong here.

hair_render = ModelRenderable.builder()
            .setSource(this, RenderableSource.builder().setSource(
                    this,
                    Uri.parse(hair_gltf),
                    RenderableSource.SourceType.GLTF2)
                    .setRecenterMode(RenderableSource.RecenterMode.NONE)
                    .build())

            .setRegistryId(hair_gltf)
            .build();
    body_render = ModelRenderable.builder()
            .setSource(this, RenderableSource.builder().setSource(
                    this,
                    Uri.parse(body_gltf),
                    RenderableSource.SourceType.GLTF2)
                    .setRecenterMode(RenderableSource.RecenterMode.NONE)
                    .build())

            .setRegistryId(body_gltf)
            .build();

    top_render = ModelRenderable.builder()
            .setSource(this, RenderableSource.builder().setSource(
                    this,
                    Uri.parse(top_gltf),
                    RenderableSource.SourceType.GLTF2)
                    .setRecenterMode(RenderableSource.RecenterMode.NONE)
                    .build())
            .setRegistryId(top_gltf)
            .build();

    CompletableFuture.allOf(
            body_render,
            top_render,
            hair_render)
            .handle((notUsed, throwable) -> {
              if (throwable != null) {
                DemoUtils.displayError(this, "Unable to load renderable", throwable);
                return null;
              }

              try {

                body = body_render.get();
                top = top_render.get();
                hair = hair_render.get();

                // Everything finished loading successfully.
                hasFinishedLoading = true;

              } catch (InterruptedException | ExecutionException ex) {
                DemoUtils.displayError(this, "Unable to load renderable", ex);
              }

              return null;
            });
dsternfeld7 commented 5 years ago

It looks like top_render may be missing the call to setRecenterMode in your code snippet

hemantkadamata commented 5 years ago

do we have any workaround or shall I try any other specific approach? sharing my GLTF file for reference. FBA.zip FBAgarment.zip FBAhair.zip

dsternfeld7 commented 5 years ago

Have you tried adding the call to setRecenterMode in the following code block?

top_render = ModelRenderable.builder()
            .setSource(this, RenderableSource.builder().setSource(
                    this,
                    Uri.parse(top_gltf),
                    RenderableSource.SourceType.GLTF2)
                    .build())

It looks like the other renderables have their recenter mode set but not this one.

hemantkadamata commented 5 years ago

@dsternfeld7 yes I have tried it, same is with the Hair Style too. My bad actually copying the code I guess I missed adding the setRecenterMode.

hemantkadamata commented 5 years ago

Hi All, is there any workaround for this bug till we have an update for the issue.

fredsa commented 5 years ago

For advice and general questions, please use the Sceneform tag on Stack Overflow: https://stackoverflow.com/questions/tagged/Sceneform

In addition, please see the Sceneform SDK developer documentation and API reference.

hemantkadamata commented 5 years ago

@fredsa Are you saying this is not a bug. but when I am using SFA and SFB and modifying the "recenter" attribute in SFA file as mention by @bobekos it works fine but the same is not for at runtime.

hemantkadamata commented 5 years ago

Guys any update on the bug