159'235 Graphics - PowerPoint PPT Presentation

1 / 18
About This Presentation
Title:

159'235 Graphics

Description:

Our 'model' so far has been entirely 2-dimensional. Model uses x,y Cartesian coordinates. Simple mapping to pixel space ... Recent examples - Shrek and Gollum ... – PowerPoint PPT presentation

Number of Views:29
Avg rating:3.0/5.0
Slides: 19
Provided by: KenHa98
Category:
Tags: graphics | shriek

less

Transcript and Presenter's Notes

Title: 159'235 Graphics


1
159.235 Graphics Graphical Programming
  • Lecture 19 - Introduction to 3D Graphics

2
3D Intro - Outline
  • 2D Viewing
  • Parametric Equations
  • 3D Models
  • Projective Geometry
  • 3d Graphics Rendering and Voxels
  • Movies, games, and Virtual Reality
  • Polygons and scenegraphs

3
2D Viewing
  • Our model so far has been entirely
    2-dimensional
  • Model uses x,y Cartesian coordinates
  • Simple mapping to pixel space coordinates for
    our rendering
  • Cropping (what to do if model is outside our
    renderable window)
  • Not trivial but details hidden from us by the
    graphics library
  • Scaling and other Affine Transforms possible
  • Colours, text, drawing primitives such as line,
    rectangle, filled shapes

4
Details of Drawing Shapes and Clipping Them
  • Graphics library (in our case the java Swing
    Library) does all this.
  • Some interesting algorithms in fact needed for
    this
  • Shapes drawn parametrically
  • Clipping regions calculated rather than just
    implemented naively
  • Important for speed and Performance

5
Parametric Equation for a Circle
  • x R cos(theta)
  • y R sin(theta)
  • R sqrt( x2 y2 )
  • R is radius (a constant for a particular
    circle)
  • theta is a parameter of the equation (radians
    angle - 2Pi -gt 1 full rotation or 360 degrees)
  • Implement as
  • for( theta 0 theta lt 2Pi theta increment )

6
Circle Equation is Basis for Polar Coordinates
  • (r,theta) lt--gt (x,y)
  • given a particular origin (x_0,y_0)
  • We have affine transform utility
  • g2.translate( x-amount, y-amount)

7
What about 3D Models?
  • What do we do if we want to render something in
    3D?
  • Our model has (x,y,z) cartesian coordinates
  • How do we translate this into a rendered view?
  • We use some projective geometry
  • Project what you would see as a flat image or
    picture if you looked at a real world 3D object
    from a particular viewpoint

8
Projective Geometry
  • We need transformations to project the model
    coordinates to a view plane coordinate space
    (what we or a camera sees)
  • But we see a distorted view - things further
    away look different from things that are closer
  • So also apply a perspective transformation - to
    distort what a viewer would see from a
    particular point in model space
  • So a lot more computation needed to make all
    this work - luckily modern libraries will do a
    lot of the work for us

9
Geometry Implementation
  • If we needed to build a library we would need to
    go into details of the Mathematical
    formulations of the projection transforms
  • Typically write a a matrix that operates on a
    world coordinate space to a viewing one
  • World might be (x,y,z)
  • View might be (u,v) - like normal (x,y) but in
    the plane of the view

10
3D Graphics Implementation
  • Generally your application maintains a world
    model
  • This is mapped to the 3D internal representation
  • A projection computes what would be seen in a
    2D view space
  • A rendering turns the 2D view into pixels

11
Rendering Pipeline
  • This sequence of getting from model world to
    pixels is often called the rendering pipeline
  • Sometimes have special hardware to help the
    various stages - eg polygon calculations
  • Our world model might be based on a wire-frame
    model built from polygonal shapes and with
    surface textures or images that we paste on
    top of them
  • Together this information constitutes the
    scene-graph

12
Voxels
  • We sometimes imagine a voxelated model
  • Voxel volume element
  • Pixel picture element
  • But until recently we did not have hardware
    that could render voxels directly
  • Polymer prototyping machines come close
  • The scene-graph model is more useful

13
3D Graphics is the basis of VR
  • Virtual Reality (VR) is when we try to fool our
    human senses into thinking we are interacting
    with a model world that need never actually
    exist in reality
  • It is entirely simulated in our program
  • We render it into displays that we can surround
    ourselves with and total immersion VR goes
    further and simulates other sensory information
    such as sounds or movements

14
3D Graphics used in Movies Games
  • Recent examples - Shrek and Gollum
  • Wire-frame models that are updated according to
    some approximate physics calculations (not yet
    in real-time!)
  • Superpose texture maps (colours etc) onto the
    surfaces defined by the wire-frames
  • Render and image - becomes still frame in a
    movie or game.
  • Around 25 frames-per-second fools the human
    vision system into thinking we see continuous
    motion

15
3D Practicalities
  • How do we represent the world model?
  • Wireframe model is set of polygons
  • Possibly a very large set if the world
    object has smooth rounded surfaces
  • A cube could be modeled with just 6 polygons
    (6 squares in fact)
  • Each might have a separate texture and colour

16
Polygons
  • A polygon - many sided shape will have a set
    of vertices and edges
  • A Graphics library may provide a Polygon class
  • There are various file formats for storing
    polygon information
  • A growing set of proprietary and some free tools
    that let us design things - create the polygon
    information
  • We can then store/exchange/combine these files
  • Often our own applications generate the
    polygons from some physics (rules about our
    model world)

17
Generating World Objects
  • We can develop and combine algorithms to
    generate shapes
  • A cube is 6 squares
  • A sphere could be generated parametrically from
    parametric spherical trigonometrical equation
  • We can approximate a sphere by a surface made
    up of lots of polygons, with an opaque colour

18
Summary
  • 3D Graphics allows us to render a real world
    model into a projected view
  • The view can be rendered as per normal
    graphically
  • All the information in a scene-graph together
    with the viewpoint and lighting model etc
    tells us what we would see if the model were
    real
  • Uses in Movies, Games and VR systems
  • Computationally very expensive - supercomputers
    needed
Write a Comment
User Comments (0)
About PowerShow.com