Frustum setup with physical screen coordinates + eye
No replies to this topic
Members - Reputation: 560
Posted 06 July 2011 - 03:33 PM
(reposted/moved from OpenGL forum... more appropriate here, I think)
Hi everyone, I'm trying to ultimately do something similar to the Johnny Lee headtracking demo, where I want to use the center of the actual screen as the world origin, and I want my "camera" eyepoint to correspond to the user eye position in the real world (in the physical display's coordinate system). Initially, I am just trying to set up a more "traditional" on-axis frustum using eye position and screen dimentions... I am using OGL so this is a right-handed coordinate system looking down neg Z axis...
I setup my projection matrix with a frustum like below
left = -SCREEN_WIDTH_IN_MM / 2.f;
right = SCREEN_WIDTH_IN_MM / 2.f;
bottom = -SCREEN_HEIGHT_IN_MM / 2.f;
top = SCREEN_HEIGHT_IN_MM / 2.f;
near = eyePos.Z - 0.01;
far = eyePos.Z + 1000.f
My view matrix is just translating by -eyePos.
My understanding was that this would provide a view frustum such that anything that sits at z=0.0 (basically, a hair behind the near clip plane) would be displayed in the same position as if I had an ortho view. However, if I move my eyePos backward away from the screen, the geometry is appearing smaller as though it is moving back from the screen. Where is my thinking wrong on this? As the eye moves away from the screen, shouldn't the narrowing frustum exactly offset the greater distance, so that the geometry takes the same space on the screen?