Hi all,
I don’t know how far the away the screen is.
I want to move my camera so that an object will perfectly align to the top of the screen but I don’t understand what to set my z to in a lookAt call to make it line up right given a certain frustrum.
For example (in Java OpenGL ES),
// Creating the perspective
float ratio = (float)width/(float)height;
gl.glFrustumf(-ratio,ratio,-1,1,4,28);
// The front face of my rectangular object is on the x,y plane
// and it’s top edge is at y=4.
// I want the top edge of it to align to the top
// of the screen. Since the near top is 1 and my object top
// is 4, I figured that I need my camera 4 times as far away
// as near to perfectly align. But…
// This doesn’t work because the camera is too far away
glu.GLUlookAt(0,0,16, 0,0,0, 0,1,0);
// This is real close, but I don’t know why this Z works nor
// do I understand how to derive it.
glu.GLUlookAt(0,0,10.44f, 0,0,0, 0,1,0);
Any help would be appreciated.
Regards,
Seed