By medabit
on Wed, 08/24/2016 - 21:06
hi,
i am trying to scale to fit a 3D plane to the cameras viewport(inside ARCamera)-like fullscreen.But sometime its getting offset either in xAxis or YAxis.Can some help ?
it works fine with the units inbuilt camera....but offset issues with the ARCamera
ARCamera settings : FOV 44.0014
near clip plane : 0.01
FAR : 5
below is the code....
Camera cam = Camera.main; float pos = (cam.nearClipPlane + 0.01f); Vector3 temp=cam.transform.position + cam.transform.forward * pos;
transform.position = temp;
float h = (Mathf.Tan(cam.fov*Mathf.Deg2Rad*0.5f)*pos*2f);
float yscale = ((h * cam.aspect)) * 1072 / 604;
transform.localScale = new Vector3(h*cam.aspect,yscale, 0f); transform.localRotation = Quaternion.Euler(0,0,0);