PDA

View Full Version : How to place crosshairs on target moving around in window?!



sillst
09-17-2001, 10:56 PM
Hi All,

Here is what may seem a rudimentary question, but it beats the hell out of me!

I have a 512*512 window that is told to look around the 3D world according to a program that is basically tracking a moving target. For all intentional purposes, the target is always in the window.

I can get the position of the target in world space coordinates (which I believe is it's origin since this position is represented by one point)

I know what I want to put over the target, and I know how big it has to be. It's just that given the target world space coordinates, I don't know how to translate these into window coordinates, i.e. in my 512*512 window the target might move from (100,200) to (110, 220), etc.

How the hell do I transform my target position to window coordinates?! Everything seems to refer to matrices which operate on *sets* of vertices, and not just one vertex. In theory, I would imagine that I need to perform the Modelview matrix, projection matrix, perspective division and viewport transformation mathematics on the one point to get the associated window coordinates.... It has GOT to be easier than that.

???

(BTW, the target only *moves through* the middle of the window, and I don't want it to always be in the middle, so glutLookAt() is not for me. The program is meant to place a crosshair on the target wherever it moves in the window)

L8r

Tim Sills

Gavin
09-18-2001, 02:21 AM
HAve you looked at unproject?

DaViper
09-18-2001, 05:25 AM
Originally posted by Gavin:
HAve you looked at unproject?
I think gluProject would be the thing to take...

Greetz
Chris

Gavin
09-18-2001, 05:27 AM
I knew what I meant! cheers viper :-)