From: dluebke@nostromo.cc.colorado.edu (Dave Luebke)
Subject: Re: TECH?: Polhemus Head Tracking / GL problem
Date: Thu, 10 Dec 92 15:39:12 -0800


David Johnson writes:
>My matrix seems to be correct, but if I use the GL perspective
>command, it seems to mess it up, and if I don't, the z-buffer
>doesn't seem to be active (clipping planes problem?).

I have worked with the GL perspective and zbuffer commands in 
a VR context, and have run into similar problems. Those problems,
and their solutions, are presented from most to least obvious:
	1) are you in mmode(MVIEWING) ?
	2) does the perspective command that you are attempting to
	   use have a clipping plane at zero? We learned the hard way
	   that the zbuffer is unpredictable under this arrangement.
	3) are you loading in your custom matrix and forgetting to
	   multiply it with the previous (untransformed) matrix?
	4) does the custom matrix you are using already account for
	   perspective calculations? I couldn't find Foley and van Dam
	   to look it up myself. 

Incidentally, why not just use the lookat() command? Might be faster than
loading in a custom matrix, since it has been precoded by people who know
and love the GL's guts. It would depend on what kind of data your head
tracker was feeding, I guess..

Oh, and:
	5) Of course, the order of the commands matters. You probably want
	   to pushmatrix() the untransformed scene, do your perspective
	   command, load in the custom matrix, do your multmatrix(),
	   render, and popmatrix() back to the untransformed scene.
	   Remember that the GL only premultiplies.

Sorry if some of these are insulting in their simplicity, but they're all
mistakes I made, and I thought I might as well cover all bases.

Good luck,

Dave Luebke
dluebke@nostromo.cc.colorado.edu
