| |
|
|
||||
![]() |
||||||
| |
|
|||||
|
2D Surface Deformation
The rapid growth of CPU power opens possibilities for development of 3D games that feature realistic environment. The increase in the performance of graphics accelerators frees additional CPU cycles that can be used for real-time physical world modeling. Game realism can be improved by simulating deformable objects or deformable surfaces. The list of common deformable objects and surfaces include:
Simulation of deformable objects results in unique experience of realistic never-the-same environment. Wind that causes waves and makes grass bend; objects that produce ripples when dropped in water; soil covered with footprints and explosion craters. The user receives much richer sense of reality when the geometry of an object is modified rather than when anew or animated texture is mapped on to it because correctly deformed objects will look right from any angle and in any lighting conditions. Also deformed objects can block or reveal other objects behind them. The implementation of deformable surfaces discussed in this article is intended for real-time 3D games that simulate realistic environment. The algorithm is optimized for AMD 3DNow! technology. Different implementations and their performance are discussed. Physics of 2D surface deformation Consider a grid that represents a simple 2D surface as shown on figure 1. Each vertex on the surface is connected with 6 neighbors to the north, east, southeast, south, west and northwest. This interconnection defines local topology. The neighboring vertices interact with each other by means of elastic forces (i.e. interconnections between vertices, depicted as solid lines on the figures, act as coil springs). In the initial (relaxed) state vertices are evenly spaced, and vectors SRelaxE, SRelaxSE, SRelaxS specify distances between neighbors. In the relaxed state elastic forces between vertices are equal to zero.
When an external force (Fext) is applied to a vertex on the surface at time t0=Dt, the vertex starts moving and displaces to a new location time t1=2Dt. This displacement produces elastic forces between local topological neighbors. The resulted elastic forces counter the displaced vertex motion and try to return the vertex to its original location. However according to the 3rd Newton’s law the same forces but with opposite direction act upon neighboring vertices. So at time t2=3Dt the neighbors get displaced, and entire cluster of vertices comes in motion. With time more and more vertices get involved in motion, representing wave propagation across the surface. The 2D surface is characterized by the following parameters:
Greater elasticity corresponds to faster deformation and stiffer body, while low elasticity corresponds to softer bodies. Smaller damping represents faster relaxation or faster solidification for ductile surfaces. This paper deals with plane isotropic surfaces combined from identical particles with mass m with six-neighbor local topology and linear elasticity model.
State of a vertex on the surface is characterized by coordinate vector S, velocity V, total internal (elastic) force FTotal and external force FExt. The surface deformation is calculated for each vertex in the following way. First vertex displacement relative to the east, south and southeast neighbors is calculated: DSE = SE - S - SRelaxE DSS = SS - S - SRelaxS DSSE = SSE - S - SRelaxSE Then elastic forces between local neighbors are evaluated: FE = Elasticity · DSE FS = Elasticity · DSS FSE = Elasticity · DSSE Total force acting on the vertex under consideration is: FTotal = FE + FS + FSE According to the 3rd Newton’s Law the vertex under consideration contributes to the total force acting on its neighbors: FTotalE = FTotalE - FE FTotalS = FTotalS - FS FTotalSE = FTotalSE - FSE Notice that north, west and northwest elastic forces are not calculated directly. The total force for the vertex FTotal is updated automatically when north, west and northwest vertices are processed (3rd Newton’s law). Finally, when all vertices on the surface are processed (i.e. all internal forces evaluated) new coordinates are calculated for each vertex. Acceleration is calculated from the 2nd Newton’s law: a = (FTotal + Fext)/m The rest is discrete numerical integration: DV = a · Dt V = V + DV DS = V · Dt S = S + DS Lastly vertice velocity is adjusted in order to account for damping: V = V · d
|
|
|