CS 184: COMPUTER GRAPHICS

     metro 

QUESTION OF THE DAY:

What structure would you impose on the scene shown at left ?

How many objects ? -- Examples ?

How many groups should you make ?

How many things should be in each in each group ?

What should be grouped together ?
   ( -- give several criteria )




PREVIOUS < - - - - > CS 184 HOME < - - - - > CURRENT < - - - - > NEXT

Lecture #7 -- Wed 2/11/2009.

Crucial Concepts from Last Lecture:

Matrices are linear operators. Composing linear operators is still linear. Any matrix has an inverse.
The transformations used in CG can be represented efficiently by matrices.
Compound transformations are then be constructed by matrix multiplication.
Translation, can also be turned into a linear operator by introducing homogeneous coordinates.
Homogeneous coordinates look at the transformation in a space that is one dimension higher (add "w") than the space of interest;
  they use the subset of transformations that leave that new dimension unaffected (except for a shear operation),
  but then use only what is happening in the hyperplane w=1.

Other neat things, not mentioned last time:

Singular Value Decomposition (SVD) of any matrix:   A = Q S R'  where Q and R are orthonormal and S is a diagonal matrix.
or we can do a Polar Decomposition:   A = U R S R'   where again U and R are orthonormal and R' is the transpose of R.
==> Thus any complex matrix can be decomposed into a product of pure scale and rotation matrices!

The  eigenvectors e  of a matrix M are determined by the equation Me = se, where s is a simple scale factor;
They correspond to those vectors that do not change direction when transformation M is applied, (e.g. vectors along the coordinate axes when M is a non-uniform affine scaling).

Scene Hierarchy, Instantiations, Compound Transformations

Now we want to build complex scenes with more than just one polygon!
How should we "describe" a complex world model in the computer ?  -- for instance: a Boeing 747: ~ 4 000 000 identifyable parts?.  -- or a battle scene in StarWars?
Use hierarchically nested groups of objects (and of other groups) with relative transformations.
An object or group of objects can be instantiated multiple times -- in different places, with different orientations, and different scales.
Benefits:  Managing complexity, abstraction, structure, re-use of objects, easy searching and editing, reducing the rendering work, ...

An example of instancing: "60 Butterlies on a Sphere"

Hierarchical Scene Composition and Description (Houses on a Hill)

Conceptual scene structure. Corresponding scene graph and fully instantiated scene tree.
The scene is built from Groups and from Instances (of groups and/or objects).
The bottom-level of groups, consisting of pure static geometry are called Objects;
The top level group, i.e., the root of the scene graph, we typically call World.
Groups are composed of Instances; and each instance comes with a transformation that specifies how it is positioned in the group's coordinate system.
Instances also carry such information as color or LOD-values.
Groups are the place to store intermediate bounding boxes and perhaps a flag that says whether the group is static or time-variable.
Groups may have many children, and they are all instances.
Instances have only a single child and this may be an object or another group (NO RECURSION!).
There is a strict alternation between groups and instances in the hierarchy.

SCD_09: a way to capture this information in a human-readable ascii format (and also easy to parse for future use).

Example Scene Description ( SCD_09 )

(Include   fish1   "fish.obj"   )      ## this calls the polygon in that file "fish1"

(G school_A
    (I   inst1   fish1   (S  0.5 0.5 )   (T  5  3.4 )   (color  1  0.8  0.2 )   )     ## orange fish
    (I   inst2   fish1   (S  0.7 0.4 )   (T  7.2  6 )   )     ## uncolored fish
    (I   inst3   fish1   (R  {t*2} )   (T 8 9 )   )     ## blank fish, rotating 2 degrees per frame around it center
 )

(G school_B
    (I   inst1   fish1   (S  -0.5 0.5 )   (T 2 {0.4*sin(t*6
*dgr)} )   )    ## mirrored fish, doing a complete vertical wiggle every 60 frames.
    (I   inst2   fish1   (S {1 + 0.5*sin(t*3*dgr)}  0.6 )   (T  4 6 ) (color  0 1 0)   )    ## green fish, changing in length with a cycle of 120 frames.
 )

(G myScene
    (I   i_1   school_A   (color  0 1 1)   )    ## cyan version of school_A
    (I   i_2   school_A   (S  -1 1)   (color  1 0 1)   )    ## magenta, mirrored version of school_A
    (I   i_3   school_B   (T  {t*0.01}{t*0.01} )     (lod  3)   )    ## school_B, slowly drifting diagonally off the view window, wire-frame only.
 )

(Render  myScene  )


Notes:
Identifiers
within a group must be unique. They will serve to form unique names for all instances in the whole scene
   by concatenating all instance names from top to bottom as follows:  "TopInst_ID.MiddleInst_ID. ... BottomInst_ID"
Transformations are applied from a WORLD perspective in the order listed:
   thus  (I   inst_ID   geom   (Xform A)   (Xform B)   (Xform C)  )  should result in:   [Xform C] * [Xform B] * [Xform A] * [geom]
   i.e., subsequent transformation matrices are applied "on the outside" = "away from the vector".
The (color ...) and (lod ...) attributes obey different hierarchical inheritance rules as follows:
COLORDuring rendering, each leaf of the hierarchical scene tree will get the color that is closest to the leaf; i.e. the lowest color in the hierarchy dominates.
    For example, if the sea is blue, containing a red instance of a school of fish, which contains a fish in that has not had its color set,
    then that fish should be colored red, while other fish that have been individually colored, keep that color.
    It may be prudent to start rendering with a default color (say medium gray (.5 .5 .5) so that everything shows up somehow.
LOD:  Levels of detail (LOD) are used to control the rendering effort on wants to expend on a subtree in the scene hierarchy.
    Normally that involves the fineness of geometrical detail and the level of subdivision of smooth surfaces.
    In A#3 we use a simplified scheme just based on shading and rendering levels to demonstrate the principle:
    LOD = 0 = none, render nothing at all.
    LOD = 1 = bounding box, render just the bounding box around this subtree of the instance hierarchy,
    LOD = 2 = outline, render the polygons as a colored "wire-frame" outline,
    LOD = 3 = flat-shaded, render all polygons filled-in, flat-shaded, e.g., colored and possibly painted in (as far as OpenGL can do it);
    LOD = 4 = fancy-shaded, render all polygons "fully", e.g., possibly textured, with fancy shading with highlights (ignore for A#3).
    LOD = 5 = ?? -- there could be more levels.
    During rendering, each node will get rendered according to the lowest LOD value occurring in the hierarchy above the node of interest.
    For example, if a node has LOD = none, the whole subtree can be ignored, and no nodes beneath it in the hierarchy are rendered.
B_BOXES are also calculated recursively during rendering. From the bottom leaf nodes, the bounding boxes for all objects are calculated;
    its four corners should be subjected to the instance transformations, and the extrema of all those transform points then yield the bounding box for the parent group.
    Each transformed bounding box can individually be surrounded with a (virtual) bounding box that can be compared agains the current view window for culling and clipping.
DYNAMIC_FLAG:  A flag may be set at the each group if there is anything dynamic (time-varying) below it that may force a re-evaluation of the bounding box.

Another hierarchical Scene: 18-Wheeler -- and how hierarchy needs to get modified when there is a flat tire.

Reading Assignments:

Study: ( i.e., try to understand fully, so that you can answer questions on an exam): 
Shirley, 2nd Ed: Ch 6.1, 6.3; Ch 13.3


Programming Assignment 2: 

Assignment #1 was worth 12 points  + a max of 2 extra credits.  ==> From now on we will do the accounting separately!
Assignment #2 is due (electronically submitted) before Thursday 2/12, 11:00pm.
Assignment #3 is due (electronically submitted) before Thursday 2/19, 11:00pm. <== THIS ASSIGNMENT CAN BE DONE IN PAIRS !
(A#4: basics of ray-tracing, will be done individually again)


PREVIOUS < - - - - > CS 184 HOME < - - - - > CURRENT < - - - - > NEXT
Page Editor: Carlo H. Séquin