In the Android project, how to set the glsurfaceview of jme3 to be transparent and display the Android components of the gland

Other areas of the glsurfaceview of the model can pass through the background color of the relative layout

I use jme3 3.3.2-stable in android studio

Anyone who has experience in this field can give us some advice. Thank you very much :blush:

1 Like

In the JmeFragment that extends AndroidHarnessFragment you need to set eglAlphaBits = 8;. Does that help for you? In the AndroidHarnessFragment this property is explained:

  * Sets the desired number of Alpha bits for the surfaceview.  This affects
     * how the surfaceview is able to display Android views that are located
     * under the surfaceview jME uses to render the scenegraph.
     * 0 = Opaque surfaceview background (fastest)
     * 1->7 = Transparent surfaceview background
     * 8 or higher = Translucent surfaceview background
     * (default = 0)

And not sure, but you might also need to add this in your Jme Application:

viewPort.setClearFlags(true, true, true);
viewPort.setBackgroundColor(new ColorRGBA(0f, 0f, 0f, 0f));

In the constructor, I set the this.eglAlphaBits = 8;
In the oncreateview function, set the view.setZOrderOnTop (false);
Set the viewport’s background 0, 0, 0, 0 in the app class
No effect
FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
mBloom = new BloomFilter( BloomFilter.GlowMode.Objects );
mBloom.setBlurScale (3);
FXAAFilter filter = new FXAAFilter();
fpp.addFilter (mBloom);
fpp.addFilter (filter);
//4X anti aliasing
fpp.setNumSamples (6);
viewPort.addProcessor (fpp);

if no Filter to viewport,and no set the view.setZOrderOnTop (false);
glsurfaceview can pass through the background color of the relative layout
but no anti aliasing,The effect of the model is not good
and Glsurfaceview will cover the interface layout of Android

I don’t know how to make it right~~~

I have developed a library that makes you able to run jme renderer on a GlSurfaceView then the result would take you to a cardView component , that you can use in xml regularly (as if it’s a button) on a RelativeLayout & avoid the pain of jmeFragment

A splash screen of your selection & your delay + finish listeners :

The current progress :

What you can do , if you use it now , notice the GUI not the game :

All the controls on this pic are Android views without a performance loss(except for the last pic , the speedometer & the tachometer are 2DTex & Lemur).

Check it here , check the example , because i havenot yet made the wiki…:


How to use it in java :

The drivingWheel isnot yet updated , but the GameStick ,Speedometer are stable now , & you can have a SplashScreen now with the delay you specify ( well , this basically donot delay jme renderer , but it renders jme game asynchronously & then commands the jmeRenderer(GLThread) to join the UI thread after this period.

In a couple of days around , i will create a separate thread post for this , describing it in more depth , but for now , you can refer to the demoApp module inside this repo , & i will help if you find something wrong .

1 Like

I try your JmESurfaceView ,it‘s looks not good,The display effect is completely different from using jme3 fragment directly. The loaded model rotates in circles on the screen. Then, after the interface migration (Android studio project), the whole interface is confused. The level of the interface is incorrect. The destroyed interface will be displayed on the screen except jmesurfaceview area. I think the canvas is confused. I added it in the way of the example. I don’t know what causes this phenomenon

Could you please show me an image illustrating ?

Edit : you can show me your code (activity code & jme code ) , remember if you didnot do :

jmeSurfaceView.setJmeGame(simpleApp: SimpleApplication);

You will obviously have a black screen(broken).

Today , I will release new version & I will add test case for easy manipulation , because the demoApp module seems very messy.

yes,My code is modelled on demoapp
The current results are as follows:
The screenshot of fragment effect using jme3 is as followsjme3fragment
The effect of using jmesurfaceview is as follows:

The model is rotating all the time. I don’t know why it is rotating all the time. There is no model rotation set

set JMESurfaceView:
jmesurfaceview.setSimpleApplication(new JME3DViewMain());

Please help to see if this phenomenon is caused by my improper use. Thank you very much

1 Like

Hi @YHKing101

if you havenot modified the JmeSurfaceView class by extending it , this will be

jmeSurfaceView.setJMEGame(simpleApplication : SimpleApplication);

But this doesn’t actually matter as long as you arenot getting NPEs or crashes.

This is not a bug , your screen is in PORTRAIT MODE :grin: as default for android activities , just make sure you set the attribute of android:screenOrientation to landscape mode.


Inside your activity tag in AndroidManifest.xml file , it basically fixes out your screen into LANDSCAPE , or enable your auto rotation in your emulator .

I USE [Night God simulator(夜神模拟器 NOX)] ,and set【android:screenOrientation=“landscape”】,The effect of setting the horizontal screen state is the same

I use 【mumu simulator(网易mumu模拟器)】,and no set【android:screenOrientation=“landscape”】The effect is correct

I think I need to replace the debugging simulator

thank you very much~~~

If I use jmesurfaceview, can I use JME engine to render models in multiple interfaces in an ordinary Android project?

Sorry , can you explain more ?


Use genymotion emulator it’s better & lightweight & directly connected to android studio through genymotion device manager :

If you mean using multiple Jme Renders or multiple Jme games at the same screen , ofc you can , but seriously , i didnot try , all right here’s the steps for testing this out , but remember it will lead to performance drop down if you have heavy scenes :smile: :

Steps to do multiple rendering on android using JmeSurfaceView :

  • Create an activity
  • add <LinearLayout> .... </LinearLayout> in your activity design stack , setting the orientation:"vertical" which means components are separated vertically.
  • add 2 tags <com.scrappers.SuperiorPlugin.jmeSurfaceView.JmeSurfaceView> ... </com.scrappers.SuperiorPlugin.jmeSurfaceView.JmeSurfaceView> there you are , each one must have different id.
  • navigate to your & there do the code 2 times one for the 1st jmeSurfaceView component & the 2nd for the second one ( 2 different instances) , & you are done , post the results with you test & experience here please.

TIPS : you can do an array of JmeSurfaceView that holds 2 instances & loop over to minimize code , also you could set the same jme game for both for testing purposes.

It is an Android simulator provided by Netease

1 Like

its okay , if its working but itsnot officially supported by android developers google.

thank you very much~~~
If JME engine provides something like Rajawali, creating surface view dynamically for engine, of course, I don’t know the source code, ha ha ha

This is not a surface view it’s multiple camera views technique , technically multiple JmeSurfaceView means multiple games in the same monitor , this is not good.