[Tips] Android, augmented reality 3D with JPCT + Camera.

Started by dl.zerocool, May 11, 2010, 08:06:35 PM

Previous topic - Next topic

EgonOlsen

They are hardly comparable IMHO. I had a discussion about some kind of coorperation with the libGDX guys and i'm still thinking of using their buffer related stuff as an option for jPCT-AE once vertex updates become a problem. However, i'm not sure if this is the right place to ask this question... ;)

androidman

Hi everyone.

This example use FrameLayout to display 2 layout, but they are still in the same activity. How can we make the same thing with 2 activity (the top one has transparent background)?

???  ???  ???

androidman

In my project, i display some 3D models with GLSurfaceView and i use a transparent background SurfaceView on the top to display a small 2D picture on the screen. The problem is the 2D picture cannot display when all 3D models were displayed. If i set invisible for some 3D models, the 2D picture is showned. Is it a memory or framebuffer problem?

EgonOlsen

#33
No idea. Personally, i feel that combining OpenGL output with some GUI components is asking for trouble, but maybe i'm just a bit old fashioned here. Do you have a screen shot that shows the problem?

androidman

Hi EgonOlsen

i checked my project again. Now, i will descript more detail:
- I used FrameLayout to display a SurfaceView and a GLSurfaceView with SurfaceView is on the top.
- On my test project, everything was fine.
- On my main project, everything works, except SurfaceView cannot display on the top. The differrent thing bettwen the test project and the main project is in the main project , glSufaceView must take a long time to load resources. When i try to set transparenct background for glSurfaceView, i can see a part of SurfaceView at black color areas on glSurfaceView.
- The main project is fine on emulator but on IS03, Nexus I


    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        SCREEN_WIDTH=getWindowManager().getDefaultDisplay().getWidth();
        SCREEN_HEIGHT=getWindowManager().getDefaultDisplay().getHeight();
       
       requestWindowFeature(Window.FEATURE_NO_TITLE);
       this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
       
       fLayout= new FrameLayout(getApplicationContext());
       
       glSurfaceView =  new GLSurfaceView(getApplication());
       glSurfaceView.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
       glSurfaceView.getHolder().setFormat(PixelFormat.TRANSLUCENT);
   

       renderer= new RendererImplement();
       renderer.loadTextures(getResources());
       glSurfaceView.setRenderer(renderer); 
       
       
       screenSurface= new mySurfaceView(getApplicationContext());
       screenSurface.getHolder().setFormat(PixelFormat.RGBA_8888);
       


       fLayout.addView(screenSurface);
       fLayout.addView(glSurfaceView);
       

       setContentView(fLayout);
       
    }

androidman

uhm, I think this is an unknown error when put a surfaceView on the top of a GLSurfaceView. I used a View instead of SurfaceView and eveything is ok with the same code!  ???  :-\

rhine

I saw some really nice AR demos this summer at Uplinq. Curious to see if many game devs will utilize this technology especially as device hardware quality/performance improves.

I am thinking of creating an AR-based game next year once I launch my first game.

BTW, its nice to finally be on this forum. Looking forward to developing with JPCT-AE

K24A3

Is there a way to play video to a Texture using the Android MediaPlayer API?


// Load video
MediaPlayer mediaPlayer = MediaPlayer.create(m_context, R.raw.videofile);

// Somehow attach the output to a texture
SurfaceHolder sh = ??? (Texture Surface)
mediaPlayerVid.setDisplay(sh);

// Play video
mediaPlayer.start();


EgonOlsen

I'm not sure. If you can make a texture a SurfaceHolder, then maybe...

K24A3

I can't seem to find a way to do it, at least efficiently.

GLSurfaceView has a getHolder() function that retrieves the SurfaceHolder.

Perhaps MediaPlayer can render to the OpenGL surface directly?

I tried using mGLView.getHolder() but it crashes. I have yet to check the exception error string but it appears that you need to use callback functions since the GL object runs in a different thread.

Davi

How to make the 3D model transform correctly  with AR marker?
I can get the changing  transform matrix,I want to make this transform matrix work with my jpct-ae model.
how to do?do with camera position matrix  or model itself transform matrix?

EgonOlsen

This thread contains code to setup your Activity at the beginning as well as code that sets the rotation of the world based on the sensor data (http://www.jpct.net/forum2/index.php/topic,1586.msg11938.html#msg11938). It should actually be sufficient...

Davi

what's different between  3d model transforming and world camera transforming? ???

EgonOlsen

Object/model space is the space in which the object itself is in after loading. World space is the space, in which it will be transformed based on it's rotation/translation/... matrices and camera space is the space where it's positioned relative to the camera assuming that the camera is fixed at 0,0,0 looking down z. Think of a camera transformation not as if you were actually moving your head around but as if the world moves around your head, because that's what basically happens in 3D graphics.

AugTech

A quick query, or a bug...!

I am doing some of the same as within this thread, but have opted for using the AAConfigChooser as it makes my scene look a lot nicer, but I've lost the transparency so therefore cannot see the camera preview (except on areas of textures!)

In the SurfaceView;


    setEGLContextClientVersion(2);
    setEGLConfigChooser(new AAConfigChooser(this));
    getHolder().setFormat(PixelFormat.RGBA_8888);


And then within the renderer onDrawFrame();


frameBuffer.clear(new RGBColor(0,0,0,0));
theWorld.renderScene(frameBuffer);
theWorld.draw(frameBuffer);
frameBuffer.display();


Does AAConfigChooser() support transparent background, and if so, how?

Incidentally, I have tried PixelFormat.TRANSLUCENT within the SurfaceView to no effect.

thanks.