Up: SGI graphics Frequently Asked Questions (FAQ)
Next: -59- Why does nothing happen when I call mapcolor(index, R, G, B)?
Previous: -57- How can I translate screen (x,y) coords into world (x,y,z) coords?
Subject: -58- How can I translate world (x,y,z) coords into screen
(x,y) coords?
Date: 07 May 1993 00:00:01 EST
There are two methods. The first method is detailed in
~4Dgifts/examples/grafix/world2scrn.c, which is part of the
dev.dev_sw.giftsfull package. It multiplies the (x,y,z) vector into
the current modeling and projection matrixes, and uses the result to
interpolate based on the window size and position.
The second method uses the current cursor position as a trick and is
much simpler. Use cmov() to set the cursor position to the point of
interest in world space, then call getcpos() to return the cursor
position in screen coordinates. Note that if your entire viewport is
off-screen, the results are undefined and you'll have to use the
first method.
float x,y,z;
short x1, y1;
cmov (x,y,z);
getcpos (&x1, &y1);
Up: SGI graphics Frequently Asked Questions (FAQ)
Next: -59- Why does nothing happen when I call mapcolor(index, R, G, B)?
Previous: -57- How can I translate screen (x,y) coords into world (x,y,z) coords?