PDA

View Full Version : Switching to a new coordinate system

meryum
05-01-2016, 11:30 AM
Hello,

I am developing an android game using Vuforia, and I am having some trouble understanding how the "OpenGL matrix stuff" works.
So basically Vuforia let's you get the the pose matrix of a recognized object (that is converted to OpenGL format), relatively to the virtual camera.

In my situation I have two objects that I want to track using Vuforia.
To achieve this I need to pick one object to act as the world center, and bring the other object into its coordinate system.
A Vuforia tutorial suggests the code below to get the wanted result, but I could not get it to work properly.
I would like you to help me understand how this code "works", in order to have an insight into solving my main problem.

// mainModelViewMatrix : pose matrix of the first object (the main one)
// modelViewMatrix : pose matrix of the second object
// Vec4FTransform : does the multiplication of the matrices in parameter

QCAR::Matrix44F mainModelViewInverse = SampleMath::Matrix44FInverse(mainModelViewMatrix);
QCAR::Matrix44F modelViewTranspose = SampleMath::Matrix44FTranspose(modelViewMatrix); // let's work with row-major matrices
QCAR::Matrix44F offsetMatrix = QCAR::Tool::multiply(mainModelViewInverse, modelViewTranspose);

// Transform a point on the second target by this offset matrix
// (0, 0, 0) is the local center of the target
QCAR::Vec4F position(0.0f, 0.0f, 0.0f, 1.0f);
position = SampleMath::Vec4FTransform(position, offsetMatrix);

BBeck1
05-03-2016, 07:02 PM
I have some instructional videos on my YouTube channel "VirtuallyProgramming.com (https://www.youtube.com/watch?v=56v9BgwSzsg)". The first two cover Vectors and Matrices and are probably worth your time to go over. It might help quite a bit to understand. I hope to do some GLSL and OGL instructional videos in the not too distant future.