google-ar / sceneform-android-sdk

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

How to anchor an indicator or pointer into scene follow geolocation? #711

Open ghost opened 5 years ago

ghost commented 5 years ago

How to add 2d view rather than 3d view without detection of plane, i know how to add 3d view by using viewRenderable.

I wish to create something like screenshot below. It like create icons and anchored them into the scene.

I have use ViewRenderable to create android 2d view in the 3d space. However, i want the 2d view stay as 2d view on the screen (something like location based AR)

https://developers.google.com/ar/develop/java/sceneform/create-renderables

Below is the code that allow me to add 2d view rather than 3d view.

arFragment = (ArFragment) getSupportFragmentManager().findFragmentById(R.id.scene_view);
arFragment.getPlaneDiscoveryController().hide(); arFragment.getPlaneDiscoveryController().setInstructionView(null);
arFragment.getArSceneView().getPlaneRenderer().setEnabled(false);

Node node = new Node();
node.setParent(arFragment.getArSceneView().getScene());
node.setEnabled(false);
node.setLocalPosition(new Vector3(0.0f, 100 * 5, 0.0f));

ViewRenderable.builder()
        .setView(this, R.layout.card)
        .build()
        .thenAccept(
                (renderable) -> {
                    node.setRenderable(renderable);
                    TextView textView = (TextView) renderable.getView();
                    textView.setText("planetName");
                })
        .exceptionally(
                (throwable) -> {
                    throw new AssertionError("Could not load plane card view.", throwable);
                });

Thanks in advance!

ghost commented 5 years ago

@nvictornvictor @tpsiaki I would like to request a geolocation feature for sceneform that allow to transfer real coordinates system to camera coordinates system and SLAM-Tracking.

suryanadiminti99 commented 5 years ago

I am using Sceneform 1.8.0 and OPENGL 3.2 . I have faced same issue . i am adding .sfb format animated models in my scene . It crashes sometimes . Not all the time .

ModelRenderable.builder() .setSource(this, Uri.parse("helicopter.sfb")).setRegistryId("helicopter.sfb").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; });