- Home /
Limiting rotation along Y axis in vuforia
I am working on an Augmented reality project where in my focus is on a vertical plane placed on a target image that rotates along with the viewing camera.The target image is the marker. I want to make it in such a way that the surface of the plane looks the same from all viewing angles.i.e whichever direction I turn to, the surface of the plane facing the camera should be visible.I am new to vuforia.Need some help please
It is unclear how you have things setup. For most basic setups, the camera is moved, not the object. So make your 'vertical plane' using a Unity Quad. Then you can just set the rotation of the Quad to the rotation of the camera.
Okay.So its like this. I have a plane that plays a sequence of images like an animation. Assume a user moves with this mobile camera while focusing the marker.The animation would start playing as soon as the marker is detected.This part works fine. I need to ensure that the surface of the plane showing the animation always faces the camera.So how do I tweak the rotation for this part?
Answer by robertbu · Nov 06, 2014 at 03:22 AM
First, use a Quad, not a Unity Plane to display the animation. You will need a reference to the camera's transform. Using this reference, in a script on the Quad you can do:
transform.rotation = camTrans.rotation;
If you want the Quad to remain upright but align itself with the camera the best it can, you can do:
var dir = camTrans.forward;
dir.y = 0.0;
transform.rotation = Quaternion.LookRotation(dir);
Thank you so much for your suggestion. But I would also like to know what would be the difference between using a Quad and a plane to play the image sequences
In terms of playing, there is no difference. A Quad has 4 vertices and 2 triangles. A plane has 121 vertices and 200 triangles. So you save some memory using a Quad. But the real difference is orientation. A quad with a rotation of (0,0,0) is vertical, faces (i.e the side that displays) negative 'z'. A plane with rotation of (0,0,0) faces upwards. Having a vertical Quad makes calculating the rotation easy. Getting the rotation of a Plane right is harder. Often the easiest solution for a Plane is to use an empty game object to make the rotation like a Quads default rotation.