General Triangle Models: Representations and Collision
description
Transcript of General Triangle Models: Representations and Collision
General Triangle Models:Representations and
CollisionDavid Johnson
Triangle Models►Boundary-
representation (B-rep) Collection of
surfaces to represent a volume
►Manifold Closed model Every edge has
two triangles
Polygon Modeling►Polygons are the dominant force
in modeling for real-time graphics►Why?
Polygons Dominate►Everything can be turned into
polygons (almost everything) Normally an error associated with the
conversion, but with time and space it may be possible to reduce this error
►We know how to render polygons quickly
►Many operations are easy to do with polygons
►Memory and disk space is cheap►Simplicity and inertia
What’s Bad About Polygons?►What are some disadvantages of
polygonal representations?
Polygons Aren’t Great► They are always an approximation to curved
surfaces But can be as good as you want, if you are willing
to pay in size Normal vectors are approximate They throw away information
► They can be very unstructured► They are hard to globally parameterize
How do we parameterize them for texture mapping?
► It is difficult to perform many geometric operations
Polygon Meshes► A mesh is a set of polygons connected to
form an object► A mesh has several components, or
geometric entities: Faces Edges, the boundary between faces Vertices, the boundaries between edges, or
where three or more faces meet Normals, Texture coordinates, colors, shading
coefficients, etc► Some components are implicit, given the
others For instance, given faces and vertices can
determine edges
Polygonal Data Structures► Polygon mesh data structures are
application dependent► Different applications require different
operations to be fast Find the neighbor of a given face Find the faces that surround a vertex
► You typically choose: Which features to store explicitly (vertices, faces,
normals, etc) Which relationships you want to be explicit
(vertices belonging to faces, neighbors, faces at a vertex, etc)
Triangle Meshes►We will look at triangle mesh data
structures Can triangulate general polygon
Triangle Soup
►Many models are just lists of triangles What does the model below look like in
a floating point computer?T1: v1, v2, v3T2: v4, v5, v6T3: v7, v8, v9T4: v10, v11, v12etc…
T1
T2 T3
T4T5 T6
Triangle Soup
►No connection between triangles Some models are produced like this, so
may have to work with it
T1: v1, v2, v3T2: v4, v5, v6T3: v7, v8, v9T4: v10, v11, v12etc…
T1
T2 T3
T4T5 T6
Triangle Soup Evaluation►What are the advantages?
It’s very simple to read, write, transmit, etc.
A common output format from CAD modelers
►BIG disadvantage: No higher order information No information about neighbors No open/closed information No guarantees on
degeneracies/manifoldness
Vertex-Face Mesh
► 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
► Advantages? Disadvantages?
v0
v2
v1v4
v3
v0 v2 v3 v4v1vertices
0 2 1 0 1 4 1 2 3 1 3 4faces
Vertex-Face Evaluation►Advantages:
Saving in storage:►Vertex index might be only 2 bytes, and a
vertex is probably 12 bytes►Each vertex gets used at least 3 and generally
4-6 times, but is only stored once Normals, texture coordinates, colors etc.
can all be stored the same way►Disadvantages:
Connectivity information is not explicit How would you find a neighbor
face/shared vertex?
Add more data►Face data structure
Face:►Neighbors = [find1, find2, find3]►Vertices = [vind1, vind2, vind3]
Vertex:►Coords = [x,y,z]►Neighborfaces = [find1,..,findn];
Some problems►Edges are implicit►Number of neighbors to vertex is
variable►Use vertex-edge-face structures
Winged edge Half-edge
Half-edge►Half-edge
leading vertex Face on left Edge ahead Flipped Edge
►Everything points to one thing
Collision Methods for Triangle Models
►Models may have millions of triangles►For two models with m and n triangles
Brute force: m*n triangle-triangle intersections
> 1012 intersection computations for two objects
►Need an acceleration structure
Bounding Volumes► Objects are often not
colliding Need fast reject for this
case Surround with some
bounding object►Like a sphere
► Why stop with one layer of rejection testing? Build a bounding volume
hierarchy (BVH)►A tree
Bounding Volume Hierarchies► Model Hierarchy:
each node has a simple volume that bounds a set of triangles
children contain volumes that each bound a different portion of the parent’s triangles
The leaves of the hierarchy usually contain individual triangles
► A binary bounding volume hierarchy:
BVH-Based Collision Detection
Type of Bounding Volumes► Spheres► Ellipsoids► Axis-Aligned Bounding Boxes (AABB)► Oriented Bounding Boxes (OBBs)► Convex Hulls► k-Discrete Orientation Polytopes (k-dop)► Spherical Shells ► Swept-Sphere Volumes (SSVs)
Point Swetp Spheres (PSS) Line Swept Spheres (LSS) Rectangle Swept Spheres (RSS) Triangle Swept Spheres (TSS)
Observations► Simple primitives (spheres, AABBs, etc.) do very well
with respect to the overlap cost. But they cannot fit some long skinny primitives tightly.
► More complex primitives (minimal ellipsoids, OBBs, etc.) provide tight fits, but checking for overlap between them is relatively expensive.
► Cost of BV updates needs to be considered.
Trade-off in Choosing BV’s
increasing complexity & tightness of fit
decreasing cost of (overlap tests + BV update)
AABB OBBSphere Convex Hull6-dop
Bounding Volume Hierarchies (Example: Spheres, PSS)
Bounding Volume Hierarchies (Example: AABB)
Bounding Volume Hierarchies (Example: k-DOPs,
k=6,14,18,26)
Level 0
Note: k=6 is a AABB.
Bounding Volume Hierarchies (Example: k-DOPs,
k=6,14,18,26)
Level 1
Bounding Volume Hierarchies (Example: k-DOPs,
k=6,14,18,26)
Level 2
Bounding Volume Hierarchies (Example: k-DOPs,
k=6,14,18,26)
Level 5
Bounding Volume Hierarchies (Example: k-DOPs,
k=6,14,18,26)
Level 8
Building Hierarchies ► Choices of Bounding Volumes
cost function & constraints
► Top-Down vs. Bottom-up speed vs. fitting
► Depth vs. breadth branching factors
► Splitting factors where & how
Sphere-Trees► A sphere-tree is a hierarchy of sets of spheres, used to
approximate an object
► Advantages: Simplicity in checking overlaps between two bounding
spheres Invariant to rotations and can apply the same transformation
to the centers, if objects are rigid
► Shortcomings: Not always the best approximation (esp bad for long, skinny
objects) Lack of good methods on building sphere-trees
Methods for Building Sphere-Trees
► “Tile” the triangles and build the tree bottom-up
► Covering each vertex with a sphere and group them together
► Compute the medial axis and use it as a skeleton for multi-res sphere-covering
► Others……
Building an OBBTree
Recursive top-down construction: partition and refit
Given some polygons,consider their vertices...
Building an OBB Tree
… and an arbitrary line
Building an OBB Tree
Project onto the line
Consider variance ofdistribution on the line
Building an OBB Tree
Different line,different variance
Building an OBB Tree
Maximum Variance
Building an OBB Tree
Minimal Variance
Building an OBB Tree
Given by eigenvectorsof covariance matrixof coordinatesof original points
Building an OBB Tree
Choose bounding boxoriented this way
Building an OBB Tree
Building an OBB Tree: FittingCovariance matrix ofpoint coordinates describesstatistical spread of cloud.
OBB is aligned with directions ofgreatest and least spread (which are guaranteed to be
orthogonal).
Good Box
Building an OBB Tree
Add points:worse Box
Building an OBB Tree
More points:terrible box
Building an OBB Tree
Compute with extremal points only
Building an OBB Tree
“Even” distribution: good box
Building an OBB Tree
“Uneven” distribution: bad box
Building an OBB Tree
Fix: Compute facets of convex hull...
Building an OBB Tree
Better: Integrate over facets
Building an OBB Tree
Building an OBB Tree
… and sample them uniformly
Building an OBB Tree: Summary
OBB Fitting algorithm:
►covariance-based►use of convex hull►not foiled by extreme distributions►O(n log n) fitting time for single BV►O(n log2 n) fitting time for entire tree
Tree Traversal
Disjoint bounding volumes:No possible collision
Overlapping bounding volumes:• split one box into children• test children against other box
Tree Traversal
Tree Traversal
Tree TraversalHierarchy of tests
Separating Axis Theorem
· L is a separating axis for OBBs A & B, since A & B become disjoint intervals under projection onto L
Separating Axis Theorem
Two polytopes A and B are disjoint iff there
exists a separating axis which is:
perpendicular to a face from either or
perpendicular to an edge from each
Implications of TheoremGiven two generic polytopes, each with E
edges and F faces, number of candidate axes to test is:
2F + E2
OBBs have only E = 3 distinct edge directions, and only F = 3 distinct face normals. OBBs need at most 15 axis tests.
Because edge directions and normals each form orthogonal frames, the axis tests are rather simple.
OBB Overlap Test: An Axis Test
sha
bas h h+>L is a separating axis iff:
L
hb
OBB Overlap Test: Axis Test Details
Box centers project to interval midpoints, somidpoint separation is length of vector T’s image.
A
B
nTAT
BT
s
nTT · BAs
OBB Overlap Test: Axis Test Details
► Half-length of interval is sum of box axis images.
n
B
rB
nRnRnR ··· BBBB bbbr 332211
Implementation: RAPID► Available at:
http://www.cs.unc.edu/~geom/OBB► Part of V-COLLIDE:
http://www.cs.unc.edu/~geom/V_COLLIDE
► Thousands of users have ftp’ed the code
► Used for virtual prototyping, dynamic simulation, robotics & computer animation