1 / 29

2 DIMENSIONAL VIEWING

Computer Engineering Kocaeli University. 2 DIMENSIONAL VIEWING. 3D View Scene. Model. 3D World Scene. Model. Model. Viewing Pipeline Revisited. Modeling Transformations. Viewing Transformations. M1. V. M2. M3. WCS. VCS. MCS. Rasterization. 2D/3D Device Scene. P. Clip.

tobit
Download Presentation

2 DIMENSIONAL VIEWING

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Computer Engineering Kocaeli University 2 DIMENSIONAL VIEWING

  2. 3D View Scene Model 3D World Scene Model Model Viewing Pipeline Revisited Modeling Transformations Viewing Transformations M1 V M2 M3 WCS VCS MCS Rasterization 2D/3D Device Scene P Clip Normalize NDCS Projection DCS SCS 2D Image

  3. Model - World • Model coordinates to World coordinates:Modelling transformations Model coordinates: 1 circle (head), 2 circles (eyes), 1 line group (nose), 1 arc (mouth), 2 arcs (ears). With their relative coordinates and sizes World coordinates: All shapes with their absolute coordinates and sizes. circle(0,0,2) circle(-.6,.8,.3) circle(.6,.8,.3) lines[(-.4,0),(-.5,-.3),(.5,.3),(.4,0)] arc(-.6,0,.6,0,1.8,180,360) arc(-2.2,.2,-2.2,-.2,.8,45,315) arc(2.2,.2,2.2,-.2,.8,225,135)

  4. World - Viewing • World coordinates to Viewing coordinates:Viewing transformations World coordinates Viewing coordinates:Viewers position and view angle. i.e. rotated/translated

  5. View - Device • Projection: 3D to 2D. Clipping depends on viewing frame/volume. Normalization: device independent coordinates Viewing coordinates: Device Independent Coordinates: Invisible shapes deleted, others reduced to visible parts. 3 arcs, 1 circle, 1 line group

  6. Unit measures Pixels Device Independen Coordinates – Screen or Device Coordinates • Device Independent Coordinates to Device Coordinates. Rasterization Screen Coordinates or Device Coordinates Device Independent Coordinates

  7. 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 Viewport Window World Coordinates Viewing Coordinates

  8. 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

  9. The clipping window Rectangular Window Rotated Window

  10. Transformations Between Coordinates Systems • Rule: Transform one coordinate frames towards the other in the opposite direction of the representation change.

  11. Transformations Between Coordinates Systems • Two Steps: • Translate so that the origin (x0,y0) of the x´y´ system is moved to the origin of the xy system. • Rotate the x´ axis onto the x axis.

  12. Transformations Between Coordinates Systems

  13. World-coordinates to Viewing Coordinates • Mwc,vc= R·T

  14. Coordinate Representation • Normalized Coordinates: A graphic system first converts world coordinate positions to normalized device coordinates, in the range 0 to 1.This makes the system independent of the output-devices. • An initial modeling coordinate position is transferred to a device coordinate position with the sequence • The modeling and world coordinate positions in this transformation can be any floating values; normalized coordinates satisfy the inequalities

  15. Normalization

  16. Calculating Device Coordinates • Coordinate transformation:Different sizes and/or height width ratios? • For any point: • should hold. And;

  17. The transformation matrix for the viewing transformation EKRAN

  18. The transformation matrix for the viewing transformation

  19. What happens if Sx=Sy=1 • ???

  20. Say we want to map this to a 640x480 viewport Where is the black point mapped in screen coordinates? Example 0.4 0.3 -0.4 -0.2 480 640

  21. OpenGL Related

  22. OpenGL 2D Viewing Functions • OpenGL, GLU, and GLUT provide functions to specify clipping windows, viewports, and display windows within a video screen.

  23. OpenGL 2D Viewing Example • 2 Viewports • One triangle is displayed in two colors and orientations in 2 viewports glutInitWindowSize (600, 300); glClear (GL_COLOR_BUFFER_BIT); glColor3f(0.0, 0.0, 1.0); glViewport(0, 0, 300, 300); drawCenteredTriangle(); glColor3f(1.0, 0.0, 0.0); glViewport(300, 0, 300, 300); glRotatef(90.0, 0.0, 0.0, 1.0); drawCenteredTriangle();

  24. Setting up a 2D Clipping-Window • glMatrixMode (GL_PROJECTION) • glLoadIdentity (); //reset, so that new viewing parameters are not combined with old ones (if any) • gluOrtho2D (xwmin, xwmax, ywmin, ywmax); or • glOrtho (xwmin, xwmax, ywmin, ywmax, zwmin, zwmax); • Objects within the clipping window are transformed to normalized coordinates (-1,1)

  25. 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)

  26. Creating a GLUT Display Window • glutInitWindowPosition (xTopLeft, yTopLeft); • the integer parameters are relative to the top-left corner of the screen • glutInitWindowSize (dwWidth, dwHeight); • glutCreateWindow (“Title of Display Window”); • glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB) • Specification of the buffer that will be used • glClearColor (red, green, blue, alpha) • Specify the background color

  27. Multiple GLUT windows • Multiple windows may be created within an OpenGL program • Need window ids to manage multiple windows • windowID = glutCreateWindow(“Window1”); • glutDestroyWindow (windowID) // to distroy the window • General functions (like glutInitDisplayMode) are applied to the current display window. We can set the current window to a specific window with: • glutSetWindow (windowID);

  28. Other functions • GLUT provide functions to relocate, resize, minimize, resize to fullscreen, change window title, hide, show, bring to front, or send to back, select a specific cursor for the current display window. (pages 309-311 in the textbook)

  29. Display callback function • Each separate GLUT window can have its own function to specify what will be drawn inside. E.g., • glutSetWindow (w1); • glutDisplayFunction (wireframeDisplay); • glutSetWindow (w2); • glutDisplayFunction (solidDisplay); • Display callback functions are called only when GLUT determines that the display content should be renewed. To update the display manually call: glutPostRedisplay(); • glutIdleFunc (functionName) could be used in animations

More Related