[comp.sys.sgi] World Coord -> ScreenCoords

cycy@isl1.ri.cmu.edu (Scum) (03/12/90)

Can anybody out there tell me how to map 3d world coordinates to screen
coordinates? I can seem to find anything in the documentation.
				Thanks,
					-- Chris.
-- 

                                       -- Chris. (cycy@isl1.ri.cmu.edu)
"People make me pro-nuclear." -- Margarette Smith

tarolli@riva.esd.sgi.com (Gary Tarolli) (03/13/90)

In article <8387@pt.cs.cmu.edu>, cycy@isl1.ri.cmu.edu (Scum) writes:
> Can anybody out there tell me how to map 3d world coordinates to screen
> coordinates? I can seem to find anything in the documentation.
> 				Thanks,
> 					-- Chris.

There are 2 things to remember when trying to do this:
	1) viewports on the IRIS go from the left edge of the left most
		pixel to the right edge of the right most pixel
		same for top and bottom, thus viewport(0,1,0,1) is 
		exactly 2 pixels by 2 pixels.
	2) the screen coordinate of a pixel center is at an integer

To map 3-D world coordinates [100,200] to a 100 x 100 viewport you would
use the following ortho2 call:

	ortho2(100-.5, 200+.5, 100-.5, 200+.5);

The reason for the +- 0.5 is to account for the left and right edges of the
pixels (see (1) above). 

Also check the screenspace() call which does world coords to absolute
screen coordinates (without regard for your window location or origin).

--
						Gary Tarolli

ghelms@hellfire.sgi.com (Gretchen Helms) (03/13/90)

cycy@isl1.ri.cmu.edu (Scum) writes:
>Can anybody out there tell me how to map 3d world coordinates to screen
>coordinates? I can seem to find anything in the documentation.
>				Thanks,
>					-- Chris.

I am currently in the final stages of debugging
a program that will do exactly that, if you are
using the perspective and polarview calls.  There
is another method if you are using other calls.
Which calls are you using for viewing and projection?

G. "Murdock" Helms			A host is a host & from coast to coast
Silicon Graphics			No one will talk to a host that's close
Product Support Engineer		Unless the host (that isn't close)
ghelms@sgi.sgi.com			Is busy, hung or dead.       -D. Lesher