CS 148

Lecture 10

3D Surface Modeling I

 
 
 
 
 
 
 
 



 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Admin:

Groups for final project
Midterm Exam from office hours or in class on Thursday

TODAY:

Modeling

Wireframe Model

Back-Face Culling

Back-Face Elimination

Towards Illumination


 
 
 


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Rendering vs. Modeling
Rendering
Basic tools and techniques used to place a picture on the display screen.
Modeling
Taking primitives and objects generated from primitives and putting them together to create an object or scene.

 

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 



 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 


 
 

Modeling incorporates:

  • Constructing solid objects
  • Constructing their boundary surface ("skin")
  • Polygon surface
  • Smoothly curved surface (patch)

  •  
     
     
     
     
     
     
     
     
     
     
     
     
     


     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     


    Solids
    For processing, solids must have representations describing the topography,  geometry and characteristics completely:

    1.Domain
    A representation should be able to represent a useful set of geometric objects.
    2.Unambiguity :
    No doubt in the representation of a solid. An unambiguous representation is usually referred to as a complete one.
    3.Uniqueness :
    There is only one way to represent a particular solid.
    4.Accuracy :
    No approximation is required.
    5.Validity :
    A representation will not represent an object that does not correspond to a solid.
    6.Closure :
     Transforming valid solids always yields valid solids.
    7.Compactness and Efficiency :
    Memory compactness and allow for efficient algorithms to determine desired physical characteristics.
    These may be contradictory!
     
     
     


     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     


    Planes and patches

    Parametric representations... again?

    Any point on surface: P(u,v)
    Three components (X,Y,Z)

    Define "outside" and "inside" regions: f(x,y,z)
    implicit fn f 'inside-outside fn' relationship>
    point(x,y,z) is:
    if f(x,y,z)<0    inside
    if f(x,y,z)=0    on surface
    if f(x,y,z)>0    outside


     
     
     
     
     
     


     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     


    Parametric Form of a Plane

  • position vector, c
  • noncollinear directions, a and b
  • Practicality?
    normal computation
    How do we actually do this?
    Any point on the plane can be represented by a vector sum:
    p(u,v) = c +ua + vb

     


     
     
     
     
     
     
     
     
     
     
     
     
     


    Equation in terms of c, a, and b components with the unit vectors: p(u,v) =

    (cx + ax*u + bx*v)i +
    (cy + ay*u + by*v)j +
    (cz + az*u + bz*v)k
    derivation?
     
     
     
     
     
     
     
     


     
     
     
     
     
     
     
     
     
     
     
     
     


    Patches
     
     
     
     

    Ranging u and v

  • Infinitely
  • Restricted to finite range: planar patch

  •  
     
     
     
     
     
     
     
     
     
     
     
     


     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     


    Curved Surfaces

    Parametric Forms exist for a large class of curved surfaces:

    Ruled Surface
    created by sweeping a 'straight' line through space
    Surfaces of Revolution
    created by 'sweeping' a curved line about an axis
    Quadratic Surfaces
    created by defining quadratic eqations in x, y, and z.
    Superquadratics
    an extension of quadratics

     
     


     
     
     


    Wireframe Models

    Storage

    vertex list
    edge list
    Rendering
    simple line drawing of edges.
     
     

     
     
     
     
     
     
     


     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     


    Applicable Example: Basic Barn

    Vertex
    x
    y
    z
    Edge
    vertex1
    vertex2
    1
    0
    0
    0
    1
    1
    2
    2
    0
    1
    0
    2
    2
    3
    3
    0
    1
    1
    3
    3
    4
    4
    0
    .5
    1.5
    4
    4
    5
    5
    0
    0
    1
    5
    5
    1
    6
    1
    0
    0
    6
    6
    7
    7
    1
    1
    0
    7
    7
    8
    8
    1
    1
    1
    8
    8
    9
    9
    1
    .5
    1.5
    9
    9
    10
    10
    1
    0
    1
    10
    10
    6
           
    11
    1
    6
           
    12
    2
    7
           
    13
    3
    8
           
    14
    4
    9
           
    15
    5
    10
           
    16
    2
    5
           
    17
    1
    3

     


     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     


    Procedural Wireframe drawing

  • use an algorithm to populate the data structure
  • project the (x,y,z) coordinates to 2-D coordinates
  • connect the vertices as defined by edge list
  • what algorithms do you use to populate the data structure?
    Here is where parametric equations become useful for some surfaces, knowledge of geometry for others.
     
     
     
     
     
     
     
     
     
     
     
     


     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     


    Platonic solid (regular polyhedron)

    All faces of polyhedron are identical and each is a regular polygon.
    Only five of these:
  • tetrahedron (4 faces, triangle each)
  • hexahedron (cube, 6 faces, square)
  • octahedron (8 faces, triangle)
  • dodecahedron (12 faces, pentagon)
  • icosahedron (20 faces, triangle)

  •  
     
     
     
     
     
     
     


     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     


    Example: Modeling a Tetrahedron

    vertex
    x
    y
    z
     
    Face
    v1
    v2
    v3
    nx
    ny
    nz
    1
    1
    1
    1
     
    1
    2
    3
    4
    -1
    -1
    -1
    2
    1
    -1
    -1
     
    2
    1
    4
    3
    -1
    1
    1
    3
    -1
    -1
    1
     
    3
    1
    2
    4
    1
    1
    -1
    4
    -1
    1
    -1
     
    4
    1
    3
    2
    1
    -1
    1

     
     
     
     
     
     
     
     
     


     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     


    Modeling Parametric Patches

    plane: p(u,v) = c + au +bv

    u- and v- contours

    For any parametric equation, we can hold either u- or v- constant. Varying the other results in a countour.
    We can draw quadrilaterals between the vertices of intersection.
     
     
     
     
     
     
     
     
     
     
     


     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     


    Face Orientation

    Define a convention: front-facing polygons described CCW
    'orientable' manifolds: surface described by polygons of consistent orientation.
    Not all surfaces are orientable.



     
     



     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     


    Culling Polygon Faces

    Must have some convention
    openGL: CCW, can be changed with glFrontFace())
    Matters when viewpoint is inside versus outside shape
    openGL: back-facing polygons never visible in completely enclosed surfaces from outside.
    glCullFace indicates which polygons should be discarded before conversion to screen coordinates.
    Define decision function:
    Compute polygon's area in window coordinates.
    Sign of area specifies orientation.

     

     
     
     
     



     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     


    What If Faces Have Holes?

    Two ways for resolving this problem:
     

    Outer boundary is ordered clockwise, while its inner loops, if any, are ordered counter clockwise.
    Add auxiliary edge between each inner loop and the outer loop.

     
     
     
     



     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     


    Hidden Surface Removal

    Depth buffer: associates depth (distance) from viewing plane
    Algorithm:
  • set depth to far clipping plane

  • openGL: glClear(GL_DEPTH_BUFFER_BIT) )
  • graphical calculations convert drawn surfaces to pixels (with depth).
  • If new pixel's depth is lesser than what is in buffer (closer to viewplane) replace the current value.
  • Drawing then done, without drawing obscured pixels.

  •  

     

    openGL: must enable depth buffering
    glutInitDisplayMode(GLUT_DEPTH | ...)
    glEnable(GL_DEPTH_TEST);

    What if we don't do this?
     
     
     



     

     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     


    Normal Vector to a Surface

    Plane

    dot(n,p) = D
    Flat Surfaces
    Normalized Cross Product of two vectors on the surface.
    Curved surfaces
    h(m0,n0) = ((dr/dm)c(dr/dn))


    Example: p(u,v) = c + au + bv

    Take partial derivatives: (dr/dm)=a; (dr/dn)=b;
    Obtain normal vector by cross product