High Performance Visualization I Week 3 - PowerPoint PPT Presentation

1 / 26
About This Presentation
Title:

High Performance Visualization I Week 3

Description:

Raw vertices are. multiplied by the. ModelView matrix. 12. Push and Pop ... Create more complex height functions, either taking ideas from the lecture ... – PowerPoint PPT presentation

Number of Views:47
Avg rating:3.0/5.0
Slides: 27
Provided by: cs196
Category:

less

Transcript and Presenter's Notes

Title: High Performance Visualization I Week 3


1
High Performance Visualization I Week 3
  • Instructors
  • Dr. James Sochacki
  • Dr. Ramon Mata-Toledo
  • Lab Instructors
  • Joshua Blake
  • Justin Creasy

2
Review
  • 3D Basics
  • Processing input from keyboard and mouse
  • Homework Terrain Program
  • Due Thursday at lab
  • Share? Problems?

3
Today
  • More advanced 3D concepts
  • Ortho vs Perspective
  • Projections
  • More on Matrices
  • Coding standards
  • Textures

4
Review
  • Process of transforming a vertex from world
    coordinates into rasterized pixels

5
Vertex Transformations
  • Each vertex is a 4-d vector
  • Transform by applying the appropriate 4x4 matrix
    to the coordinates of the vertex.
  • If v is our vertex
  • And M is our 4x4 matrix
  • Then Mv is our image of v under the
    transformation of M

6
Making my life easier
  • For now, just understand that when you specify a
    point, either 2-d or 3-d, internally the computer
    stores it as a 4-d point
  • We have already talked about the X, Y, and Z
    coordinates. We skipped the W coordinate
  • W is basically 1/depth
  • For now, understand it is there and will affect
    transformations and when it is not specified its
    value is 1
  • x, y, z, w

7
Counteracting commands
  • Some transformations can counter what is done by
    another transformation (or add to it)
  • Transformations affect the current matrix, and
    are cumulative
  • Using a viewing transformations we can pull our
    viewport away from the image, making it smaller
  • We could instead also use a modeling
    transformation to move the model away from the
    viewport
  • To counter a transformation, use the inverse
    matrix

8
Examples of Matrices
  • glLoadIdentity()
  • Identity Matrix
  • Any vector multiplied by the identity doesnt
    change. ( Iv v )
  • The inverse of the identity is itself.

9
More examples
  • Translate, Scale, and Rotate modify the current
    matrix (Modelview, Projection, etc.)
  • glTranslate(x, y, z) generates T, where

10
More examples
  • glScale(x, y, z) generates S, where
  • Rotation is more complicated.

11
The Modelview Matrix
  • This positions your vertices and models in the
    world
  • Include rotating, scaling, and translating the
    model
  • Raw vertices aremultiplied by the ModelView
    matrix

12
Push and Pop
  • glPushMatrix saves the current state of the
    active matrix (usually the modelview)
  • Saved on a stack
  • glPopMatrix retrieves the state
  • Used for complex objects
  • glPushMatrix()
  • glTranslatef(10, 0, 0) (changes the origin)
  • Draw something with respect to origin
  • glPopMatrix()
  • Now the thing you drew is centered around (10,
    0, 0)

13
Projection Matrix
  • Determines what is visible
  • Clipping planes are defined
  • Analogous to positioning a camera on a tripod
  • Produces a view of your world

14
Projection Transformation
  • This is the process of determining the shape of
    the volume you are viewing
  • Following the camera analogy, its like deciding
    what lens to use
  • Two types of projections are orthographic and
    perspective

15
Orthographic
  • Maps object directly onto screen without
    affecting its relative size
  • Useful when the measurements of objects is more
    important than how the object actually looks
  • Ex Architectural and computer aided designing
  • Parallel lines stay parallel

16
Perspective
  • This is the more commonly used projection
  • Attempts to match the graphics to how they would
    look in everyday life
  • Specified by the glFrustrum() or gluPerspective()
    command
  • Objects further away appear smaller, etc. and
    there is a vanishing point
  • Parallel lines converge

17
Viewport Transformation
  • This is the process of determining what is
    viewable on screen and matching pixels to their
    correct color, shade, etc. (also called
    rasterization)

18
How this pertains to you
  • While this is the order the computer processes
    your graphics, its not necessarily how you think
    about it
  • You create vertices, lines, and so forth, which
    are affected by the matrices.
  • To create viewing transformations,
    transformations must be performed on these
    matrices.

19
Textures Mapping
  • Pastes an image onto a polygon
  • glTexCoord2d(u, w) specifies the texture
    coordinates

(1, 1)
(0, 1)
w
(0, 0)
(1, 0)
u
20
Texture Coordinates
  • Use texture coordinates to specify what part of
    the active texture will align with the following
    vertices
  • glTexCoord2f(0, 0)
  • glVertex3f(0, 0, 0)
  • glTexCoord2f(0, 1)
  • glVertex3f(0, 2, 0)
  • glTexCoord2f(1, 1)
  • glVertex3f(2, 2, 0)
  • glTexCoord2f(1, 0)
  • glVertex3f(2, 0, 0)

The vertices do not have to be same as the
texture coordinates!
21
Texture Coordinates
  • glTexCoord2f(0, 0)
  • glVertex3f(0, 0, 0)
  • glTexCoord2f(0, 1)
  • glVertex3f(0, 2, 0)
  • glTexCoord2f(1, 1)
  • glVertex3f(1, 2, 0)
  • glTexCoord2f(1, 0)
  • glVertex3f(1, 0, 0)

22
Texture Coordinates
  • glTexCoord2f(0, 0)
  • glVertex3f(0, 0, 0)
  • glTexCoord2f(0, .5)
  • glVertex3f(0, 2, 0)
  • glTexCoord2f(1, .5)
  • glVertex3f(2, 2, 0)
  • glTexCoord2f(1, 0)
  • glVertex3f(2, 0, 0)

23
Example code
24
Lighting
  • Next week!

25
Reference
  • Neat terrain stuff
  • http//www.lighthouse3d.com/opengl/terrain/
  • www.gamedev.net (The Redbook)
  • Chapter 9 for textures
  • Chapters 3 and Appendix F for matrices

26
Homework
  • Add Textures to the Terrain
  • Start to form an organized idea of what the world
    is it could be abstract patterns or concrete
    idea from the real world, but it should
    definitely be understandable
  • Add at least two textures, at least one to the
    terrain itself, and one to the object on the
    terrain from last week
  • Create more complex height functions, either
    taking ideas from the lecture/example code or
    from a terrain tutorial online
  • Continue to be creative
Write a Comment
User Comments (0)
About PowerShow.com