Log in or register to post comments

modelViewProjection matrix rotational / position issues

November 4, 2011 - 10:49am #2

I'm having an issue with the 3D renderer that I'm trying to integrate into QCAR.

I'm passing the resulting modelViewProjection to my renderer that was derived like the ImageTargets example

translatePoseMatrix(0.0f, 0.0f, kObjectScale, &modelViewMatrix.data[0]);
scalePoseMatrix(kObjectScale, kObjectScale, kObjectScale, &modelViewMatrix.data[0]);
multiplyMatrix(&projectionMatrix.data[0], &modelViewMatrix.data[0], &modelViewProjection.data[0]);

The issue I'm having is that when I rotate the camera, the model doesn't stay attached to the target - it rotates incorrectly in the wrong directions. Also, it is like the axis isn't down the center of the model, so when the model rotates it rotates off-center.

I tried first just sending the modelViewProjection to the renderer.

Next I tried doing what I did to solve this in my previous application with another AR package by doing the following to the modelViewMatrix, but it isn't working here sending the modelViewProjection or the modelViewMatrix:

  1. transpose rotational values of original matrix into matTranspose[16]
  2. mat multiply: original matrix positional values by matTranspose to matResult
  3. use the matResult position values and overwrite the original matrix positional values
  4. use original matrix with new position values to position the model

On my third try, I'm getting a bit closer, the rotation is almost there - stays static, but the model position moves in the opposite direction than expected (negating doesn't work)

modelViewMatrix works best with this, but modelViewProjection gets close

  1. Transpose original matrix
  2. Multiple original position values by transpose matrix
  3. Use result for rotation and position. negate x position.

Any ideas for the right combination of transpose / multiply / which rotational / which positional / etc to use?

Also, should I be trying to use the modelViewMatrix or modelViewProjection? modelViewMatrix seems to be getting it closer right now for me.

Re: modelViewProjection matrix rotational / position issues

November 4, 2011 - 11:10am #1

Hi zakharm, I don't believe you should be doing anything but the example you give.

It sounds like something else is applying a further rotation/reflection.

My first two thoughts are:

1) Have you lost the 90 degree rotation of the view somewhere along the line? Although I think that would cause the whole view to just be 90 degrees out though and distorted, but with the camera view and augmentation still bound together.

2) Are you applying some other viewport or translation within your own model? It sounds like a relection of some kind.

Log in or register to post comments