A New Self-Collision Detection Method for Cloth Simulation

In the system of cloth simulation, the process of cloth deformation together with the method of self-collision detection have great significance on how to simulate cloth deformation fast and realistic on computer. In this paper, we present a novel contour test based on the star-shaped property of a polygon, the central data structure for efficient execution of the star-contour test. This paper describes and compares in detail directly accumulation method and global stiffness matrix method. Experiment results showed that the effect simulated by the latter method is more close to reality effect. Taking consider of efficiency, stability and convergence, this paper put forward an explicit -implicit combined method which is suitable for our force models. At last, this paper puts forward a fabric deformation constraint method which is suitable for linear FEM. This method is effective to restrain fabric excessive deformation behavior and achieved realistic simulation result.


INTRODUCTION
In the simulation of flexible body, cloth not only collides with surrounding objects but also undergoes self-collision.If not appropriately responded, self-collision would manifest as penetration on the cloth, significantly reducing realistic feature.The detection and responding are both demanding and will shed immediate impact on simulation speed.
Most algorithms available now enhance collisiondetection efficiency by reducing the number of detection elements.The detection can be handled by extraction of hierarchical structure.This type of algorithms lose their applicability in self-collision since no collided grid can be found between adjacent triangular mesh in independent test.In this paper, we present screening criteria based on regular patch described by direction and contour.Its strength in efficiency and accuracy is then illustrated by experiments.
Cloth simulation categorizes into geometric, physical and a combination of both since 1980s [1,2].Geometric method is easy to apply and known for its speed.However, it's relatively bad for simulation method and that's when physical simulation comes in.Mass-Spring [3] and Finite Element Method (FEM) are among the most popular ones.Mass-Spring is extensively used since the algorithm is easy to realize with high efficiency.FEM computes cloth deformation based on its continuous medium and presents more accurate simulation.

COMPUTATION WORK FLOW
The proposed self-collision detection algorithm can be widely applied on grid model deformation and cloth simulation.When the grid model is deformed, the algorithm can find the collided triangle patch pair.Whereas in cloth simulation, the algorithm can compute response of the collision node, change the position and speed of collision point, and then realize the wanted collision.The method can then be further divided into preprocessing and real-time phases.In the pre-processing, recursive meshing is implemented to build a BVH (Bounding Volume Hierarchy) [4] tree and a SCTT (self-collision test tree).The latter is then traversed in real-time phase.Patch contour of each knot on the two trees will eventually be computed.In the pre-processing phase of cloth simulation, cloth model is first generated, and simulation scene is chosen, then elastic force and numerical integration are computed.Simulation parameters are eventually initialized in realtime phase.
In the real-time phase of self-collision detection for grid model, deformation is achieved by a few known deformation algorithms.The SCTT tree is then traversed to realize the detection, including four steps: a) Patch normal test: one public normal vector is computed for whole patch; b) Starcontour test: to check whether patch projection on the public normal vector intersects with each other; c) BVH test: to check whether one pair patch collides with each other; d) Primitive test: to check whether two triangles collide with each other; The real-time running in cloth simulation is also divided into five steps: 1) We established a mechanical model for the simulated cloth.By doing so, we can compute external force on all nodes and internal force according to cloth deformation.
If the integration method used in the next step is the explicit integration, the force vector can be calculated directly.Otherwise, implicit integration is used for expression of velocity and location.2) We established a partial differential equation for force model, which is then solved by numerical integration method.We got the movement of the fabric node status of each frame, including the velocity and location.Hence the dynamic cloth simulation is accomplished.Numerical integration methods applied may be explicit or implicit depending on the force model applied; 3) Based on the location in Step 2, we performed constraint handling to avoid excessive deformation; 4) Based on the velocity in Step 2, we performed continuous collision test and computed collision response of the collided nodes, and changed their position and velocity; 5) We rendered a real-time cloth image based on the changed location information and used the current location and velocity into the simulation for the next frame.

Self-Collision Detection Algorithm Based on Star-Contours
As is described in [1], in collision detection, BVTT tree expresses hierarchical traverse sequence.One tree node that includes two BVH patches performs collision detection.CSTT including two adjacent patches is defined as sub-tree of BVTT tree.SCTT node is adjacent patch pair to perform collision detection.
First, we performed a patch normal test [5] to find a public normal vector for BVTT node contour.Then all sides on contour can have a projection on the plane corresponding to the public normal vector, which requires vector dot product of all triangular patch within BVTT node greater than 0.
Fourteen directional vectors are chosen by image space sampling and then tested for triangular patches to locate the sample passing all tests.If no sample can meet the requirement, then the directional test fails.These fourteen vectors are chosen from the center of BVTT to its eight vertexes and center of six surfaces.
After directional test, BVTT node will enter into starcontour test.There are two conditions to define a starcontour: (1) there has to be one point on internal plane consisting of all sides; (2) any ray from the point intersects with the side on one point.Polygon can be defined as star on the condition that (1), t, the lowest intersection point of top-edge ray and L is higher than b, the lowest intersection point of bottom-edge ray and L; (2), searching line intersects with only one top edge.Fig. (2) illustrates realization flow of starcontour self-collision detection algorithm.
1) Read the model information of cloth; 2) We performed meshing and build BVH tree, with each node including a set number of triangular patches; 3) SCTT tree is built based on BVH tree.Each node on the SCTT tree has a pair of node of BVH for self-collision detection; 4) Contour information on each node of BVH tree is computed recursively;  In this way, most elements with no collision are excluded before the test.Collision-detection test efficiency is increased and system real-time requirement is met accordingly.

Simulation Based on FEM
Considering the fact that soft cloth is subject to deformation, we choose FEM as our mechanical simulation model, for cloth deformation elasticity calculation, numerical integration on dynamic simulation, and constraining method on cloth deformation.
Soft fabric texture deforms caused a change of relative location of node structure.To respond to this specific feature, we established a physical model.Elastic force computing method based on FEM is applied to analyze internal stress such as elastic force and bending force.FEM Modeling: Finite Element Method (FEM) is an engineering approach which discretizes a grid structure and solves the discrete model by numerical analysis [6,7].The cloth model in use is a finite three-node triangular element model, which defines the simulation object as a continuous medium.FEM discretizes this continuous medium into several elements, which are connected by nodes and continue on the boundary.As is shown in Fig. (3), our finite three-node triangular model defines cloth as a continuity consisting of several continuous finite elements on the boundary.Elements are in the shape of triangle and the three vertexes of the triangle are nodes of the element.In our model, meshing is in accordance with grid patch meshing to simplify calculation.

Detailed modeling process is elaborated as follows:
First, cloth grid topological structure is established.Each vertex is numbered and assigned a data storage structure consisting of location, speed, weight, etc.Each patch is numbered and assigned a data storage structure consisting of index number of its three vertexes in the vertex matrix.Two single-dimensional matrixes store information on vertex and patch respectively.Second, FEM structure is established.For each element, a data storage structure is established, combining its physical information (elasticity modulus, Poisson's coefficient, etc. to compute elastic force).Here, we also use matrix to store all elements.The element is numbered according to its corresponding patch number in patch matrix.
Cloth deformation under stress: As is described above, stress on the element is supposed to be equivalently integrated on its nodes, which are grid vertexes in our FEM model.In this sense, force analysis is to compute force on all grid vertexes.
Force on each cloth grid includes external and internal force, which can be expressed as: ( )

Grid discretization
Element analysis Force analysis

Fig. (4). Work flow of elastic force computed by FEM.
First step, the continuous structure is discretized into several element sets.Elements are connected by nodes; Second step, acting force on each element is analyzed.Node displacement represents element's deformation.Conversion formula is computed for the elastic force on the nodes; Third step, resultant force is computed as force analysis.
The primary task for element analysis is to derive conversion relation between node displacement and node force, based on material property, shape, size, number of nodes, position, etc. Geometric equations, physical equations, and visual work equations in elastic mechanics are introduced to derive element stiffness matrix, and build an equation on force and displacement.Refer to Fig. (5).
After force analysis on single element, we proceed to integral node force analysis.In this process, all forces on the node are integrated to compute the resultant force.There are two approaches applied and compared.
The first method to get the resultant elastic force is direct accumulation of elastic forces on adjacent nodes [8].The computing is done on the level of element and can further be categorized into Green strain method and Cauchy strain method.The process is illustrated in Fig. (6).
Another one takes the force accumulation process as an integration of global stiffness matrix.To put it another way, element force analysis is done first to get element stiffness matrix, which are then integrated into a global stiffness matrix.The global matrix can then generate elastic resultant force of all nodes.The integration of global stiffness matrix can be seen as the force accumulation process.
After building mechanical models for cloth deformation, we apply explicit or implicit numerical integration method to do movement integration and work out movement information on each frame.In response to specific features of our mechanical models and realize cloth dynamic simulation, efficient, accurate and stable integration method is in need.Besides, we put forward a fabric deformation constraint to avoid super-elasticity in simulation.
Numerical integration and deformation constraint: Cloth simulation based on physical models, though with different solving methods, can be summarized into the following process: to express (in force or energy) node elastic relations on account of Newton's laws of motion (or Lagrange motion equation) as one partial differential equation, and then solve the equation by explicit or implicit numerical methods.In choosing the right numerical method, we take into consideration the system scale, solving accuracy and simulation features.The mechanical model chosen has three features: 1, gravity is a constant, irrelevant to position and velocity; 2, bending force, support force on the collision surface, friction force can only be calculated explicitly (use position and velocity of a known previous step size to compute force directly); 3, elastic force and viscous force can be implicitly expressed in equation, or can be computed directly.The approach we take is a combination of both explicit and implicit integration.The whole process can be explained as follows: First step, to establish a Lagrange motion equation: Second step, to rewrite the above Lagrange equation into the form of Newton's laws of motion: Third step, to further rewrite the equation into the form of integration discrete step sizes: ( ) Fourth step, in order to solve +V , we put (5)   into (6), then: Last step, we apply conjugate gradient method to solve the equation to have x + , new velocity and lo- cation for the node is computed by (5).
As is explained above, the method we use is linear FEM [9], in which the element stress is computed by (8).p is Poisson ratio, representing mutual effect of horizontal and vertical deformation.The greater the p, the larger the effect is. E is elastic modulus.It can be inferred that a larger E means greater elasticity.
Instead, if E is not a constant and change in accordance with the stress, a non-liner feature can then be simulated.We propose the method to compute element Strain, which is the basis to change E by segments.

EXPERIMENTAL RESULTS AND ANALYSIS
Experimental environment applied in this paper is Windows XP operating system with Intel(R) Core(TM) 4*E7300CPU(2.66GHZ).Development and realization are all in Visual studio 2008.Self-collision detection uses METIS third-party development library to meshing recursively.OpenGL graphic development libraries are introduced to render scenes and models whereas for cloth simulation, DirectX is used.

Test results of Star-Contour Collision Algorithm
Animal models are chosen to highlight self-collision in detail.Data recorded are summarized in Table 1, including time delay, frame rate, number of collision pairs, number of collision pairs after screening, screening rate, etc. Screening rate means that the algorithm has already pruned most selfcollision.Collision effect is shown in Fig. (7), grid patch collision is highlighted with red cells.(a) and (b) represent non-blank grid and blank grid effect respectively.

Numeric Methods Taken for Elastic Forces
Fig. (8) simulates the process of one piece of cloth falling onto a static ball.The number of cloth patch is 512.We use explicit integration and simulation step size is defined as 0.001.Cloth form turns up due to different integration meth-od taken.It is obvious that cloth simulated by that global stiffness matrix shows a well-balanced coverage on the ball whereas cloth simulated by direct accumulation shows one sunken angle and unsymmetrical angles.The former clearly outweigh the latter.

Comparison Between Two Integration Methods
We also simulate one piece of cloth hanging under gravity with two points fixed.Frame rates simulated by explicit and implicit integration with different numbers grid vertexes (elements) are compared and summarized in Table 2. Same mechanical method (global stiffness matrix) is applied to rule out other factors.

System Results
There are two simulations done for final illustration in Fig. (9).(a) cloth collides with a rolling ball, (b) cloth collides with an object in irregular shape.The number of patches is 512 with simulation step size as 0.002.
Fig. (1) illustrates the work flow of the algorithm, consisting of self-detection test on star-contour grid model and cloth simulation.
external and internal forces respec- tively.External force can further be categorized into gravity and air damping force.Gravity is a known constant and damping force is in direct proportion with node velocity.Internal force is acting force caused by internal deformation, and usually consists of elastic force, viscous force and bending force.FEM based cloth elastic force computing: Elastic force is computed by FEM model as is shown in Fig. (4).

Fig. ( 8 )
Fig. (8).cloth falling onto a ball: comparison of two methods.left is global stiffness matrix and right is the direct accumulation.