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); scalePoseMatrix(kObjectScale, kObjectScale, kObjectScale, &modelViewMatrix.data); multiplyMatrix(&projectionMatrix.data, &modelViewMatrix.data, &modelViewProjection.data);
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:
- transpose rotational values of original matrix into matTranspose
- mat multiply: original matrix positional values by matTranspose to matResult
- use the matResult position values and overwrite the original matrix positional values
- 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
- Transpose original matrix
- Multiple original position values by transpose matrix
- 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.