Community

Topic: Android SDK

Use Vector3 and Quaternion instead of Matrix to represent position and oreintation of 3d model

Francis Anyeji
Friday, February 2, 2018

Hello,
I noticed your sdk does not support 3d animation, I decided to use Rajawali 3D framework, which I added to the view by 'addContentView()'.
The problem is that rajawali uses Vector3 and quaternion to position Objects. I'm using this github link as a reference
https://github.com/Rajawali/RajawaliVuforia/blob/master/RajawaliVuforia/rajawalivuforia/src/main/java/org/rajawali3d/vuforia/RajawaliVuforiaRenderer.java
The positioning of the 3D animation doesn't work well, integrating rajawali with pikkart, i'm new to model View and projection matrix, so I guess i'm doing something wrong.
It might be too much to ask, but I really need it to work. I'll also like to know if there's a better way to render a 3D animation with pikkart.
Thanks

user profile image
Support Team  (expert)
Monday, February 5, 2018

Hi,
We have never tried integrating Rajawali3D with ou SDK, but the procedure should be similar to what we do in Unity.
First you have to multiply the pose matrix given to you by our SDK with an "alignment" matrix that rotate and mirror our frame of reference to that used by Rajawali3D.
In the case of Unity such a matrix is
B << -1, 0, 0, 0,
0, 0, 1, 0,
0, -1, 0, 0,
0, 0, 0, 1;
We then multiply that pose matrix with the inverse of the Unity's worldToCameraMatrix:
transformed_viewMatrix = cam.worldToCameraMatrix.inverse * viewMatrix;
After that the translation vector is the last column of the resulting matrix, the orientation matrix is the 3x3 upper left part, which can be easily transformed into a quaternion.

Sign in to add a comment