Hi,
I want to draw a rectangular mesh in front of my camera. For this i want to control its size and position in pixels.
This is what i have so far…
The position of this mesh is at the near clipping plane position + 0.0001f (so its not clipped by the camera).
The orientation is towards the camera.
Now i need the actual width and height of the near clipping plane so i can calculate the dimensions of my mesh.
Heej Eric… Thanx for you’re answer. But i’ve found another solution since i didn’t get your’s properly working…
I sat behind my screen scribbling on some paper and suddenly i saw it… Here is it…
Rect NearPlaneDimensions(Camera cam)
{
Rect r = new Rect();
float a = cam.nearClipPlane;//get length
float A = cam.fieldOfView * 0.5f;//get angle
A = A * Mathf.Deg2Rad;//convert tor radians
float h = (Mathf.Tan(A) * a);//calc height
float w = (h / cam.pixelHeight) * cam.pixelWidth;//deduct width
r.xMin = -w;
r.xMax = w;
r.yMin = -h;
r.yMax = h;
return r;
}
but if you have a better solution or faster/simpler then i realy lik to know…