- Sort Posts
- 10 replies
- Last post

### How to get camera view vector / lookat vector

### How to get camera view vector / lookat vector

If you need to take into account the 3D model translation from the center of the trackable, you can modify the code as follows:

const QCAR::TrackableResult* result = state.getTrackableResult(tIdx); const QCAR::Trackable& trackable = result->getTrackable(); QCAR::Matrix44F modelViewMatrix = QCAR::Tool::convertPose2GLMatrix(result->getPose()); // Add this line to take into account 3D model translation from trackable center float my_translation_x = 10.0f; SampleUtils::translatePoseMatrix(my_translation_x, 0.0f, 0.0f, &modelViewMatrix.data[0]); QCAR::Matrix44F inverseMV = SampleMath::Matrix44FInverse(modelViewMatrix); QCAR::Matrix44F invTranspMV = SampleMath::Matrix44FTranspose(inverseMV);

where the my_translation_x is just an example of translation along the X-axis of the trackable (you can then use your own custom values, along X, Y and Z)

### How to get camera view vector / lookat vector

Thanks for so quick reply.

Correct me if I am wrong , I am new to this enenvironment--

But camera viewing direction is w.r.t. to tracker , what if I translate the model far from tracker then :

1) angle between camera vector and center of model

2) angle between camera vector and center of tracker

are different .

I want to find the camera vector looking toward model not tracker.

Thanks

### How to get camera view vector / lookat vector

You can definitely use that link:

https://developer.vuforia.com/resources/dev-guide/getting-camera-position

which actually explains what I was referring to and provides you the exact steps and code snippets; in particular, the **camera viewing direction** is the vector that you are looking for.

### How to get camera view vector / lookat vector

Hi,

Did you mean that we should multiply (0,0,1) with inverse of modelViewMatrix (ImageTarget) to get camera lookat vector w.r.t. rendered model ?

From the below link

https://developer.vuforia.com/resources/dev-guide/getting-camera-position

we can get camera viewing direction, camera right direction and camera up direction. Do we also need these vectors ?

Thanks

### How to get camera view vector / lookat vector

Hi, if you need to compute the camera vlookat vector in the model reference frame, you will need to:

- take the lookat vector defined in the camera reference frame, i.e. the vector whose XYZ components are (0, 0, 1)

- multiply this vector by the inverse of the modelview matrix that corresponds to the target pose.

Make sure that the model normal is defined in the same reference frame (i.e. the reference frame of the model) and that the 2 vectors are normalized, if needed.