Game Development Reference

In-Depth Information

behavior. Moreover, selecting the parameters of the springs, such as the stiffness

and damping, to simulate a particular material is not trivial, and generally, these

parameters are chosen arbitrarily. Evidently, despite the nice features of mass-

spring models, they are not very accurate since they are not based on the elasticity

theory and are strongly topology dependent.

On the other hand, finite element models (FEM) are based on elasticity theory,

in which physical material properties can be described using only some parame-

ters obtained from textbooks. Unlike mass-spring models, finite element methods

model soft bodies in a more accurate manner, and they make it easy to simulate

any particular material. This fact makes things easier for game artists in charge of

modeling different types of soft bodies.

In the past, finite element models have been used very little in computer games

and in real-time applications since they have been considered to be computation-

ally expensive and complex to implement. This has changed, and today's new

hardware power and new researches allow real-time applications. The purpose

of this chapter is to describe the implementation of real-time finite element mod-

els from an implementation point of view, trying to keep mathematics as basic

as possible. We start by giving a short introduction to continuum mechanics,

which is important to understanding the basic concepts of elasticity. Next, in Sec-

tion 10.3, we explain how we translate these concepts into a discretized soft-body

model, also known as the finite element method. Within this section, we pro-

vide pseudocode listings of some key parts to help programmers implement the

model. In Section 10.4, we describe some techniques to accelerate the resolu-

tion of the model and achieve real-time simulations. We also provide some pseu-

docode listings that will help in the understanding of the solutions. Finally, we ex-

plain how to link the soft-body model to the mesh resource used for the graphical

rendering.

10.2 Continuum Mechanics

Continuummechanics is used to model the kinematics and the mechanical behav-

ior of objects on the macroscopic scale such as solids and fluids (e.g., liquids and

gases). It ignores the fact that matter is made of atoms and molecules and treats

objects as if their matter were continuously distributed throughout the space it

occupies. The continuum concept allows us to approximate physical quantities,

such as energy and momentum, to describe the mechanical behavior of a given

object. Based on this, continuum mechanics defines the governing equations of

an object based on its material properties, or more generally, on its constitutive

laws.