Window View Port Mapping Computer Graphics
-
Upload
nadisha-fathima -
Category
Documents
-
view
849 -
download
4
description
Transcript of Window View Port Mapping Computer Graphics
WINDOW TO WINDOW TO VIEWPORT MAPPINGVIEWPORT MAPPING
Presentation By:Presentation By:Nadisha FathimaNadisha Fathima
IV MCAIV MCAChintechChintech
2D Viewing World coordinates to Viewing coordinates Window to Viewport.
Window: A region of the scene selected for viewing (also called clipping window)Viewport: A region on display device for mapping to window
World Coordinates Viewing Coordinates
WindowWindow
Viewport
Clipping Window vs. Viewport
The clipping window selects what we want to see in our virtual 2D world.
The viewport indicates where it is to be viewed on the output device (or within the display window)
By default the viewport have the same location and dimensions of the GLUT display window you create
− But it can be modified so that only a part of the display window is used for OpenGL display
The clipping window
xwmin xwmax
ywmin
ywmax
xvmin xvmax
yvmin
yvmax
xvminxvmax
yvmin
yvmax
x0
y0
xview
yview
xworld
yworld
xview
yview
RectangularWindow
RotatedWindow
1. construct scene in world coordinate(attributes,o/p primitives)
2.Obtain particular orientation of window setup a 2D viewing coordinate s/m in wc plane,define a window in vc s/m.
3.Viewing coordinate ref.frame used to provide method –setup arbitrary orientation for rect.window
4.Transform world coordinate to view coordinates.
5.define normalized coordinates(0—1) & map vc of scene to normalized coordinates.
6.All parts outside are clipped,contents in viewport transferred to device coordinate.
Viewports defined in unit squares(normalized coordinates)
It seperates view & other transformation from device specific o/p dev requirements, so graphic pkgs is largely device independent.
Once scene transferred to nc, unit square is simply mapped to display area for particular o/p dev in use at that time.
When all coordinate transformation completed—viewport clipping with normalized coordinates
Reduce computation by concatenation of various transformation matrices.
World-coordinates to Viewing Coordinates
Mwc,vc= R·T
x0
y0
xview
yview
xworld
yworld
xview
yviewxview
yview
xworld
yworldyview
T −x0 ,− y0 R θ
θ
Normalization
Coordinate transformation:Different sizes and/or height width ratios?
For any point:
(xv-xvmin)/(xvmax-xvmin)=(xw-xwmin)/(xwmax-xwmin))
(yv-yvmin)/yvmax-yvmin)=(yw-ywmin)/(ywmax-ywmin)
should hold.
xv=xvmin+(xwxwmin)sx yv=yvmin+(ywywmin)sy Scaling factors:
sx=(xvmaxxvmin)/((xwmaxxwmin)
sy=(yvmaxyvmin)/(ywmaxywmin)
This can also be accomplished in 2 steps:
1.Scale over the fixed point(xwmin,ywmin)
2.Translate lowerleft corner of the clipping window to the lowerleft corner of the viewport
Relative proportions of objs maintained,if sx=sy.Otherwise world objs stretched or contracted either in x or y dir
OpenGL 2D Viewing Functions
OpenGL, GLU, and GLUT provide functions to specify clipping windows, viewports, and display windows within a video screen.
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)
2D Viewing Functions
evaluateViewOrientationMatrix(x0,y0,xV,yV,
error,viewMatrix) x0,y0coordinates of viewing origin xV,yVworld coordinates for view up vector error(integer)Error code generated if i/p args are in error Otherwise the viewMatrix world to view transformation
calculated .
To Setup elements in windowviewport mapping matrix
evaluateViewMappingMatrix(xwmin,xwmax,ywmin,ywmax,xvmin,xvmax,yvmin,yvmax,error,viewMappingMatrix)
xwmin,xwmax,ywmin,ywmaxWindow limits
xvmin,xvmax,yvmin,yvmaxViewport limits
ViewMappingMatrixfor creating windowviewport pairs & use to project various parts to scene to different areas
Storing combinations of windowviewport mapping for
workstationssetViewRepresentation(ws,viewIndex,viewMatrix,v
iewMappingMatrix,xclipmin,xclipmax,yclipmin,yclipmax,clipxy)
ws o/p device(workstation) Value of viewIndexsets integer id for particular
windowviewport pair.(viewMappingIndex+viewMatrix)
Clipxynoclip /clip(helps to turn off clipping to view outside the viewport
Noclipspeedup processing when know all the parts of the picture is inside the limit
To set particular set of options from viewing table
setViewIndex(viewIndex)
ViewIndexselection applied to subsequent o/p primitives & associated attributes & generates displayon each workstation.
last workstation transformation by selecting a workstation window viewport pair
setWorkstationWindow(ws,xwsWindmin,xsWindmax,ywsWindmin,ywsWindmax)
setWorkstationViewport(ws,xwsVPortmin,xwsVportmax,ywsVportmin,ywsVportmax)
ws workstation number Window coordinates extends are specified(0 to 1) Viewport limits—integer device coordinates If workstation viewport not specified,unit square of
normalized ref. Frame is mapped on to largest square area possible on o/p device.
Coordinate origin of normalized space mapped to origin of device coordinates.
Aspect ratio is retained by transforming unit square onto square area on o/p device.
THANK YOU!!!!THANK YOU!!!!