Log in or register to post comments

Native renderFrame + java 3d rendering possible?

March 18, 2012 - 12:36pm #1

Hi,

I'm trying to bypass the native 3d object rendering, and move it over to the java onDrawFrame(GL10 gl) method. I'm trying to get min3d do the rendering (no lighting orfancy stuff, just obj models), but let QCAR do the video frame rendering. I tried drawing a square on the java side after the native renderFrame method, but with no luck (i'm guessing after renderFrame() is finished, it's not possible to draw on the surfaceView without commenting out some code from the native side).

Can anyone tell me if this is possible? If yes, which native renderFrame code should I comment out?

Thanks!!
Paul

Re: Native renderFrame + java 3d rendering possible?

March 26, 2012 - 5:44am #3

Thanks for the reply! But i've taken a lazier route to solve this problem.. for those who might need it:

I've created a surfaceView on top of the qcar surfaceView, which min3d will draw to. I've struggled to get the models into the correct position on top of the rendered markers using min3d camera/object position vectors but with no luck, especially using the modelview matrix from native code. What i've done is bypassed the min3d "convenience layer", if i can call it that, and just went directly into the Render class, and replaced the object draw code:

pushmatrix
...
_gl.glTranslatef($o.position().x, $o.position().y, $o.position().z);
_gl.glRotatef($o.rotation().x, 1,0,0);
_gl.glRotatef($o.rotation().y, 0,1,0);
_gl.glRotatef($o.rotation().z, 0,0,1);

_gl.glScalef($o.scale().x, $o.scale().y, $o.scale().z);
...
popmatrix

with :
(copied from imagetargets.cpp)

_gl.glMatrixMode(GL10.GL_PROJECTION);
_gl.glLoadMatrixf(projectionMatrix, 0); // projection taken from imagetargets.cpp

_gl.glMatrixMode(GL10.GL_MODELVIEW);
_gl.glLoadMatrixf(modelviewMatrix, 0); // matrix taken from imagetargets.cpp pose
_gl.glTranslatef(0.f, 0.f, objScale);
_gl.glScalef(objScale, objScale, objScale);

(dont forget to comment out push/pop matrix calls)

And it worked! min3d now renders the 3d object correctly on top of the marker. This is a bit of a hack, but it can be edited into something prettier, which I don't have the time to do. The app performance is acceptable (probably because i'm using a Galaxy Nexus) so I'm happy.

Hope this helps someone..
Paul

Re: Native renderFrame + java 3d rendering possible?

March 18, 2012 - 7:13pm #2

I've never tried this. I think in theory it should work, what are you using in terms of projection and modelview matrices? If you can provide a code snippet I can help debug.

- Kim

Log in or register to post comments