18
WINDOW TO WINDOW TO VIEWPORT MAPPING VIEWPORT MAPPING Presentation By: Presentation By: Nadisha Fathima Nadisha Fathima IV MCA IV MCA Chintech Chintech

Window View Port Mapping Computer Graphics

Embed Size (px)

DESCRIPTION

indow viewport transformation

Citation preview

Page 1: Window View Port Mapping Computer Graphics

WINDOW TO WINDOW TO VIEWPORT MAPPINGVIEWPORT MAPPING

Presentation By:Presentation By:Nadisha FathimaNadisha Fathima

IV MCAIV MCAChintechChintech

Page 2: Window View Port Mapping Computer Graphics

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

Page 3: Window View Port Mapping Computer Graphics

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

Page 4: Window View Port Mapping Computer Graphics

The clipping window

xwmin xwmax

ywmin

ywmax

xvmin xvmax

yvmin

yvmax

xvminxvmax

yvmin

yvmax

x0

y0

xview

yview

xworld

yworld

xview

yview

RectangularWindow

RotatedWindow

Page 5: Window View Port Mapping Computer Graphics

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.

Page 6: Window View Port Mapping Computer Graphics

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.

Page 7: Window View Port Mapping Computer Graphics

World-coordinates to Viewing Coordinates

Mwc,vc= R·T

x0

y0

xview

yview

xworld

yworld

xview

yviewxview

yview

xworld

yworldyview

T −x0 ,− y0 R θ

θ

Page 8: Window View Port Mapping Computer Graphics

Normalization

Page 9: Window View Port Mapping Computer Graphics

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.

Page 10: Window View Port Mapping Computer Graphics

xv=xvmin+(xw­xwmin)sx yv=yvmin+(yw­ywmin)sy Scaling factors:

sx=(xvmax­xvmin)/((xwmax­xwmin)

sy=(yvmax­yvmin)/(ywmax­ywmin)

This can also be accomplished in 2 steps:

1.Scale over the fixed point(xwmin,ywmin)

2.Translate lower­left corner of the clipping window to the lower­left corner of the viewport

Relative proportions of objs maintained,if sx=sy.Otherwise world objs stretched or contracted either in x or y dir

Page 11: Window View Port Mapping Computer Graphics

OpenGL 2D Viewing Functions

OpenGL, GLU, and GLUT provide functions to specify clipping windows, viewports, and display windows within a video screen.

Page 12: Window View Port Mapping Computer Graphics

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)

Page 13: Window View Port Mapping Computer Graphics

2D Viewing Functions  

evaluateViewOrientationMatrix(x0,y0,xV,yV,

error,viewMatrix) x0,y0­coordinates of viewing origin xV,yV­world 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 .

Page 14: Window View Port Mapping Computer Graphics

To Setup elements in window­viewport mapping matrix

evaluateViewMappingMatrix(xwmin,xwmax,ywmin,ywmax,xvmin,xvmax,yvmin,yvmax,error,viewMappingMatrix)

xwmin,xwmax,ywmin,ywmax­Window limits

xvmin,xvmax,yvmin,yvmax­Viewport limits

ViewMappingMatrix­for creating window­viewport pairs & use to project various parts to scene to different areas

Page 15: Window View Port Mapping Computer Graphics

Storing combinations of window­viewport mapping for 

workstationssetViewRepresentation(ws,viewIndex,viewMatrix,v

iewMappingMatrix,xclipmin,xclipmax,yclipmin,yclipmax,clipxy)

 ws­ o/p device(workstation) Value of viewIndex­sets integer id for particular 

window­viewport pair.(viewMappingIndex+viewMatrix)

Clipxy­noclip /clip(helps to turn off clipping to view outside the viewport

Noclip­speedup processing when know all the parts of the picture is inside the limit

Page 16: Window View Port Mapping Computer Graphics

To set particular set of options from viewing table

setViewIndex(viewIndex)

ViewIndex­selection 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)

Page 17: Window View Port Mapping Computer Graphics

 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.

Page 18: Window View Port Mapping Computer Graphics

THANK YOU!!!!THANK YOU!!!!