Log in or register to post comments

use model view matrix to show model on 3d engin

March 5, 2012 - 2:23pm #1

hi,

I am trying to show a model form the model view matrix using 3d engine.

I am doing this

mCameraARPosition = Vector3(-modelViewMatrix[12], modelViewMatrix[13] , modelViewMatrix[14])

at start my model was on (0,0,0);

and it's look like the model is not stabilized on the center of the image, like in the demo app when I moving the picture.
I also translate the model like the demo app

glTranslatef(0.0f, 0.0f, -kObjectScale);
            glScalef(kObjectScale, kObjectScale, kObjectScale);

it's seems to improve the stability of the model concerning to the picture. but it's still not enough stabilized on the center of the picture when moving (the picture).
if someone can help me, i need to understand how it work on the demo app. because the base of the teapot is not on (0,0,0), and i am assume that the center of the image is indeed on (0,0,0) on the imaginary world, so why it's look like it's realy sitting on the center of the image even from side look.
and why i need to

glTranslatef(0.0f, 0.0f, -kObjectScale);

if the base position is (0,0,0) and the scale not influence on it.

i hope i made my self clear, because it's hard to explain.
please help.

Re: use model view matrix to show model on 3d engin

March 10, 2012 - 1:15am #5

thanks kim,

it's realy was a problem of view port and FOV.
thanks a lot

Re: use model view matrix to show model on 3d engin

March 7, 2012 - 7:14am #4

Each target has its own coordinate system, with (0, 0, 0) at the center of the target. See this image: https://ar.qualcomm.at/resources/images/coordinateSystems.jpg

When you add a translation of the 3D content you are moving it from this center point. The vertices of our teapot model are centered around the origin of its own coordinate system, so it needs to be moved up the Z axis to sit on the target. That's why the samples do this:

SampleUtils::translatePoseMatrix(0.0f, 0.0f, kObjectScale,
                                 &modelViewMatrix.data[0]);
SampleUtils::scalePoseMatrix(kObjectScale, kObjectScale, kObjectScale,
                             &modelViewMatrix.data[0]);

The code above scales the teapot first and then moves it up by the scale amount. You could also just save your model so it is sitting on the origin (instead of centered on the origin).

Back to your original problem - this may be an issue with the viewport. The samples render to a viewport that is slightly larger than the screen, because the camera image aspect ratio doesn't typically match the screen aspect ratio. The size of the viewport is defined in the configureVideoBackground method in the native code (e.g. ImageTargets.cpp). Try setting your viewport to match.

- Kim

Re: use model view matrix to show model on 3d engin

March 7, 2012 - 2:03am #3

thanks for answer kim,
of course i use both. the rotation and the traslation of the matrix.
but it's seems to be that my object is not position exactly in the middle when I am moving the image. it's indeed moving in the right direction, and rotate well.
I am using ogre, and I can set projection matrix, but it's not helping, and I dont think it's the issue.

I need to understad to thing
1. what the position of the middle of the image in the imaginary world?
2. how the example app place the base of the teapot on the middle of the image if the base of the teapot is on an arbitrary point below zero, and why they do scale and translate.
thanks again.

Re: use model view matrix to show model on 3d engin

March 6, 2012 - 6:56pm #2

The modelview matrix contains both position and rotation info, you need to take both into account. It looks like you're only using the position here.

It will be easiest to use the projection matrix provided by QCAR along with the full modelview matrix. Does your 3D engine allow you to set the projection matrix?

- Kim

Log in or register to post comments