Hi All,
I am working on some prototypes for Android using
ARCore and OpenGL 2.0 ES
Here is a problem I am trying to solve, but got stuck. I have two points (on the same plane, so same y-coordinate) created by a screen taps. Each point is describes as
Pose, which means I can get its ModelMatrix and rotation information. Since each point is different and was added independently, they will have different Pose and rotation matrices. Typically, when Pose is added, the object is facing the camera. So it can be said that both points are facing the camera.
Lets say one point is A, the other one is B. Now I have vector AB = B - A. And I need to place and object C that is facing the same direction as vector AB.
When I place an object with a tap, it creates and
Anchor, which contains the Pose. Again, Pose is just Model->World transform. But the default behavior, is to make the placed object face the camera. I don't need the object to face the camera. I need to create Model->World transform such that the object C will be facing same direction as AB vector.
Is there a way to create a rotation, know only the direction vector? Since both vector AB and object C are on the same plane, the problem can be reduced from 3D to 2D.
Would appreciate any help!
View and Projection matrices are obtained from
Camera object.
Full transform is as follows:
gl_Position = Proj from Camera object * View from Camera object * ModelMatrix from Pose object * vertex