Some basic concepts
Download
1 / 34

Some Basic Concepts - PowerPoint PPT Presentation


  • 74 Views
  • Uploaded on

Some Basic Concepts . Computer graphics. Clipping. A window is measured physically in terms of pixels. Before you can start plotting points , lines , and shapes in a window, you must tell OpenGL how to translate specified coordinate pairs into screen coordinates.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Some Basic Concepts' - nadda


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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Some basic concepts

Some Basic Concepts

Computer graphics


Clipping
Clipping

  • A window is measured physically in terms of pixels.

  • Before you can start plotting points, lines, and shapes in a window, you must tell OpenGL how to translate specified coordinate pairs into screen coordinates.

  • You do this by specifying the region of Cartesian space that occupies the window; this region is known as the clipping region.

  • In two-dimensional space, the clipping region is the minimum and maximum x and y values that are inside the window.

  • Another way of looking at this is specifying the origin’s location in relation to the window


Viewport
Viewport

  • Rarely will your clipping area width and height exactly match the width and height of the window in pixels.

  • The coordinate system must therefore be mapped from logical Cartesian coordinates to physical screen pixel coordinates.

  • This mapping is specified by a setting known as the viewport.

  • The viewport is the region within the window’s client area that is used for drawing the clipping area.

  • The viewport simply maps the clipping area to a region of the window.

  • Usually, the viewport is defined as the entire window, but this is not strictly necessary; for instance, you might want to draw only in the lower half of the window.


Perspective
Perspective

  • What makes a shape look three-dimensional is perspective, or the angles between the lines that lend the illusion of depth.


Projection
projection

  • The 3D coordinates you use to create geometry are flattened or projected onto a 2D surface (the window background). It’s like tracing the outlines of some object behind a piece of glass with a black marker.

  • By specifying the projection, you specify the viewing volume that you want displayed in your window and how it should be transformed.


Orthographic projections
Orthographic projections

  • In orthographic, or parallel, projections you specify a square or rectangular viewing volume. Anything outside this volume is not drawn. Furthermore, all objects that have the same dimensions appear the same size, regardless of whether they are far away or nearby.


Orthographic projection
Orthographic Projection

  • Orthographic projection


Perspective projection
Perspective projection

  • The perspective projection adds the effect that distant objects appear smaller than nearby objects. The viewing volume is something like a pyramid with the top shaved off.

  • The remaining shape is called the frustum. Objects nearer to the front of the viewing volume appear close to their original size, but objects near the back of the volume shrink as they are projected to the front of the volume


The frustum
The Frustum

Perspective Projection



Transformation pipeline
Transformation Pipeline

  • Three levels of geometric transformations occur between the time you specify your vertices and the time they appear on the screen:

  • These are:

    Viewing transformation

    Modeling transformation

    Projection transformation


The eye coordinate systems
The EYE Coordinate Systems

  • An important concept throughout this chapter is that of eye coordinates.

  • Eye coordinates are from the viewpoint of the observer, regardless of any transformations that may occur;

  • you can think of them as “absolute” screen coordinates.

  • Thus, eye coordinates represent a virtual fixed coordinate system that is used as a common frame of reference.

  • All the transformations are described in terms of their effects relative to the eye coordinate system.



Viewing transformation
Viewing Transformation

  • The viewing transformation allows you to place the point of observation anywhere you want and look in any direction.

  • Determining the viewing transformation is like placing and pointing a camera at the scene.

  • Generally, you must specify the viewing transformation before any other modeling transformations.

  • The reason is that it appears to move the current working coordinate system in respect to the eye coordinate system.


Modeling transformations
Modeling Transformations

  • Modeling transformations are used to manipulate your model and the particular objects within it.

  • These transformations move objects (translate) into place, rotate them, and scale them





The order of modeling trasnfomations
The Order of Modeling Trasnfomations

  • The final appearance of your scene or object can depend greatly on the order in which the modeling transformations are applied. This is particularly true of translation and rotation.




The modelview
The Modelview

  • Practically, the viewing transformation and the modeling transformation are combined in one transformation: The ModelView Transformation


Projection transformation
Projection Transformation

  • The projection transformation is applied to your vertices after the modelview transformation.

  • This projection actually defines the viewing volume and establishes clipping planes.

  • The clipping planes are plane equations in 3D space that OpenGL uses to determine whether geometry can be seen by the viewer.


Orthographic projections1
Orthographic Projections

  • In an orthographic, or parallel, projection, all the polygons are drawn onscreen with exactly the relative dimensions specified.

  • Lines and polygons are mapped directly to the 2D screen using parallel lines, which means no matter how far away something is, it is still drawn the same size, just flattened against the screen.



Perspective projections
Perspective Projections

  • A perspective projection shows scenes more as they appear in real life.

  • The main feature of perspective projections is foreshortening, which makes distant objects appear smaller than nearby objects of the same size.

  • Lines in 3D space that might be parallel do not always appear parallel to the viewer.

  • With a railroad track, for instance, the rails are parallel, but using perspective projection, they appear to converge at some distant point.



The viewport transformation
The Viewport Transformation

  • When all is said and done, you end up with a two-dimensional projection of your scene that will be mapped to a window somewhere on your screen.

  • This mapping to physical window coordinates is the last transformation that is done, and it is called the viewport transformation.



The effect is cumulative
The effect is cumulative

  • The effects of transformation functions are cumulative.

  • Each time you call one, the appropriate matrix is constructed and multiplied by the current modelview matrix.

  • The new matrix then becomes the current modelview matrix, which is then multiplied by the next transformation, and so on.


Example
Example

  • Suppose that you want to draw two spheres:


Example1
Example

// Go 10 units up the y-axis

glTranslatef(0.0f, 10.0f, 0.0f);

// Draw the first sphere

glutSolidSphere(1.0f,15,15);

// Go 10 units out the x-axis

glTranslatef(10.0f, 0.0f, 0.0f);

// Draw the second sphere

glutSolidSphere(1.0f);


The actual result
The Actual Result

The actual result for the above code:


Solution reset using the identity matrix
Solution: Reset using the identity matrix

// Set current matrix to modelview and reset

glMatrixMode(GL_MODELVIEW);

glLoadIdentity();

// Go 10 units up the y-axis

glTranslatef(0.0f, 10.0f, 0.0f);

// Draw the first sphere

glutSolidSphere(1.0f, 15, 15);

// Reset modelview matrix again

glLoadIdentity();

// Go 10 units out the x-axis

glTranslatef(10.0f, 0.0f, 0.0f);

// Draw the second sphere

glutSolidSphere(1.0f, 15, 15);