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

Model size in Sceneform AR. #960

Open saadshahid310 opened 4 years ago

saadshahid310 commented 4 years ago

i'm working on my project using Sceneform to render models from server i'm having problem in loading models i need guidance about what should be the minimum and maximum size of model and which is more suitable sfb or gltf i don't have much time.

km4391 commented 4 years ago

Check the limits of the resize function in the video capture example to see

On Sun, Jan 5, 2020, 9:11 PM saadshahid310 notifications@github.com wrote:

i'm working on my project using Sceneform to render models from server i'm having problem in loading models i need guidance about what should be the minimum and maximum size of model and which is more suitable sfb or gltf i don't have much time.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/google-ar/sceneform-android-sdk/issues/960?email_source=notifications&email_token=AMKULX53YDE6JFRJ4TNCNULQ4KHMVA5CNFSM4KC6PZUKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IEDXWOA, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMKULX5FHGEYSLY3LG3ZIKTQ4KHMVANCNFSM4KC6PZUA .

saadshahid310 commented 4 years ago

Check the limits of the resize function in the video capture example to see On Sun, Jan 5, 2020, 9:11 PM saadshahid310 @.***> wrote: i'm working on my project using Sceneform to render models from server i'm having problem in loading models i need guidance about what should be the minimum and maximum size of model and which is more suitable sfb or gltf i don't have much time. — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#960?email_source=notifications&email_token=AMKULX53YDE6JFRJ4TNCNULQ4KHMVA5CNFSM4KC6PZUKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IEDXWOA>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMKULX5FHGEYSLY3LG3ZIKTQ4KHMVANCNFSM4KC6PZUA .

please attach the refrence i didn't get it

saadshahid310 commented 4 years ago

Hello sir, thank you very much for your kind response can you help me with this, https://github.com/google-ar/sceneform-android-sdk/tree/bb7d990305c1e4dba01fc031642c7bf18e79f050/samples/hellosceneform

i want to fetch models from server using this app and i cant figure out where to change. please help sir.

On Mon, Jan 6, 2020 at 8:07 AM Rocky Raccoon notifications@github.com wrote:

Check the limits of the resize function in the video capture example to see

On Sun, Jan 5, 2020, 9:11 PM saadshahid310 notifications@github.com wrote:

i'm working on my project using Sceneform to render models from server i'm having problem in loading models i need guidance about what should be the minimum and maximum size of model and which is more suitable sfb or gltf i don't have much time.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub < https://github.com/google-ar/sceneform-android-sdk/issues/960?email_source=notifications&email_token=AMKULX53YDE6JFRJ4TNCNULQ4KHMVA5CNFSM4KC6PZUKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IEDXWOA , or unsubscribe < https://github.com/notifications/unsubscribe-auth/AMKULX5FHGEYSLY3LG3ZIKTQ4KHMVANCNFSM4KC6PZUA

.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/google-ar/sceneform-android-sdk/issues/960?email_source=notifications&email_token=AN32QUOI4U3I7VWT6HIBIRLQ4KOAZA5CNFSM4KC6PZUKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIEI7VY#issuecomment-570986455, or unsubscribe https://github.com/notifications/unsubscribe-auth/AN32QUIQ36LFSCGPRTCWDV3Q4KOAZANCNFSM4KC6PZUA .

programmer35 commented 4 years ago

Here is what I use to do it. This is Kotlin and a kotlin extension I made. fyi, setRegistryId doesn't seem to do anything. I thought it was sort of a caching mechanism but it doesn't do anything, so I had to write my own caching files.

fun Context.buildModel(url: String): CompletableFuture<ModelRenderable> {
    val renderSrc = RenderableSource.builder()
        .setSource(this, Uri.parse(url), RenderableSource.SourceType.GLB)
        .setRecenterMode(RenderableSource.RecenterMode.ROOT)
        .build()

    return ModelRenderable.builder()
        .setSource(this, renderSrc)
        .setRegistryId(url)
        .build()
}

Call it using

private suspend fun loadModel(url: String) = suspendCancellableCoroutine<ModelRenderable> { c ->
        if (activity == null) {
            c.resumeWithException(Exception("Activity is not attached"))
            return@suspendCancellableCoroutine
        }
        activity?.apply {
            buildModel(url).thenAccept {
                if (c.isActive) {
                    c.resume(it)
                }
            }.exceptionally {
                loge("Failed to load Model for \n${url} with error message: ${it.message}", it)
                if (c.isActive) {
                    c.resumeWithException(it)
                }
                return@exceptionally null
            }
        }
    }

I am not related to Sceneform team, just been doing a lot of trial and error and work arounds to get things to work the way I need them to.