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

Sceneform without camera feed #229

Closed marcos-dogonahorse closed 6 years ago

marcos-dogonahorse commented 6 years ago

Hi google team,

I know i asked this before but it seems it was misunderstood for "Sceneform without Arcore". I defiantly like that now we can use it on none ARCore supported devices but i really wanted was a way to use Sceneform without camera session. So if possible, using Sceneform on a regular GLSurfaceView or TextureView with openGL. I love the progress this library is having and the new features included on every release but i feel forcing Sceneform to be only used for AR is a bit to limited. I not expecting that sceneform would be the next 3D game engine for android(even if that would be super cool and hopefully that is the final direction this is going to) but i would love it to be a bit more open on where we can render the 3D model on. I can see this being used for stuff like Kia showing new Shelves and inventory without needing the device to have a camera(Example for tablet uses).

Thanks and looking forward to the next update,

dsternfeld7 commented 6 years ago

Thanks for your request! The use case you described is something we would like to support.

It should be possible to use Sceneform without a camera feed now. To do this, instead of using ArFragment or ArSceneView, you can use the class SceneView, which is a subclass of SurfaceView.

In your layout file, you would have this:

  <com.google.ar.sceneform.SceneView
      android:id="@+id/scene_view"
      android:layout_width="match_parent"
      android:layout_height="match_parent" />

and in your activity:

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_scene_view);
    sceneView = findViewById(R.id.scene_view);
  }

  @Override
  protected void onResume() {
    super.onResume();
    try {
      sceneView.resume();
    } catch (CameraNotAvailableException e) {
      throw new AssertionError("Failed to resume SceneView", e);
    }
  }

  @Override
  public void onPause() {
    super.onPause();
    sceneView.pause();
  }

  @Override
  public void onDestroy() {
    super.onDestroy();
    sceneView.destroy();
  }

You'll notice that onResume does catch a checked exception related to the camera. However, this is an API bug. SceneView does not make any calls into the camera and does not render the camera feed.

Also, Sceneform does have a maven dependency on ARCore that will still be pulled in when you use SceneView. However, no calls will be made into the ARCore SDK in this case. We are investigating removing this dependency when just using SceneView.

Does this help address what you are looking for?

marcos-dogonahorse commented 6 years ago

@dsternfeld7 Thank you so much for that suggestion. That worked and the model looks amazing on my screen :). Now just got to wait for Skeleton Animation :)

tomcat-bit commented 6 years ago

Is it possible to switch between a Sceneform camera feed and OpenGLES camera feed? The OpenGLES camera feed is implemented in the Hello_AR example project. I'd like to render the planes read from Sceneform in the functions in HelloArActivity.java. I think the problem is the fact that ArSceneView won't go entirely away. I always get exceptions on an OpenGL thread. Is there any way to completely destroy a Sceneform session and switch to an OpenGL rendering session in the same activity?

malik-at-work commented 5 years ago

Sceneform can't be combined with other access to OpenGLES. There is some more discussion of this at https://github.com/google-ar/sceneform-android-sdk/issues/169

yjoo9317 commented 5 years ago

@dsternfeld7 Thank you so much for that suggestion. That worked and the model looks amazing on my screen :). Now just got to wait for Skeleton Animation :)

@marcos-dogonahorse can you look at my question https://github.com/google-ar/sceneform-android-sdk/issues/431 I am trying to render 3d model on the view as you did here. But I am failing to do that. Thanks.