dmz@jove.rutgers.edu (Dave Zirl) (07/04/90)
This may sound quite simple, but we are having problems none-the-less. We want to pick a point on the screen(x,y) and convert them into object(world) coordinates(X,Y,Z). The problem seems to be in the multiple layers of transformations that the screen coordinates must undergo before they become object coordinates. According to the graphics library program guide the following transformations are involved(in either direction (obect <-->screen)) obect coords --> model/view matrix --> eye coords --> projection matrix --> clip coords --> divide by w normalized coords --> viewport system --> window coords --> window offset --> screen coords -->pixel However, the problem lies in converting pixel values returned from MOUSEX and MOUSEY into the eye coordinate system and subsequently going from the eye to object coordinate system. If anyone has done any similar programming their assistance on this problem would be greatly appreciated. I can be reached at dmz@rutile.rutgers.edu Thanks in advance David Zirl Rutgers University Department of Ceramics PO Box 909 Piscataway, NJ 08855-0909 201-932-3083 dmz@rutile.rutgers.edu
blbates@AERO4.LARC.NASA.GOV ("Brent L. Bates AAD/TAB MS361 x42854") (07/05/90)
If I understand you correctly, I just started doing that recently.
Below is some sample FORTRAN:
...
integer*4 tranmatrix,xmice4,xwinlen,xwinorg,ymice4,ywinlen,ywinorg
real scaleyz,xo,xoff,xtekscale,yo,yoff,ytekscale,zmin,zoom
...
call getori(xwinorg,ywinorg)
call getsiz(xwinlen,ywinlen)
...
tranmatrix=genobj()
call makeob(tranmatrix)
call viewpo(0,xwinlen,0,ywinlen)
call ortho(0.,xtekscale,0.,ytekscale,-.1,.1)
call lookat(0.0,0.0,.1,0.0,0.0,0.0,0.0)
call transl(xtekscale/2.0,ytekscale/2.0,0.0)
call scale(zoom,zoom,1.0)
call transl(-xtekscale/2.0,-ytekscale/2.0,0.0)
call transl(xoff,yoff,0.0)
call scale(scaleyz,scaleyz,1.0)
call transl(0.0,-zmin,0.0)
call closeo
...
xmice4=getval(mousex)-xwinorg
ymice4=getval(mousey)-ywinorg
if(xmice4.lt.0) then
xmice4=0
else if(xmice4.gt.xwinlen) then
xmice4=xwinlen
endif
if(ymice4.lt.0) then
ymice4=0
else if(ymice4.gt.ywinlen) then
ymice4=ywinlen
endif
call mapw2(tranmatrix,xmice4,ymice4,xo,yo)
xo and yo are the 2d world coordinates
I hope this is what you are looking for.
--
Brent L. Bates
NASA-Langley Research Center
M.S. 361
Hampton, Virginia 23665-5225
(804) 864-2854
E-mail: blbates@aero4.larc.nasa.gov or blbates@aero2.larc.nasa.gov