Collision Detection between Cloth and a Solid ... - Semantic Scholar

5 downloads 0 Views 808KB Size Report
Jun 4, 2015 - [4] Mark Meyer. Gilles Debunne. Mathieu Desbrun. Alan H. Barr. “Interactive Animation of Cloth-like Objects in Virtual. Reality”. Journal of ...
ISBN 978-93-84422-22-6 Proceedings of 2015 International Conference on Image Processing, Production and Computer Science (ICIPCS'2015) Istanbul (Turkey), June 3-4, 2015 pp. 8-13

Collision Detection between Cloth and a Solid Object using Mass Spring Model and Bounding Volume Hierarchy Nur Saadah Mohd Shapri1, Riza Sulaiman2, Abdullah Bade3 12

Faculty of Information Science and Technology, Universiti Kebangsaan Malaysia 3 School of Engineering & Information Technology, Universiti Malaysia Sabah 1 nursaadah5 {at} gmail.com, 2rizsulaiman {at} gmail.com, 3abb {at} ums.edu.my

Abstract: This paper presents the problem of performing collision detection between cloth and the solid object in real-time simulation. In order to achieve the fast collision detection and to help in collision computation, we propose a self-created Axis-Aligned Bounding Box (AABB) hierarchy. These AABBs can help in reducing the time needed to compute collision resolution.

Keywords: Cloth Simulation, Collision Detection, Bounding Volume Hierarchy

1. Introduction Cloth plays an important role in our life and also in the virtual environment world as the advancement in the computer hardware industry and rapid research done in the simulation field of cloth. Cloth in real life can be manipulated freely but it does not have the ability to be manipulated in virtual world as the time taken to compute cloth properties to be as real as in real time will be very time consuming. In computer animation field, cloth and also flexible material simulation is treated as an important aspect for creating realistic virtual humans and dynamic environment. New emerging technologies such as interactive digital television and multimedia products provides a base tool to perform real time simulations which is powerful although it can’t produce very accurate and realistic result as non-real time simulations. The cloth simulation can be either in real time or non-real time which can be breakdown to many component compromising difference technique and method to make the final cloth appearance as real as possible. Among those components, the main component will be highlighted such as the cloth model creation method, the mass physical properties representing the cloth, collision technique used, collision detection and also collision resolution method as those components will have impact on the overall computation time and needs to take extra remark when constantly creating the cloth object in the simulation system.

2. Mass Spring Model Mass spring model is the most famous model for cloth model [1, 2, 3]. Spring-mass system particles are connected by massless spring of non-zero natural length and there are may be composed more than two particles. When a gravity force is applied to the particles, it produces a velocity for each particle to update its position. The new position of each particle can change the length for each spring-damper connection. [2] argued that cloth is not a homogeneous material but a mechanism of threads woven into an interlocking network and the fabric is not held together by molecular bonds but by friction. Euler integration method has been the standard way to use with particle system model as it calculates the time history of the particle trajectory efficiently. As cloth simulation takes into consideration of internal and external force which may account to large force magnitudes, the integration method will not be suitable as it will be unstable and undesired result might occur as stated in [1] where they used Implicit Euler Integration. The downside of using Euler integration increases when

http://dx.doi.org/10.17758/UR.U0615002

8

collision handling is involved as the particle trajectory result will be unstable. [4] suggested that each particles velocity within the objects should be corrected after each time step using the equation shown below: vm j = vm j

m−1 xm j − xj

dt

xm j

(1) represent x m−1 j

the positions at the current and the and represent the velocity of the particles, Where previous time step and dt represents the infinitesimal time step. As to achieve a more numerically stable model when considering particle position at difference time steps, verlet integration method is being introduced where the position of the particle are computed without using any velocity term. The method of verlet integration is shown as below: fm j

m m−1 x m+1 = xm + dt 2 n j j + xj − xj

(2)

j

Where fj represent the accumulated external forces and nj represent the particle mass. With this equation in 2, the cloth particle system can be introduced with damping force that could affect the appearance of the cloth as small amount of dragging effect can be achieved. The equation with the used of damping force is shown as below: fm

m−1 m ) + dt 2 j = xm x m+1 j + (1 − K d )( x j − x j j n

j

(3)

[5] Presented a model where each particle in the grid is connected to its four nearest neighbors by stiff stretch springs. Each particle is also connected to its four diagonal neighbors by (less stiff) shear springs. Finally, each particle is connected to its eight next-nearest neighbors by (weak) non-linear bend springs. Fig. 1 below illustrates the three types of springs and how they are connected to the particles:  Structural springs: Handle extension and compression and are connected vertically and horizontally.  Shear springs: Handle shear stresses and are connected diagonally.  Bend springs: Handle bending stresses and are connected vertically and horizontally to every other particle.

Fig. 1: Three types of springs a) Structural spring b) Shear spring c) Bend spring

[6] Used a mass-spring model to describe rigid cloth behavior which proved to be faster than the techniques described above. His algorithm checks the length of each spring after iterations and modifies the positions of the ends of the spring if it exceeds its natural length with more than a certain value (10% for example) as shown in Fig. 2. However, the major drawback is super elasticity but to overcome this problem, [6] applied a position modification algorithm to the ends of the over elongated springs but other spring would be elongated if this operation modifies too many vertices position.

Too Large Rest Length Too Short Fig. 2: Concept of constraint operation when two particle point distance is as shown.

When the distance between the two nodes the spring is connected two is equal to the resting length, the spring is not affecting the two nodes with any force. When the distance between the nodes is greater than the

http://dx.doi.org/10.17758/UR.U0615002

9

resting length, the spring will apply a force to them, thus trying to move them closer, and vice versa. The spring force is linear to the displacement, and a spring coefficient controls the stiffness of the spring. The higher the coefficient is, the stiffer the cloth will be. A higher spring coefficient will make the system more unstable. External force such as aerodynamics and friction will help in producing realistic cloth simulations. The following is formulation for the external force F, similar to [7]: 1

(4) Fair = 2 pcw A(n̂ × vrel ) vrel Where, P represent specified weight of air, cw represent resistance coefficient, A represent surface area represented by the particle, n̂ represent unit surface normal at that point and vrel represent the velocity of the particle with respect to an ambient wind vector. [8] can be referred to for a more realistic treatment of aerodynamic effects in cloth simulation.

3.

Cloth Collision Detection

A widely used method for detecting cloth collisions is to put small repellent proximity forces between the cloth surface and the deformable rigid or cloth surface as describe by [1, 2, 9]) while the actual collisions are tested with pairs of particle-face or face-face of the current positions. Bounding Volume Hierarchy (BVH) can be easily employed to accelerate collisions among the BVs that are used widely to build coarse representations of the objects are spheres [10, 11], ellipsoids, Axis Aligned Bounding Boxes (AABB) [12], Oriented Bounding Boxes (OBB) [13], Binary Space Partition Trees (BSP-Trees) and Quantized Orientation Slabs with Primary Orientations (QuOSPOs) [14]. An adaptive spatial subdivision of the object space based on Oc-tree structure has been introduced by [15]. Another popular approach to collision detection is based on Voronoi diagrams [16] where spatial and temporal coherence has also been exploited. [17] have described a method to solve collision detection for flexible objects composed of polygons. [4] have used a hybrid explicit/implicit integration algorithm to animate real-time clothes which integrated as a Voxel-based collision detection algorithm but it seems to be limited by the maximum number of polygons that can animate in real-time. [18] proposed to use the z-buffer for collision detection to generate depth and normal maps. Computation time of their collision detection does not depend on the complexity of the body. However, the maps need to be pre-computed before simulation, restricting the real-time application. Some research and approach has been carried out by [19,20,21,22] in providing fast and suitable intercollision checks using Bounding Volume Hierarchy (BVH). BVH can be constructed using bottom-up or topdown approach where leaf node holds the primitive type.

4. Cloth Collision Resolution Numerous approaches proposed by [9,23,1,6] have been introduced for cloth collision resolution: the correct next positions and velocities of colliding cloth particles. So far, however, no cloth collision resolution method which considers cloth-cloth momentum conservation has been introduced, while we cannot achieve realistic cloth interactions in cloth animation without conserving cloth-cloth momentums. Having this characteristic is visually distinctive when cloth surfaces are moving fast and interact with each other.

5. AABBs Hierarchy The first part of the computation process would be to create the bounding box for the vertex points of the cloth for collision resolution purpose. All of the cloth vertex point will be bounded with bounding box first which is also known as leaf node (Fig. 3).

http://dx.doi.org/10.17758/UR.U0615002

10

Fig. 3: Grouping of vertex and triangle point as a bounding box

The second step would be to create a main bounding box that bound the whole cloth vertex point and recursively subdivide into 8 child node where each child node will contain the bounding box of the primitive intersecting in it. When the child node is less than 8, no more subdivide of the space is done. Therefore, there exist only 1 bounding box first and all child bounding box are linked together in a hierarchical tree since it will provide the smallest number of overlap test for collision and for the purpose of preventing all collision checking with each bounding box at each frame. Fig. 4 below shows the example of how the hierarchical tree works for a cloth model.

Fig. 4: Example of hierarchical tree for a cloth model

6. Collision Checking Inter-collision will be focused in this project and thus during each frame, the hierarchies node of the cloth will be checked with the hierarchies node of another model. The process of testing AABBs intersection or overlapping will be carried out on each pair of node and only the intersected node will have further test carried out on their children nodes by traversing the hierarchy tree.[12] concept of traversing hierarchies will be used and the procedures are outlined as follow:  If the current nodes for both objects are leaf nodes, then the primitives bounded inside will be tested for the occurrence of intersection to determine whether collision occurs. If collision happens, then further collision resolution will be performed.  If the current nodes are leaf nodes and the other is an internal node, then the leaf node is tested repeatedly for the occurrence of intersection with the children of the internal node and the process stop when a leaf node is reached.

http://dx.doi.org/10.17758/UR.U0615002

11

 If the current nodes for both objects are internal nodes, the node with smaller volume size is tested for the occurrence of intersection with the children of the node with the larger volume size. Triangle-point intersection test will be carried out if both BVH object are leaf node. The point for the cloth vertex particle will be check first to see if it is penetrating the triangle of the model. For example, (x,y,z) of ⃗⃗⃗⃗3 of the X2 X current point location and (x ′ , y ′ , z ′ ) of previous point location from cloth will be check with ⃗⃗⃗⃗ X1 ⃗⃗⃗⃗⃗ ⃗⃗⃗⃗4 ). If the triangle by shooting a ray in the direction of old cloth point position to current cloth point position (X ray intersect the triangle by passing through it, the barycentric coordinate (w1 , w2 , w3) for the triangle will be computed. The barycentric coordinate can be computed using the following equation: ⃗X ∗ X ⃗ 13 X ⃗ 13 ∗ ⃗X 23 ⃗ ∗ ⃗X 43 w1 X [ 13 ] [ w ] = [ 13 ] (5) 2 ⃗ ∗X ⃗ ⃗ ∗ ⃗X ⃗ ∗ ⃗X X X X 13

23

23

23

23

43

w1 + w2 + w3 = 1 (6) Equation 6 will be used to find the third coordinate of the barycentric and with this 3 coordinates, the new ⃗ 5 , with coordinate (x t , y t , z t ) that lies on the triangle plane which the ray intersect is computed using point X the Eq. 7 below: x t = w1⃗⃗⃗⃗ X1 y t = w2 ⃗⃗⃗⃗ X2

(7)

z t = w3 ⃗⃗⃗⃗ X3 ⃗ 5 or X ⃗ 4 ), is nearer to the old cloth vertex point. If the The next step would be to check which point (X new point is nearer, the collision will resolve with moving the current cloth vertex point location to the location ⃗ 5 + length of the cloth thickness * the direction from the old cloth vertex point to the new point. If the new of X point is further, then current cloth point will be used to check if its distance to the new point is less than the cloth thickness. If the distance is smaller, the current cloth point will be corrected to a new position based on how near it is from the new point.

7. Conclusion The program created uses the algorithm in the methodology and some self-created algorithm which is the BVH creation, collision checking and resolution. The program will start with creating the cloth object, constraint between the particles, the cloth BVH object and followed by extracting the model’s data and creating the BVH for the model object. Updating the cloth particle position will be carried out based on external force like gravity and wind. The program also provides inter-collision detection and collision resolution to ensure the cloth stays on solid object. The application does not provide self-collision and with this feature added, the cloth can be visualize more naturally and realistically as it will always stay on the surface of other triangles mesh like what it does in the real world.

8. Acknowledgements This work was supported by Center for Artificial Intelligence Technology (CAIT) at Faculty of Information Science and Technology. The authors are thankful to all contributors that willingness to share their ideas and hard-earned experience. Thank you all.

9. References [1] [2]

[3]

Baraff D. and Witkin A. “Large steps in cloth simulation”. In SIGGraph. 1998, pages 43-54. ACM. http://dx.doi.org/10.1145/280814.280821 Breen David E, House Donald H, Wozny Michael J. “Predicting the drape of woven cloth using interacting particles”. Proceedings of SIGGRAPH 94, computer graphics proceedings, annual conference series: ACM Press/ACM SIGGRAPH; 1994. p. 365–372. Provot, Xavier. "Deformation constraints in a mass-spring model to describe rigid cloth behaviour." Graphics interface. Canadian Information Processing Society, 1995.

http://dx.doi.org/10.17758/UR.U0615002

12

[4] [5]

[6]

[7]

[8] [9]

[10] [11] [12] [13]

[14]

[15] [16]

[17]

[18] [19] [20] [21] [22] [23]

Mark Meyer. Gilles Debunne. Mathieu Desbrun. Alan H. Barr. “Interactive Animation of Cloth-like Objects in Virtual Reality”. Journal of Visualization and Computer Animation, John Wiley & Sons. 2000. Choi, K., and Ko, H. “Stable But Responsive Cloth”. International Conference on Computer Graphics and Interactive Techniques. 2002 http://dx.doi.org/10.1145/566570.566624 Xavier Provot . “Collision and self-collision handling in cloth model dedicated to design garments”. Graph Interf’97. 1997. p. 147–154. http://dx.doi.org/10.1007/978-3-7091-6874-5_13 Eberhardt B., Weber A., and Strasser W. “A fast, exible particle-system model for cloth draping”. IEEE Computer Graphics and Applications, 1996. 16(5):52-59. http://dx.doi.org/10.1109/38.536275 House D. and Breen D. “Cloth modeling and animation”. A. K. Peters, Ltd. 2000. Volino P., Courchesne M., and Magnenat-Thalmann N. "Versatile and Efficient Techniques for Simulating Cloth and Other Deformable Objects". Computer Graphics (SIGGRAPH’95 proceedings), Addison-Wesley, 1995. pp 137-144. http://dx.doi.org/10.1145/218380.218432 Hubbard P.M. “Approximating polyhedral with spheres for time-critical collision detection”. ACM Transactions on Graphics 15, 3, 1996. 179–210. Palmer I. J. and Grimsdale R. L. “Collision detection for animation using sphere trees”. Computer Graphics Forum 14, 2, 1995. pp 105–116. Van Den Bergen G. “Efficient collision detection of complex deformable models using AABB trees”. Journal of Graphics Tools 2, 4, 1997. 1–14. Gottschalk S., Lin M., Manocha D. “OBB-Tree: A hierarchical structure for rapid interference detection”. In SIGGRAPH 96 Conference Proceedings, Rushmeier H., (Ed.), ACMSIGGRAPH,AddisonWesley, 1996. pp. 171–180. http://dx.doi.org/10.1145/237170.237244 He T. “Fast Collision Detection Using QuOSPO Trees”. Symposium on Interactive 3D Techniques, Proceedings of the 1999 symposium on Interactive 3D graphics. ACM. pp. 55-62, Atlanta, GA USA. http://dx.doi.org/10.1145/300523.300529 Bandi S., Thalmann D, “An Adaptive Spatial Subdivision of the Object Space for Fast Collision Detection of Animating Rigid Bodies”. Eurographics’95, Maastricht, 1995. pp. 259-270. Cohen J.D., Lin M.C., Manocha D., Ponamgi M.K.. “I-COLLIDE: An Interactive and Exact Collision Detection System for Large-Scale Environments”. Proc. Of ACM Interactive 3D Graphics Conference, 1995. pp. 189-196. http://dx.doi.org/10.1145/199404.199437 Moore, M., and Wilhelms, J. “Collision Detection and Response for Computer Animation”. Computer Graphics, 22(4), 1988. pp 289-298. http://dx.doi.org/10.1145/378456.378528 Vassilev T., Spanlang B. “Fast Cloth Animation on Walking Avatars”. Eurographics. Blackwell Publishers. 2001. Klosowski J. T., Held M., Mitchell J. S. B., Sowrizal H., Zikan K.,” Efficient collision detection using bounding volume hierarchies of k-DOPs”. IEEE Transactions on Visualization and Computer Graphics 4, 1, 1998. pp 21–36. Pelechano N, Bull L, Slater M. “Fast collision detection between cloth and a deformable human body”. Technical report, Department of Computer Science, University College London. 2002. Pelechano N. “Real-Time Collision Detection between Cloth and Skinned Avatars Using OBB”. MSc Vision, Imaging and Virtual Environments Project Report, Department of Computer Science, University College London. 2002 Xinyu Zhang and Young J. Kim, “Interactive Collision Detection for Deformable Models using Streaming AABBs”. IEEE Transactions on Visualization and Computer Graphics archive Volume 13 Issue 2, March. 2007. Volino P., Courchesne M., and Magnenat-Thalmann N. “Accurate collision response on polygonal meshes”. Proc. of Computer Graphics, pages 179–188. Proceedings annual conference series: ACM Press/ACM SIGGRAPH; 2000. p. 604–611. http://dx.doi.org/10.1109/ca.2000.889073

http://dx.doi.org/10.17758/UR.U0615002

13