Polygon Surfaces
- Basic form of representation.
- In some systems, all objects are described as polygon surfaces.
For example,
Inventor.
- Polygons are easy to process, so rendering and display of objects is sped up.
Thus, some systems allow objects to be described in other ways (such as
splines), but reduce all objects to polygons for processing.
- For a polygon, the representation is exact. For other surfaces, polygons
are tiled in a polygon-mesh which approximates the object. As we noticed
in Inventor and in project 2, objects can be approximated with triangles.
- How do we represent these polygons?
Polygon Tables
- We specify objects as a set of vertices and associated attributes.
This information can be stored in tables, of which there are two
types: geometric tables and attribute tables.
- The geometry can be stored as three tables: a vertex table, an edge
table, and a polygon table. Each entry in the vertex table is a
list of coordinates defining that point. Each entry in the edge
table consists of a pointer to each endpoint of that edge. And the
entries in the polygon table define a polygon by providing pointers
to the edges that make up the polygon.
- We can eliminate the edge table by letting the polygon table reference
the vertices directly, but we can run into problems, such as drawing some
edges twice, because we don't realize that we have visited the same
set of points before, in a different polygon. We could go even further
and eliminate the vertex table by listing all the coordinates explicitly
in the polygon table, but this wastes space because the same points appear
in the polygon table several times.
- Using all three tables also allows for certain kinds of error checking.
We can confirm that each polygon is closed, that each point in the vertex
table is used in the edge table and that each edge is used in the polygon
table.
- Tables also allow us to store additional information. Each entry in the
edge table could have a pointer back to the polygons that make use of it.
This would allow for quick look-up of those edges which are shared
between polygons. We could also store the slope of each edge or the
bounding box for each polygon--values which are repeatedly used in
rendering and so would be handy to have stored with the data.
Example: Plane Equations
- Often in the graphics pipeline, we need to know the orientation of an
object. It would be useful to store the plane equation with the polygons
so that this information doesn't have to be computed each time.
- The plane equation takes the form:
Ax + By + Cz + D = 0
Using any three points from a polygon, we can solve for the coefficients.
Then we can use the equation to determine whether a point is on the inside
or outside of the plane formed by this polygon:
Ax + By + Cz + D < 0 ==> inside
Ax + By + Cz + D > 0 ==> outside
- The coefficients A, B, and C can also be used to determine a vector normal
to the plane of the polygon. This vector, called the surface normal, is
given simply by:
N = (A, B, C).
- If we specify the vertices of a polygon counterclockwise when viewing the
outer side, in a right-handed coordinate system, the surface normal N will
point from inside to outside. You can verify this from an alternate definition
for N, based on three vertices:
N = (V2 - V1) x (V3 - V1) = (A, B, C)
If we find N in this way, we still need D to complete the plane equation.
The value of D is simply the dot product of the surface normal with any
point in the polygon:
N . P = -D
Polygon Meshes
- The polygons we can represent can be arbitrarily large, both in terms of
the number of vertices and the area. It is generally convenient and more
appropriate to use a polygon mesh rather than a single mammoth polygon.
- For example, you can simplify the process of rendering polygons by breaking
all polygons into triangles. Then your triangle renderer from project two
would be powerful enough to render every polygon. Triangle renderers can
also be implemented in hardware, making it advantageous to break the world
down into triangles.
- Another example where smaller polygons are better is the Inventor lighting
model. Inventor computes lighting at vertices and interpolates the values
in the interiors of the polygons. By breaking larger surfaces into
meshes of smaller polygons, the lighting approximation is improved.
- Triangle mesh produces n-2 triangles from a polygon of n vertices.
- Quadrilateral mesh produces (n-1) by (m-1) quadrilaterals from an n x m
array of vertices.
- Specifying polygons with more than three vertices could result in
sets of points which are not co-planar! There are two ways to solve
this problem:
- Break the polygon into triangles, and deal
- Approximate A, B, and C in the plane equation.
This can be done either by averaging or by projecting the polygon
onto the coordinate planes. A should be proportional to the
projection in the yz-plane, B proportional to xz, and C proportional
to xy.
Spatial Data
Structures
We will use heirarchical tree structures to
store object information.
Why?
- Reduce Storage Space
- Speed up visibility computations
Let's start with 2D.
Quadtrees
Definition
Based on the divided-and-conquer principle, a quadtree is a
data structure that recursively subdivides a plane into 4
quadrants.
The decision to subdivide is based on an attribute
of the current quadrant. If the quadrant is heterogeneous with
respect to this attribute, further subdivision occurs. If it
is homogeneous, or we have reached the desired level of detail,
we stop subdividing.
We will apply quadtrees to storing planar polygons.
Our attribute will be whether current quadrant is filled by the
interior of a polygon:
The succesive subdivisions can be reprensented as a tree with
heterogeneous quadrants as nodes and homogeneous quadrants as leaves.
Here, we are grouping by color:
F: Full ; E: Empty; P: Partially Full
For an area containing 2^n by 2^n pixels, a quadtree representation contains
at most n levels.
Octrees
Octrees are based on the same principle, but divide regions of 3D space
(usually into cubes).
The scene is subdivided at each step with three mutually perpendicular planes, aligned
with the Cartesian coordinate planes.
Individual partitions of 3D space are called Voxels (Volume Elements).
Applications: raycasting, shadowcasting.
Octrees, like Quadtrees, use a node structure to store the
volume elements:
In this figure, the octree has been refined twice.
First, the root is refined into eight
cells, each representing an octant of the root's domain. Then, one of
the root's children is refined yet again.
Here is an example of a fully subdivided torus:
BSP Trees
Binary Space-Partitiong Trees subdivide space into 2 halves at every step.
The plane of subdivision can have any position and orientation.
This reduces tree depth and search time as compared to an octree.
BSP Trees for Polygons
We can represent a polygon with a BSP tree.
Let each face of the polygon coincide with a partitioning plane of the
tree.
Now, each node of the tree encodes a face of the polygon.
Each leaf of the tree is either inside or outside of the polygon.
It is easy to find out if a given point is inside the
polygon; put it in the tree and see if it ends up in a + or - leaf (also
have case of point exactly on a plane)
Let v be a node, p a point
point_classify( v, p
)
if v
is a leaf
return leaf's value ("in" or "out")
else
if p
is on negative side of plane( v )
return point_classify( v.left,
p )
else
if p
is on positive side of plane( v )
return point_classify( v.right,
p )
else (p is
on the plane)
l = point_classify( p, v.left
)
r = point_classify( p, v.right
)
if l
= r
else
Constructive Solid-Geometry Methods
Constructive models represent a solid as a combination of primitive solids. (CSG)
Sweep Representation
Specifying a 2D shape and a sweep that moves the shape through a region
of space.
We perform a sweep by moving the shape along a path.
At intervals along this path, we replicate the shape and draw a set
of connectiong line in the direction of the sweep to obtain the wireframe
reprensentation.
Example of torus designed using a rotational sweep. The periodic
spline cross section is rotated about an axis of rotation specified in
the plane of the cross section.
Implicit/mathematical definition. Difficult to implement.
Constructive Solid Geometry (CSG)
1. Definition
- Combine volume occupied by overlapping 3D objects using set boolean operations
- Each primitive is defined as a combination of half-spaces.
- Typical standard primitives are:
cone, cylinder, sphere, torus, block, closed spline surface, right
angular wedge. swept solids (a revolution or linear sweep of a planar
face which may contain holes.
- Operations are union, intersection and difference.
2. Implementation with ray casting
Ray Casting is often used to implement CSG operation when objects are described with boundary
representation. We fire a ray from the plane xy (which represent the screen). The surface
limits for the composite object are determnined bu the specified set operation (see Table).
Operation
|
Surface Limit
|
Union
|
A, D
|
Intersection
|
C, B
|
Difference (Obj2 - Obj1)
|
B, D
|
This method can also be used for physical simulation.
Visualization
The use of graphical methods to aid in analysis,
often of datasets so large or complex they can not be conseptualized otherwise.
The analysed data can be scalars, vectors, tensors, or a combination of these
types.
An example of visualization. Proteins are too complex to describe verbally
Scalar Fields
- Graphs/charts
- Pseudo-color
- Countour plots, isolines
A topographic map of Marfa, Texas. Topographical maps are the most common utilization of isolinear plots.
Volume Rendering
Project the data into 2D using ray casting, but the 2D value can be some
function of the values along that ray.
Examples:
- Max/min values
- Accumulate the opacity of points until it reaches 1 or the ray passes through
(X-rays).
The Visualization Toolkit is a cool program
for doing some of these applications.
Physically Based Modelling Methods
- Physical modelling is a way of describing the behavior of an object in
terms of the interactions of external and internal forces.
- Simple methods for describing motion usually resort to having the object
follow a pre-determined trajectory.
- Physical modelling, on the other hand, is about dynamics.
- Physically based modelling methods will tell show us how a table-cloth
will drape over a table or how a curtain will fall from a window.
- A common method for approximating such nonrigid objects is as a network
of points with flexible connections between them.
Spring Networks
- A simple type of connection is a spring.
- When external forces are applied, the amount of stretching or compression
depends on the properties of the spring. For the simple spring, this is
just the spring constant k, and the restoring force is given by F = -kx.
- If the object is completely flexible, it will return to its original
configuration when external forces are removed. If want to model puddy,
which deforms, we would need a more complicated model of the spring.
- We can also model specific materials by replacing the spring model with
the strain-energy function of the desired material.
- An example of this type
of modelling can be seen in a previous 6.837 project.
Particle Systems
- Allow us to describe natural or irregular shaped objects which are
flowing or fluid-like, particular objects which are changing over time.
- We can model objects, like grass, which are not actually composed of
particles but which are fluid in form.
- We can also model objects, like waterfalls and fireworks, which are
actual physical processes that we can attempt to model through particles.