I am trying to overlay a RajawaliSurfaceView
with the Earth Demo-Renderer over the Google Vision Face Tracker sample.
I use this to make the background transparent:
rajawaliSurfaceView.getHolder().setFormat(PixelFormat.TRANSPARENT);
This is the layout file of my activity:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:surfaceview="http://schemas.android.com/apk/res-auto"
android:id="@+id/topLayout"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:keepScreenOn="true">
<com.google.android.gms.samples.vision.face.facetracker.ui.camera.CameraSourcePreview
android:id="@+id/preview"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.gms.samples.vision.face.facetracker.ui.camera.GraphicOverlay
android:id="@+id/faceOverlay"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</com.google.android.gms.samples.vision.face.facetracker.ui.camera.CameraSourcePreview>
<org.rajawali3d.surface.RajawaliSurfaceView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/rajawali_surface"
android:layout_gravity="left|top" />
</FrameLayout>
It compiles without a problem, but I do not see the 3d model or the FaceGraphic from the Google Demo project. I also get this error when trying to preview the layout xml in Android Studio:
java.lang.NullPointerException
at android.opengl.GLSurfaceView.onResume(GLSurfaceView.java:562)
at org.rajawali3d.surface.RajawaliSurfaceView.onResume(RajawaliSurfaceView.java:106)
at org.rajawali3d.surface.RajawaliSurfaceView.onVisibilityChanged(RajawaliSurfaceView.java:116)
at android.view.View.dispatchAttachedToWindow(View.java:14537)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2843)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2843)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2843)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2843)
at android.view.AttachInfo_Accessor.setAttachInfo(AttachInfo_Accessor.java:42)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:232)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:426)
at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:350)
at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:510)
at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:498)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:888)
at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:498)
at com.android.tools.idea.rendering.RenderTask.access$600(RenderTask.java:72)
at com.android.tools.idea.rendering.RenderTask$3.call(RenderTask.java:610)
at com.android.tools.idea.rendering.RenderTask$3.call(RenderTask.java:607)
at com.android.tools.idea.rendering.RenderService.runRenderAction(RenderService.java:366)
at com.android.tools.idea.rendering.RenderTask.render(RenderTask.java:607)
at com.android.tools.idea.rendering.RenderTask.render(RenderTask.java:629)
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.doRender(AndroidLayoutPreviewToolWindowManager.java:652)
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.access$1700(AndroidLayoutPreviewToolWindowManager.java:80)
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$7$1.run(AndroidLayoutPreviewToolWindowManager.java:594)
at com.intellij.openapi.progress.impl.CoreProgressManager$2.run(CoreProgressManager.java:152)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:452)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:402)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:54)
at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:137)
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$7.run(AndroidLayoutPreviewToolWindowManager.java:589)
at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:320)
at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:310)
at com.intellij.util.ui.update.MergingUpdateQueue$2.run(MergingUpdateQueue.java:254)
at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:269)
at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:227)
at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:217)
at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238)
at com.intellij.util.Alarm$Request$1.run(Alarm.java:351)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
UPDATE 1:
I removed this line (rajawaliSurfaceView.getHolder().setFormat(PixelFormat.TRANSPARENT);
), hoping to see the 3d scene at least, but nothing changed, I still only see the camera preview.
However, when resuming the app from anywhere I see the rotating earth for the fraction of a second, before the camera preview is started.
According to this answer, it should work as I expected it to. What do I have to do?
UPDATE 2:
(using this tutorial)
OK - Adding the line rajawaliSurfaceView.setZOrderOnTop(true);
renders the 3d scene on top of my camera preview, but I still have a problem.
Neither
rajawaliSurfaceView.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
rajawaliSurfaceView.getHolder().setFormat(PixelFormat.TRANSLUCENT);
nor
rajawaliSurfaceView.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
rajawaliSurfaceView.getHolder().setFormat(PixelFormat.RGBA_8888);
only clear the background of the scene. I allways get a fully transparent SurfaceView. Any ideas how I can resolve this?
(Apparently the xml error only seems to be a mild anoyance I'll have to ignore.)