Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
General Triangle Models: Representations and Collision David Johnson Triangle Models ► Boundary- representation (Brep) 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? T4 T1 T2 T5 T3 T6 T1: v1, v2, v3 T2: v4, v5, v6 T3: v7, v8, v9 T4: v10, v11, v12 etc… Triangle Soup ► No connection between triangles Some models are produced like this, so may have to work with it T4 T1 T2 T5 T3 T6 T1: v1, v2, v3 T2: v4, v5, v6 T3: v7, v8, v9 T4: v10, v11, v12 etc… 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 v0 v4 v1 v2 vertices faces 0 2 1 v0 v1 v2 v3 v4 0 1 4 1 2 3 1 3 4 v3 ► 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? 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 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 Sphere AABB OBB 6-dop Convex Hull increasing complexity & tightness of fit decreasing cost of (overlap tests + BV update) 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 sphere-tree is a hierarchy of sets of spheres, used to approximate an object ►A ► 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 SphereTrees ► “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 Building an OBB Tree Given some polygons, consider their vertices... Building an OBB Tree … and an arbitrary line Building an OBB Tree Project onto the line Consider variance of distribution 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 eigenvectors of covariance matrix of coordinates of original points Building an OBB Tree Choose bounding box oriented this way Building an OBB Tree: Fitting Covariance matrix of point coordinates describes statistical spread of cloud. OBB is aligned with directions of greatest and least spread (which are guaranteed to be orthogonal). Building an OBB Tree 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 … 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 Tree Traversal Overlapping bounding volumes: • split one box into children • test children against other box Tree Traversal Tree Traversal Hierarchy 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 Theorem Given 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 L s ha hb L is a separating axis iff: s > ha+hb OBB Overlap Test: Axis Test Details Box centers project to interval midpoints, so midpoint separation is length of vector T’s image. B TB A TA T n s s T T n A B OBB Overlap Test: Axis Test Details ► Half-length of interval is sum of box axis images. B rB n rB b1 R1B n b2 R 2B n b3 R 3B n Implementation: RAPID ► Available at: http://www.cs.unc.edu/~geom/OBB ► Part of V-COLLIDE: http://www.cs.unc.edu/~geom/V_COLLIDE ► Thousands ► Used of users have ftp’ed the code for virtual prototyping, dynamic simulation, robotics & computer animation