Title: G53GRA
1G53GRA Modelling
2Modelling Overview
- A model is a description of an object. Modeling
is the process of describing the object - Sometimes the description is an end product in
itself, e.g., computer aided design - More typically in graphics, the model is then
used for rendering - The model only exists to produce a picture
- It can be an approximation, as long as the visual
result is ok - The computer graphics motto If it looks right
it is right, but it doesnt work for CAD
3Modelling Techniques
- There are many ways to represent an object. What
should be considered when choosing a
representation? - Surface vs. Volume
- Sometimes we only care about the surface
- Rendering and geometric computations
- Sometimes we want to know about the volume
- Some representations are best thought of defining
the space filled, rather than the surface around
the space - Medical data with information attached to the
space - Parametric vs. Implicit
- Parametric generates all the points on a surface
(volume) by plugging in a parameter eg (sin?
cos?, sin? sin?, cos?) - Implicit models tell you if a point in on (in)
the surface (volume) eg x2 y2 z2- 1 0
4Choosing a Representation
- How well does it represents the objects of
interest? - How easy is it to create?
- By hand, procedurally, by fitting to
measurements, - How easy is it to render (or convert to
polygons)? - How compact is it (how cheap to store and
transmit)? - How easy is it to interact with?
- Modifying it, animating it
- How easy is it to perform geometric computations?
- Distance, intersection, normal vectors,
curvature,
5Level of Detail
- Represent objects in a scene at several
resolutions, or decrease the complexity of
object representation as it moves away from the
viewer or according other metrics
- http//lodbook.com/
- The basic concept is to provide various models to
represent the same object - Must have a way to switch from one mesh to
another - Also called mesh decimation, multi-resolution
modeling etc
http//www.cs.unc.edu/geom/SUCC_MAP/
6Polygonal Models
- Polygons are the most popular in modeling for
real-time graphics - Everything can be turned into polygons (almost
everything) - The concept is easy to understand.
- A common output format from CAD modelers
- Many operations are easy to do with polygons
- We know how to render polygons quickly
- Memory and disk space is cheap
7Polygonal Models
- A polygonal model has several components, or
geometric entities - Faces
- Edges (boundaries between faces)
- Vertices (boundaries between edges)
- Normals, texture coordinates, colors, shading
coefficients, etc - Some components are implicit, given the others
- For instance, given faces and vertices can
determine edges - Eulers formula Faces Vertices Edges 2,
for any polyhedron that doesn't intersect itself - A polygonal mesh is a set of polygons connected
to form a mesh
8Polygonal Models
- There are reasons not to store the vertices
explicitly at each polygon - Wastes memory - each vertex repeated many times
- Very messy to find neighboring polygons
- Difficult to ensure that polygons meet correctly
- Solution Indirection
- Put all the vertices in a list
- Each face stores the list indices of its vertices
- Minimizes amount of data sent to the renderer
- Fewer function calls, faster!
9Polygonal Models
- Polygonal data structures are application
dependent. Different applications require
different operations to be fast - Find the neighbours of a given face
- Find the faces that surround a vertex
- Intersect two polygon meshes
- You typically choose
- Which features to store explicitly (vertices,
edge faces, normals) - Which relationships you want to be explicit
(vertices belonging to edges, edges belonging to
faces, faces at a vertex, etc)
10Modelling a Cube
- A model can be obtained by slicing along certain
edges of a solid and unfolding it to lie flat so
that all polygons are seen from the outside
6
5
6
2
1
6
6
5
3
2
4
1
7
3
0
4
7
5
7
4
11Modelling a Cube
y
Vertex array Vi012 V1(-1,-1,1) V2(-1,1,1
) V3(1,1,1) V4(1,-1,1) V5(1,-1,-1) V6(1,1,-1)
V7(-1,1,-1) V8(-1,-1,-1)
7
-1,1,-1
6
1,1,-1
1,2,3,4, // front face 5,6,7,8 // back face
3,2,7,6 // top face 1,3,5,4 // bottom face
3,6,5,4 // right face 1,2,7,8 // left face
2
-1,1,1
o
3
8
1,1,1
-1,-1,-1
5
1
x
1,-1,-1
-1,-1,1
z
4
1,-1,1
12Normal Vectors
- Normal vectors give information about the true
surface shape - Per-Face normals
- One normal vector for each face, stored as part
of face - Flat shading
- Per-Vertex normals
- A normal specified for every vertex (smooth
shading) - Can keep an array of normals analogous to array
of vertices - Faces store vertex indices and normal indices
separately - Allows for normal sharing independent of vertex
sharing
13A Cube
Vertices (1,1,1) (-1,1,1) (-1,-1,1) (1,-1,1) (1,1
,-1) (-1,1,-1) (-1,-1,-1) (1,-1,-1)
Normals (1,0,0) (-1,0,0) (0,1,0) (0,-1,0) (0,0,1)
(0,0,-1)
Faces ((vert,norm), ) ((0,4),(1,4),(2,4),(3,4))
((0,0),(3,0),(7,0),(4,0)) ((0,2),(4,2),(5,2),(1,2)
) ((2,1),(1,1),(5,1),(6,1)) ((3,3),(2,3),(6,3),(7,
3)) ((7,5),(6,5),(5,5),(4,5))
14Modelling Tetrahedron
15Modelling Prism
y
x
16Whats Bad About Polygons?
- They are an approximation to curved surfaces.
Most real-world surfaces are curved, particularly
natural surfaces, but approximation can be as
good as you want - Quite difficult to create a complex model
- They are unstructured
- They are hard to globally parameterize
- It is difficult to perform many geometric
operations
17Meshes from Scanning
- Laser scanners sample 3D positions
- One method uses laser triangulation a thin
stripe of laser light is projected across the
object surface and is viewed by a camera.
Stereoscopic method uses the positions of the
camera and laser emitter to compute the 3D
positions of points on the laser stripe - Another uses time of flight shoots a laser pulse
at the object and measures the time taken for the
pulse to return to the scanner, distancespeed of
light time - Software then takes thousands of points and
builds a polygon mesh out of them - Research topics
- Reduce the number of points in the mesh
- Reconstruction and re-sampling!
18Scanning in Action
- http//www-graphics.stanford.edu/projects/mich/
19Alternative Object Representations
- Sweep Objects
- Hierarchical modeling
- Constructive Solid Geometry
- Octrees
- Metaballs/Blobs
- Production rules
- Procedural methods
20Sweep Objects
- Define a polygon by its edges
- Sweep it along a path
- The path taken by the edges form a surface - the
sweep surface - Special cases
- Surface of revolution Rotate edges about an axis
- Extrusion Sweep along a straight line
21Hierarchical Modelling
- A hierarchical model unites several instances
into one object, for example a desk is made up
of many blocks - Generally represented as a tree, with
transformations and instances at each node - Rendered by traversing the tree, applying the
transformations, and rendering the instances - Particularly useful for animation
- Human is a hierarchy of body, head, upper arm,
lower arm, etc - Animate by changing the transformations at the
nodes
22Hierarchical Model Example
- Vitally Important Point
- Every node has its own local coordinate system.
- This makes specifying transformations much easier.
23OpenGL Support
- OpenGL defines glPushMatrix() and glPopMatrix()
- Takes the current matrix and pushes it onto a
stack, or pops the matrix off the top of the
stack and makes it the current matrix - Note Pushing does not change the current matrix
- Rendering a hierarchy (recursive)
RenderNode(tree) glPushMatrix() Apply node
transformation Draw node contents RenderNode(c
hildren) glPopMatrix()
24Recursive Hierarchical Modeling
- By applying small transforms to every level of
the scene graph, a recursive model can quickly
generate some amazing images.
25Constructive Solid Geometry
- Based on a tree structure, like hierarchical
modeling, but now - The internal nodes are set operations union,
intersection or difference (sometimes complement) - The edges of the tree have transformations
associated with them - The leaves contain only geometry
- Allows complex shapes with only a few primitives
- Common primitives are cylinders, cubes, etc, or
quadric surfaces - Motivated by computer aided design and
manufacture - Difference is like drilling or milling
- A common format in CAD products
26CSG Example
27CSG Summary
- Advantages
- Good for describing many things, particularly
machined objects - Better if the primitive set is rich
- Moderately intuitive and easy to understand
- Disadvantages
- Not a good match for polygon renderers
- Some objects may be very hard to describe, if at
all - Geometric computations are sometimes easy,
sometimes hard
28Spatial Data Structures
- Basic idea describe object by the space it
occupies - For example, break a volume of interest into lots
of tiny cubes, and say which cubes are inside the
object - Works well for things like medical data
- The process itself, like MRI or CAT scans,
enumerates the volume - Data is associated with each voxel (volume
element) - Problem to overcome
- For anything other than small volumes or low
resolutions, the number of voxels explodes - Note that the number of voxels grows with the
cube of linear dimension
29Spatial Data Structures
- Octrees are an example of a spatial data
structure - A data structure specifically designed for
storing information of a spatial nature - In graphics, octrees are frequently used to store
information about where polygons, or other
primitives, are located in a scene - Speeds up many computations by making it fast to
determine when something is relevant or not - Other spatial data structures include BSP (binary
space partitioning) trees, KD-Trees, Interval
trees,
30Quadtrees (and Octrees)
- Build a tree where successive levels represent
better resolution (smaller voxels) - Large uniform spaces result in shallow trees
- Quadtree is for 2D (four children for each node)
- Octree is for 3D (eight children for each node)
top left
top right
bot left
bot right
31Rendering Octrees
- Volume rendering renders octrees and associated
data directly - A special area of graphics, visualization, not
covered in this class, will be covered in G54CGA - Can convert to polygons by a few methods
- Just take faces of voxels that are on the
boundary - Find isosurfaces within the volume and render
those - Typically do some interpolation (smoothing) to
get rid of the artifacts from the voxelization
32Implicit Functions
- Some objects are easy represent this way
- Spheres, ellipses, and similar
- More generally, quadratic surfaces
- Shapes depends on all the parameters
a,b,c,d,e,f,g - Some surfaces can be represented as the vanishing
points of functions in 3D space, e.g., points
where a function f(x,y,z)0 - Rendering implicit surfaces
- Raytracing - find ray and surface intersections
- For polygonal renderer, must convert to polygons
33Metaballs/Blobs
- Implicit modeling technique
- We can think of a metaball as a particle
surrounded by a density field, where the density
(particle influence) decreases with distance from
the particle location - A surface is implied by taking an isosurface
through this density field - the higher the
isosurface value, the nearer it will be to the
particle
- An isosurface is a surface in 3D space whose
points render a function constant think about a
special instance of implicit function f(x,y,z)
c, similar to the contours on a topographic map
34Metaballs
- The key to using metaballs is the definition of
the equation for specifying the influence of a
particle on an arbitrary point - Blinn used exponentially decaying fields for each
particle, with a Gaussian function with height b
and standard deviation a - If r is the distance
from the particle to a location in the field, the
influence of the particle on the location is
bexp(-ar). The resulting density of an arbitrary
location in the field is simply the summation of
the contributions from all the particles.
35Metaballs
- Can combine (add together) multiple primitives
into a complex object - by summing the influences
of each metaball on a given point, we can get a
smooth blending of the influence fields - This results in automatic blending of shapes
36Metaballs
- Metaballs are a type of implicit modeling
technique. - Think of a metaball as a particle surrounded by
a density field, where the density decreases with
distance from the particle location. - A surface is implied by taking an isosurface
through this density field - the higher the
isosurface value, the nearer it will be to the
particle. - Metaballs can be combined. By simply summing the
influences of the metaballs on a given point, we
can get a very smooth blending of the spherical
influence fields
37Rewriting Systems
- Rewriting is a technique for defining complex
objects by successively replacing parts of a
simple initial object using a set of rewriting
rules or productions - Works best for things like plants
- Start with a stem
- Replace it with stem branches
- Replace some part with more stem branches, and
so on - Best understood rewriting systems operate on
character strings, and the methods for
generating, recognizing and transforming them - Essentially, generate a string that describes the
object, replace sub-strings with some new strings - Can generate a garden or forest
38Rewriting Systems
39A Simple L-System
- Biologist, Aristid Lindenmayer, introduced a
string-rewriting mechanism in 1968 , termed
L-systems. An example - Production rules below are applied
- b ? a.
- a ? ab.
- We now have word ab.
- In the next derivation step, a is replaced by ab,
b is replaced by a, so we have word aba - Similar way, the string aba yields abaab which in
turn yields abaababa, then abaababaabaab, and so
on
40 Graphical Representation of L-System
- Letters of the L-system alphabet are represented
graphically as shorter or longer rectangles with
rounded corners. The generated structures are
one-dimensional chains of rectangles, reflecting
the sequence of symbols in the corresponding
strings. - In order to model higher plants, a more
sophisticated graphical interpretation of
L-systems is needed. - The geometric aspects, such as the lengths of
line segments and the angle values, were added in
a post-processing phase.
41Graphical Representation of L-System
- F Move forward a step of length d. The state of
the turtlechanges to (x, y, a), where x x d
cos a and y y d sin a. A line segment between
points (x, y) and (x, y) is drawn. - f Move forward a step of length d without
drawing a line. - Turn left by angle d. The next state (of the
turtle) is - (x, y, ad). The positive orientation of angles
is counterclockwise. - - Turn right by angle d. The next state (of the
turtle) is - (x, y, a - d).
42Representation of L-System
- Interpreting strings generated by the following
L-system - a
- F - F - F - F
- b
- F ? F - F F FF - F - F F
43Representation of L-System
- Axial trees (at each node, at most one straight
segment, zero or more side segments) can be
represented using strings with brackets - Push the current state of the turtle onto a
pushdown operations stack. The information saved
on the stack contains the turtles position and
orientation, and possibly other attributes such
as the color and width of lines being drawn - Pop a state from the stack and make it the
current state of the turtle.
44L-Systems Generator
Prusinkiewicz, Hammel, Mech http//www.cpsc.ucalga
ry.ca/projects/bmv/vmm/title.html
45L-Systems
Prusinkiewicz, Hammel, Mech http//www.cpsc.ucalga
ry.ca/projects/bmv/vmm/title.html
46Procedural Methods Swarm Intelligence
47Procedural Methods - Particle Systems
- Particles have positions and velocity in the
scene and these are tracked and updated - To create fire
- Constantly create particles
- Particles move upwards, with turbulence added
- Draw them as partially transparent circles that
fade over time
48Procedural Methods - Physical Systems
- Describe in mathematical terms how objects behave
when forces are applied to them