If you think the Android project min3d listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package com.min3d;
//www.java2s.comimport android.graphics.PixelFormat;
import android.os.Bundle;
import android.view.View;
import com.min3d.lib.core.RendererActivity;
import com.min3d.lib.objectPrimitives.Box;
import com.min3d.lib.vos.Light;
/**
* Example of implementing a transparent GLSurfaceView.
*
* (a) Override glSurfaceViewConfig() to configure glSurfaceView for transparency as shown
* (b) Set the scene's backgroundColor to 0x00000000 (black with 0-alpha)
*
* If you were to place any 2D elements (images, etc) in the Activity "behind" glSurface,
* they would be now visible.
*
* In this example, instead of doing that, the Activity itself is set to transparent,
* allowing the underlying Activity to show through... (See the manifest xml --
* "android:theme="@android:style/Theme.Translucent.NoTitleBar")
*
* @author Lee
*/publicclass ExampleTransparentGlSurface extends RendererActivity
{
privatefinalint NUM = 25;
private Box[] boxes;
@Override
protectedvoid glSurfaceViewConfig()
{
// !important
_glSurfaceView.setEGLConfigChooser(8,8,8,8, 16, 0);
_glSurfaceView.getHolder().setFormat(PixelFormat.TRANSLUCENT);
}
@Override
publicvoid initScene()
{
// !important
scene.backgroundColor().setAll(0x00000000);
Light light = new Light();
scene.lights().add(light);
boxes = new Box[NUM];
for (int i = 0; i < NUM; i++) {
Box box = new Box(0.5f,0.5f,0.5f);
box.vertexColorsEnabled(false);
box.position().x = (float) (-1.5 + Math.random()*3);
box.position().y = (float) (-4 + Math.random()*8);
box.position().z = (float) (-1.5 + Math.random()*3);
box.rotation().x = (float) (Math.random()*360);
box.rotation().y = (float) (Math.random()*360);
boxes[i] = box;
scene.addChild(box);
}
}
@Override
protectedvoid onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
_glSurfaceView.setOnClickListener(
new View.OnClickListener() {
publicvoid onClick(View v) {
finish();
}
}
);
}
@Override
publicvoid updateScene()
{
for (int i = 0; i < NUM; i++) {
boxes[i].rotation().x += 2;
boxes[i].rotation().y += 1;
boxes[i].position().y -= .075;
if (boxes[i].position().y < -4) {
boxes[i].position().y = 4;
boxes[i].position().x = (float) (-1.5 + Math.random()*3);
boxes[i].position().z = (float) (-1.5 + Math.random()*3);
}
}
}
}