CS488 - Introduction to Computer Graphics - Lecture 30
Modelling
Polyhedra and Meshes
What is a polyhedron?
- A set of vertices
- Connected by edges
- Which define faces
Ray Tracer format
- Array of vertices (3 floats)
- Array of faces (pointers to vertices, needs to know number of
vertices)
- Build the arrays as you read the input.
Ray tracer requires intersection tests, normal calculation.
What does the ray tracer format give?
- Intersect a line with a plane
- Requires a vertex & the face normal
- Normal calculation requires three consecutive vertices
- Vertices are ordered so it's easy
Disadvantages
- Finding the faces that surround a vertex, or the edges that emanate
from a vertex
- must search linearly through the list of polygons
- Modifying the mesh.
- Add a vertex and a face
- easy because the user must specify the three vertices
- add the new vertex
- add the new face
- Add a vertex, split a face, need to find the face.
- user specifies face (O(# of faces)) & new vertex
- add new vertex
- overwrite old face
- add two new faces
- Deleting a face. ( O(# of faces))
- Splitting or deleting a vertex
- Need to find the faces that surround a vertex.
Augmented Ray Tracer Format
- Build a list of faces for each vertex when reading the input
- Can now find faces from vertices. To split a vertex
- Overwrite the deleted face with one of the new faces
- Add the other new faces to the end of the face array.
- General deletion is still hard, unless you are willing to tolerate
holes in the array.
Winged Edge Data Structure
When we talk about polyhedra & meshes it seems most natural to talk
about vertices
- edges are vertex pairs,
- faces are vertex n-tuples n>2.
And we have been most interested in vertices and faces. Meshes are, of
course, graphs
Every time we see a graph we should think,
In the dual edges are primary:
- vertices are where edges meet,
- faces are minimal closed paths
- topology of mesh is determined by edges
- which faces are bordered by which edges
Operations we want to do
- Faces that are neighbours of a vertex
- Faces that are neighbours of a face
- Vertices that are neighbours of a vertex
- Vertices that are neighbours of a face
- Modify the polyhedron
- Move a vertex
- Add a vertex, plus edges and faces
- Add an edge between two vertices, plus faces
- Delete various stuff, including disconnected vertices
Winged edge data structure
- Where does the name come from?
Each edge has
- pointers to the faces it separates
- pointers to the vertices at its ends
- pointers to the next and previous edges at each vertex
struct edge {
struct vert* v1, v2;
struct edge* nxt1, nxt2, prv1, prv2;
struct face* f1, f2;
}
Each vertex has
- one pointer to an edge
- Exercise. Why do you only need one?
struct vert {
struct *edge rep;
}
Each face has
- one pointer to an edge
- Exercise. Why do you only need one?
struct face {
struct *edge rep;
}
Note. Data suppressed in the above data structures.
Exercises for the reader: Write C code that demonstrates the following.
- Traversal. Can you find all neighbours quickly?
- Vertex/edge addition. Can you do it in constant time?
- Vertex/edge deletion. Can you do it in constant time?
Splines without Tears (or Jerks)
Why do splines exist at all?
- Sometimes we absolutely need curves
- Example: specifiying fonts for SVG
General piece-wise curves
- One example is line segments: you have been making them all along.
When you put them in a mesh there is an extra requirement
- They must join at the ends: end of one must be the start of the
next
- This is continuity.
For linear splines
- Blending is the key operation.
- Start with two points P1, P2
- Get the in-between points using P(t) = P1 + t(P2 - P1) for
0<t<1.
Linear curves necessarily give derivative discontinuities (called C1
continuity)
We can make the discontinuities unimportant by putting the points close
enough together
- That is, you give me a curve I can evaluate at any points,
- I can pick points close enough together that linear interpolation
between the points produces negilible derivative discontinuities.
- But how do you specify this curve?
- algebraic equation
- OR ???
The usual way is a piecewise continuous non-linear curve, with as much
continuitity as you desire at the joins.
Non-linear blending
- Start with three points P1, P2, P3
- Blend in pairs
- P10(t) = P1 + t (P2 - P1)
- P11(t) = P2 + t (P3 - P2)
- Blend the blend
- P20(t) = P10(t) + t (P11(t) - P10(t))
- The result is a quadratic curve
You can take this to as many levels as you want. What does it give you?
Continuity. Which is?
- To get rid of them you need higher order curves.
- Actually third order ones.
- How does this do it?
Now you have a way of making smooth-enough curves specified by a small
number of points.
Why is it important to have them available?
Return to: