I'm having trouble understanding coordinate space using perspective in OpenGL. Basically I can't figure out how many units will represent the entire screen given a specific z-value or how spacing should be done, etc. In all the tutorials I've seen they plot these nice shapes placed evenly apart in different areas of the screen x units back in the z-plane but I have no idea how to inherently understand how many units I have to work with at that z-value and how to space things, place them, etc. Is there a good primer on this or some formula using something like the fov angle, viewport size and camera position to figure these things out? Recently I was asked to plot two dots in perspective 1 inch apart on the screen and I'm having trouble figuring out how to achieve this (1280x800 10" monitor display).

9 Years
Discussion Span
Last Post by wildgoose

Yes, I'm using perspective. I made a function that plots 40 points 0.1 floating point units apart across the x and y axes and I've been adjusting the z-values to try to get a little more used to the space but I still don't understand how one inherently understands that.


In my OpenGL code I use the following...

//	_______________________________________________
//	Perform operations to 'Projection' matrix stack
	// matrix = identity x Perspective
	// PI/4, 2/h, 0.1f, 1000.0f
	// mtxWorld = identity
	// D3DXMatrixPerspectieFovLH( &mtxProj, (Radians)PI/3, w/h, 1.0, 1000.0f );

gluPerspective( 60,	// Field of View  60 = pi/3
	app.Viewport.x / app.Viewport.y,	// Aspect ratio
	0.1,		// Near clipping Plane (always positive)
	1000 );		// Far clipping Plane  (always positive)

//	______________________________________________
//	Perform operations to 'ModelView' matrix stack
gluLookAt(	// *** Starting camera position ***
	EyeXYZ.x, EyeXYZ.y, EyeXYZ.z,		// Eye Position
	LookAtXYZ.x, LookAtXYZ.y, LookAtXYZ.z,		// Center reference point XYZ
	0, 1, 0);			// Up X (Y) Z

	glScaled( 1.0, 1.0, -1.0 );			// Convert Right-hand to Left-hand

In this orientation

Into screen    (+Z)
(-X)   Left of screen          0               right of screen (+x)
                  Behind viewer   (-z)

+Y elevation up  -Y below ground
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.