Sie sind auf Seite 1von 18

WINDOWTO VIEWPORTMAPPING

PresentationBy: NadishaFathima IVMCA Chintech

2DViewing

WorldcoordinatestoViewingcoordinates WindowtoViewport. Window:Aregionofthesceneselectedfor viewing(alsocalledclippingwindow) Viewport:Aregionondisplaydeviceformapping Viewport to window

Window World Coordinates Viewing Coordinates

ClippingWindowvs.Viewport

Theclippingwindowselectswhatwewanttoseein ourvirtual2Dworld. Theviewportindicateswhereitistobeviewedonthe outputdevice(orwithinthedisplaywindow) Bydefaulttheviewporthavethesamelocationand dimensionsoftheGLUTdisplaywindowyoucreate

Butitcanbemodifiedsothatonlyapartofthe displaywindowisusedforOpenGLdisplay

The clipping window


yw max yw min xw min xw max y view y view yv max x view x0 x world yv min xv min xv max x view yv max yv min xv min xv max

Rectangular Window

y world y0

Rotated Window

1.constructsceneinworldcoordinate(attributes,o/p primitives)

2.Obtainparticularorientationofwindowsetupa2D viewingcoordinates/minwcplane,defineawindowinvc s/m. 3.Viewingcoordinateref.frameusedtoprovidemethod setuparbitraryorientationforrect.window 4.Transformworldcoordinatetoviewcoordinates.

5.definenormalizedcoordinates(01)&mapvcofsceneto normalizedcoordinates. 6.Allpartsoutsideareclipped,contentsinviewport transferredtodevicecoordinate.

Viewportsdefinedinunitsquares(normalized coordinates) Itseperatesview&othertransformationfromdevice specifico/pdevrequirements,sographicpkgsislargely deviceindependent. Oncescenetransferredtonc,unitsquareissimply mappedtodisplayareaforparticularo/pdevinuseat thattime. Whenallcoordinatetransformationcompleted viewportclippingwithnormalizedcoordinates Reducecomputationbyconcatenationofvarious transformationmatrices.

World-coordinates to Viewing Coordinates


y world y0 x view x0 x world y view y world y view y view

x view y
view

x world

x view

T x 0 , y 0

Mwc,vc= RT

Normalization

Coordinate transformation:Different sizes and/or height width ratios?

For any point: (xv-xvmin)/(xvmax-xvmin)=(xw-xwmin)/(xwmaxxwmin))

(yv-yvmin)/yvmax-yvmin)=(yw-ywmin)/(ywmax-ywmin)

xv=xvmin+(xwxwmin)sx yv=yvmin+(ywywmin)sy Scalingfactors: sx=(xvmaxxvmin)/((xwmaxxwmin) sy=(yvmaxyvmin)/(ywmaxywmin)

Thiscanalsobeaccomplishedin2steps: 1.Scaleoverthefixedpoint(xwmin,ywmin)

2.Translatelowerleftcorneroftheclippingwindowtothelower leftcorneroftheviewport

Relativeproportionsofobjsmaintained,ifsx=sy.Otherwiseworld objsstretchedorcontractedeitherinxorydir

OpenGL2DViewingFunctions

OpenGL,GLU,and GLUTprovidefunctions tospecifyclipping windows,viewports,and displaywindowswithina videoscreen.

Setting up a Viewport

glViewport (xvmin, yvmin, vpWidth, vpHeight); All the parameters are given in integer screen coordinates relative to the lower-left corner of the display window. If we do not invoke this function, by default, a viewport with the same size and position of the display window is used (i.e., all of the GLUT window is used for OpenGL display)

2DViewingFunctions

evaluateViewOrientationMatrix(x0,y0,xV,yV, error,viewMatrix)

x0,y0coordinatesofviewingorigin xV,yVworldcoordinatesforviewupvector

error(integer)Errorcodegeneratedifi/pargsareinerro

OtherwisetheviewMatrixworldtoviewtransformation calculated.

ToSetupelementsinwindow viewportmappingmatrix
evaluateViewMappingMatrix(xwmin,xwmax,ywmin ,ywmax,xvmin,xvmax,yvmin,yvmax,error,viewMa ppingMatrix) xwmin,xwmax,ywmin,ywmaxWindowlimits xvmin,xvmax,yvmin,yvmaxViewportlimits ViewMappingMatrixforcreatingwindowviewport pairs&usetoprojectvariouspartstosceneto differentareas

Storingcombinationsof windowviewportmappingfor workstations


setViewRepresentation(ws,viewIndex,viewMatrix,v iewMappingMatrix,xclipmin,xclipmax,yclipmin,yc lipmax,clipxy)

wso/pdevice(workstation) ValueofviewIndexsetsintegeridforparticular

windowviewportpair.(viewMappingIndex+viewMatrix) Clipxynoclip/clip(helpstoturnoffclippingtoview outsidetheviewport Noclipspeedupprocessingwhenknowallthepartsofthe pictureisinsidethelimit

Tosetparticularsetofoptions fromviewingtable
setViewIndex(viewIndex) ViewIndexselectionappliedtosubsequento/pprimitives& associatedattributes&generatesdisplayoneach workstation. lastworkstationtransformationbyselectingaworkstation windowviewportpair setWorkstationWindow(ws,xwsWindmin,xsWindmax,yw sWindmin,ywsWindmax) setWorkstationViewport(ws,xwsVPortmin,xwsVportma x,ywsVportmin,ywsVportmax)

wsworkstationnumber Windowcoordinatesextendsarespecified(0to1) Viewportlimitsintegerdevicecoordinates Ifworkstationviewportnotspecified,unitsquareof normalizedref.Frameismappedontolargestsquare areapossibleono/pdevice. Coordinateoriginofnormalizedspacemappedto originofdevicecoordinates. Aspectratioisretainedbytransformingunitsquare ontosquareareaono/pdevice.

THANKYOU!!!!

Das könnte Ihnen auch gefallen