Author Topic: [Tips] Android, augmented reality 3D with JPCT + Camera.  (Read 49728 times)

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11771
    • View Profile
    • http://www.jpct.net
Re: [Tips] Android, augmented reality 3D with JPCT + Camera.
« Reply #30 on: December 21, 2010, 10:44:35 pm »
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... ;)

Offline androidman

  • byte
  • *
  • Posts: 14
    • View Profile
Re: [Tips] Android, augmented reality 3D with JPCT + Camera.
« Reply #31 on: May 16, 2011, 09:27:41 am »
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)?

 ???  ???  ???

Offline androidman

  • byte
  • *
  • Posts: 14
    • View Profile
Re: [Tips] Android, augmented reality 3D with JPCT + Camera.
« Reply #32 on: May 17, 2011, 07:31:58 am »
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?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11771
    • View Profile
    • http://www.jpct.net
Re: [Tips] Android, augmented reality 3D with JPCT + Camera.
« Reply #33 on: May 17, 2011, 09:13:30 am »
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?
« Last Edit: May 17, 2011, 09:18:53 am by EgonOlsen »

Offline androidman

  • byte
  • *
  • Posts: 14
    • View Profile
Re: [Tips] Android, augmented reality 3D with JPCT + Camera.
« Reply #34 on: May 18, 2011, 03:57:44 am »
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

 
Code: [Select]
    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);
       
    }

Offline androidman

  • byte
  • *
  • Posts: 14
    • View Profile
Re: [Tips] Android, augmented reality 3D with JPCT + Camera.
« Reply #35 on: May 24, 2011, 04:25:05 am »
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!  ???  :-\

Offline rhine

  • byte
  • *
  • Posts: 5
    • View Profile
Re: [Tips] Android, augmented reality 3D with JPCT + Camera.
« Reply #36 on: August 01, 2011, 09:15:17 pm »
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

Offline K24A3

  • long
  • ***
  • Posts: 231
    • View Profile
Re: [Tips] Android, augmented reality 3D with JPCT + Camera.
« Reply #37 on: September 28, 2011, 08:45:35 am »
Is there a way to play video to a Texture using the Android MediaPlayer API?

Code: [Select]
// 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();


Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11771
    • View Profile
    • http://www.jpct.net
Re: [Tips] Android, augmented reality 3D with JPCT + Camera.
« Reply #38 on: September 28, 2011, 11:11:47 pm »
I'm not sure. If you can make a texture a SurfaceHolder, then maybe...

Offline K24A3

  • long
  • ***
  • Posts: 231
    • View Profile
Re: [Tips] Android, augmented reality 3D with JPCT + Camera.
« Reply #39 on: September 29, 2011, 11:53:04 am »
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.

Offline Davi

  • byte
  • *
  • Posts: 33
    • View Profile
Re: [Tips] Android, augmented reality 3D with JPCT + Camera.
« Reply #40 on: October 30, 2011, 04:37:57 pm »
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?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11771
    • View Profile
    • http://www.jpct.net
Re: [Tips] Android, augmented reality 3D with JPCT + Camera.
« Reply #41 on: October 30, 2011, 08:02:31 pm »
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...

Offline Davi

  • byte
  • *
  • Posts: 33
    • View Profile
Re: [Tips] Android, augmented reality 3D with JPCT + Camera.
« Reply #42 on: October 31, 2011, 02:53:49 am »
what's different between  3d model transforming and world camera transforming? ???

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11771
    • View Profile
    • http://www.jpct.net
Re: [Tips] Android, augmented reality 3D with JPCT + Camera.
« Reply #43 on: October 31, 2011, 07:10:01 am »
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.

Offline AugTech

  • int
  • **
  • Posts: 64
    • View Profile
    • Augmented Technologies
Re: [Tips] Android, augmented reality 3D with JPCT + Camera.
« Reply #44 on: December 01, 2011, 01:12:18 pm »
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;

Code: [Select]
    setEGLContextClientVersion(2);
    setEGLConfigChooser(new AAConfigChooser(this));
    getHolder().setFormat(PixelFormat.RGBA_8888);

And then within the renderer onDrawFrame();

Code: [Select]
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.