Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!maverick.ksu.ksu.edu!zaphod.mps.ohio-state.edu!sdd.hp.com!elroy.jpl.nasa.gov!decwrl!sgi!shinobu!odin!dave From: dave@sgi.com (dave "who can do? ratmandu!" ratcliffe) Newsgroups: comp.sys.sgi Subject: Re: Problems with mapw() in GL on Personal Iris Keywords: Silicon Graphics, 3D-Pick, GL (Graphic Language) Message-ID: <1990Nov9.220015.27521@odin.corp.sgi.com> Date: 9 Nov 90 22:00:15 GMT References: <(Graphic> <3238@zgdvda.zgdvda.uucp> Sender: news@odin.corp.sgi.com (Net News) Organization: Silicon Graphics, Inc., Mountain View, CA Lines: 90 In article <3238@zgdvda.zgdvda.uucp> boehmk@zgdvda.uucp writes: > > >I have a problem with the 'mapw()'-Function of the GL of the Personal >IRIS machine. >It would also be great, if anybody could send a part of a sample Program ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >to me. I am not able to use the pick()-Function. > >Hope to hear anything >Klaus perhaps the below example will be useful: /* * mapw: * * Bare-bones example demonstrates use of MAPW(3G) for determining a line * in 3-space given a 2-D screen space point. Note that the "line" drawn * after the call to MAPW(3G) simply looks like a green point. This is * exactly as it should be--i.e. drawing a line from the first to the * second point returned by mapw *should* appear to the viewer's eye as if * it is simply a point in space * * ratman - 1987 */ #include #include #define VOBJ 6 main() { Screencoord scrx, scry; Coord wx1, wy1, wz1, wx2, wy2, wz2; short screenx, screeny, val; long xorig, yorig; Device dev; prefsize(512,512); winopen("mapw_test"); qdevice(LEFTMOUSE); qdevice(ESCKEY); color(BLACK); clear(); perspective(440,1.0,1.0,1500.0); makeobj(VOBJ); perspective(440,1.0,1.0,1500.0); closeobj(); getorigin(&xorig, &yorig); while (TRUE) { dev = qread(&val); switch(dev) { case LEFTMOUSE: if (val) { scrx = (short) getvaluator(MOUSEX) - xorig; scry = (short) getvaluator(MOUSEY) - yorig; callobj(VOBJ); mapw(VOBJ,scrx,scry,&wx1,&wy1,&wz1,&wx2,&wy2,&wz2); /* only get values +/- 1.0 for wz1 */ printf("wx1=%.2f wy1=%.2f wz1=%.2f ", wx1, wy1, wz1); printf("wx2=%.2f wy2=%.2f wz2=%.2f\n", wx2, wy2, wz2); color(BLACK); clear(); color(GREEN); move(wx1, wy1, wz1); draw(wx2, wy2, wz2); } break; case REDRAW: getorigin(&xorig, &yorig); reshapeviewport(); callobj(VOBJ); color(BLACK); clear(); break; case ESCKEY: gexit(); exit(0); break; } } }