Bbpzz / min3d

Automatically exported from code.google.com/p/min3d
0 stars 0 forks source link

Background transparent in insidelayout example #27

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I've created a simple project of ExampleInsideLayout but I don't know how to 
set the background transparent.

I put:
scene.backgroundTransparent();
_cube = new Box(1,1,1);
_cube.colorMaterialEnabled(true);

scene.addChild(_cube);

but the background appears black.

Original issue reported on code.google.com by fribell on 8 Jan 2011 at 3:12

GoogleCodeExporter commented 8 years ago
Look at how Scene.java works. Min3D uses some coding conventions that are not 
as you learned it in your SCJP-classes ;) It's more related to action script 
where there are explicit getters and setters available.

scene.backgroundTransparent(true); Should do the trick.

(I would vote to change Min3D to use getBackgroundTransparent() and 
setBackgroundTransparent(boolean b) btw.)

Original comment by LWanders...@gmail.com on 18 Jan 2011 at 6:20

GoogleCodeExporter commented 8 years ago
I'm also trying to get background transparency to no avail.
Changing the ExampleInsideLayout initScene() to:
        scene.lights().add(new Light());

        scene.backgroundColor().setAll(0xff444444);
        scene.backgroundTransparent(true);
        _cube = new Box(1,1,1);

should surely have made it transparent, but instead it just renders on a black 
background instead of the background colour. To test this I added backgrounds 
to R.drawable.listActivity (the root) and to the LinearLayout across the middle 
of the layout.

Is there a way to let the backdrop texture show through? It's what we need in 
my game.

Thanks for any help!

Original comment by spiran...@gmail.com on 20 Jan 2011 at 10:20

GoogleCodeExporter commented 8 years ago
Hi, I've added a 'recipe' demonstrating transparency in 
min3dSampleProject1/ExampleTransparentGlSurface.java.

For device compatibility reasons, I'm reluctant to create the functionality for 
transparency thru a single simple method call, but hopefully this will suffice.

BTW, the Scene.backgroundTransparent() getter and setter got removed, since its 
name was a little misleading and it didn't add any useful functionality on its 
own.

Original comment by l...@felar.ca on 21 Feb 2011 at 6:03

GoogleCodeExporter commented 8 years ago
Greetings, I have been attempting to implement a translucent glsurfaceview over 
an image background for a while now without success.  I'd also like a few 
widgets (buttons, textviews, etc) on top of the glsurfaceview.

In ExampleTransparentGlSurface.java the comment says its possible, how is this 
accomplished?  Would you give an example?

I've attempted several variations of the following:

# ExampleTransparentGlSurface.java
protected void onCreateSetContentView()
{
    setContentView(R.layout.transparent_layout);
    ((LinearLayout)findViewById(R.id.surface_holder)).addView(_glSurfaceView);
}

protected void glSurfaceViewConfig()
{
    _glSurfaceView.setEGLConfigChooser(8,8,8,8, 16, 0);
    _glSurfaceView.getHolder().setFormat(PixelFormat.TRANSLUCENT);
}

public void initScene() 
{
    scene.backgroundColor().setAll(0x00000000);
}

# transparent_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:layout_height="fill_parent">

    <!-- Background Image -->
    <ImageView android:layout_width="fill_parent"
        android:layout_height="fill_parent" android:src="@drawable/earth" />

    <!-- Holds Gl Surface View -->
    <LinearLayout android:layout_height="fill_parent"
        android:layout_width="fill_parent" android:id="@+id/surface_holder" />

    <!-- Widgets, etc. should be on top of 3d environment -->
    <Button android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:text="This is a big button" />

</FrameLayout>

Original comment by ArturoTh...@gmail.com on 23 Feb 2011 at 7:10

Attachments:

GoogleCodeExporter commented 8 years ago
Hi, i have the same issue with Background transparency; does anyone found a 
solution to fix this? , 
It worked for me when i used a SurfaceView in background but not over an image 
background, my code is almost the same as "ArturoTh...@gmail.com"

Original comment by unknown....@gmail.com on 8 Jul 2011 at 9:13

GoogleCodeExporter commented 8 years ago
it worked for me that way:
@Override 
    protected void glSurfaceViewConfig()
    {
        _glSurfaceView.setEGLConfigChooser(8,8,8,8, 16, 0);
        _glSurfaceView.getHolder().setFormat(PixelFormat.TRANSLUCENT);
        _glSurfaceView.setZOrderOnTop(true);
    }

public void initScene()
    {

        scene.backgroundColor().setAll(0, 0, 0, 0);
//rest of your code
}

Original comment by mate...@gmail.com on 18 Oct 2011 at 12:35

GoogleCodeExporter commented 8 years ago
it worked for me that way:
@Override 
    protected void glSurfaceViewConfig()
    {
        _glSurfaceView.setEGLConfigChooser(8,8,8,8, 16, 0);
        _glSurfaceView.getHolder().setFormat(PixelFormat.TRANSLUCENT);
        _glSurfaceView.setZOrderOnTop(true);
    }

public void initScene()
    {

        scene.backgroundColor().setAll(0, 0, 0, 0);
//rest of your code
}

Original comment by mate...@gmail.com on 18 Oct 2011 at 12:48

GoogleCodeExporter commented 8 years ago
hey explain to me how to do exactly? I've never used <! - Holds Gl Surface View 
-> 
<LinearLayout android: layout_height = "fill_parent" 
android: layout_width = "fill_parent" android: id = "@ + id / surface_holder" 
/> 

I just object and I want to put a button ...

Original comment by braniste...@gmail.com on 11 Feb 2014 at 3:19