Interactive Visualization of Open Water Using Hybrid Wave Model in

advertisement

Interactive Visualization of Open Water Using Hybrid Wave Model in

Oceanaut Arcade Game

Chih-Ming Chiu 2 , Ming-Yuhe Chang 1 , Ching-Sheng Tsai 2 , and Damon Shing-Min Liu 2

1 Department of Multimedia and Entertainment Science, Southern Taiwan University, Taiwan, Republic of China

2 Department of Computer Science and Information Engineering, National Chung Cheng University, Taiwan, Republic of China

A BSTRACT

In this work, a hybrid wave model and a novel methodology are proposed to realize the vivid three-dimensional wave/water visualization interactively. We integrate the Fast Fourier

Transform (FFT) wave model to specify the ocean simulation and the Smooth Particles Hydrodynamics (SPH) wave model to simulate the visualization of rigid body interactions in a bounded region of interest. The aim is to implement a three-dimensional arcade game “Oceanaut” with a three-degree-of-freedom servo platform system and a force feedback joystick. In the arcade game

“Oceanaut”, the game players can physically experience, i.e., in the manners of force feedback and a vivid oceanic threedimensional game environment, a lifelike windsurfing sport with a vivid ocean wave simulation.

CR Categories and Subject Descriptors

: I.3.7 [Computer

Graphics]: Three-Dimensional Graphics and Realism - Virtual reality .

Additional Keywords: Fast Fourier Transform , Smoothed

Particle Hydrodynamics , Arcade Game, Water Simulation,

Particle System, Torque Game Engine .

1 I

NTRODUCTION

Game Control System (PC)

A/D Signals

( Weight, SailingAngle ,

BoardInclinationAngle,

Force, ReactForce )

Force

Joy

LabView

DLL

Math. Model

(Fortran77-> C++-

>DLL)

WindForce

Stick

Motion

Information

Buffer ( Heave,

Sway, Surge,

Yaw, Roll, Pitch,

WindDirection,

WindDegree,

WaveForce )

DLL

Game Engine

VisualBasic

3 DOF

Platform

Motion Board

Controller (PC)

RS232C ( Pitch, Roll )

Figure 1. System architecture of “Oceanaut” arcade game.

As described in Figure 1, the system architecture of the

“Oceanaut” arcade game consists of several components: 1) a mechanism of Force Joy Stick, 2) a 3-DOF servo Platform and

Motion Board Controller, and 3) the Game Control System.

Within the Game Control System, the motion information collected from the Force Joy Stick and the 3-DOF Platform can be calculated and transformed into the messages such as including

1 e-mail:changmy@mail.stut.edu.tw

2 e-mail:{ccm95p, tcs95m, damon}@cs.ccu.edu.tw

‘Heave’, ‘Sway’, ‘Surge’, ‘Yaw’, ‘Roll’, ‘Pitch’, ‘WindDirection’, and ‘WindDegree’, which are subsequently sent to Game Engine to create in real-time the corresponding interactive threedimensional renderings that is required in the game scenarios of the “Oceanaut” arcade game.

The Math. Model generates the events/phenomena of wind force in terms of messages ‘WindDirection’ and ‘WindDegree’ to be inputs of the Game Engine that changes the three-dimensional renderings of a lifelike windsurfing play scenarios as the storyboard specified in advance.

The Game Engine renders the game scenes according to the preset scenarios and simulates the vivid ocean waves in terms of message ‘WaveForce’ that is sent back to the Math. Model to generate the wave impact force feedback according to the message ‘ReactForce’ received from the Math. Model to be physically performed on the body of the game player by the Force

Joy Stick .

To have the game player immerse in the interactive visualization of a vivid three-dimensional ocean wave/water, a hybrid wave model and the model-specified methodology are proposed in this work by integrating the Fast Fourier Transforms

(FFT) wave model to specify the ocean simulation and the

Smoothed Particles Hydro-dynamics (SPH) wave model to simulate the visualization of rigid body interactions in a bounded region of interest, i.e., to present the splashing of the water around the sailboard .

An overview of the modules, including the sailboard mechanism, numerical analysis module, 3D display module, and sports platform, is illustrated in Figure 2 .

Figure 2. Overview of modules in the architecture.

2 R ELATED W ORK

Water or fluid simulation and visualization play an important role in traditional Computational Fluid Dynamics. Until recently, with the emergence of shader driven graphics hardware and the improving computing power of personal computers, we are able to render a visually convincing water surface on low cost machines.

For interactive applications like digital games, the industry also

began to embrace the new technology recently. High-end game engines such as CryENGINE [1] and Source [2] engines offer interactively pretty water rendering capability in their technology previews and in yearly E3 trade shows.

Water simulation algorithms can be categorized as either

Eulerian or Lagrangian. Because it is easy to implement and usually gives pleasant results, major game developers choose to adopt Eulerian methods for their water simulations. For example, the famous “stable fluid” method of stam [3] is an Eulerian simulation.

The major problems of Eulerian water methods are hard to interact with arbitrary rigid bodies and not appropriate for water splash or collect in pools. For our Oceanaut console game, the sailboard players are very close to the water surface. In order to yield acute surfing experience, we adopt a hybrid method that integrates grid based Eulerian with particle-based Lagrangian water simulation.

2.1 Interactive Water Simulation

Natural phenomena like ocean simulation are among the most important special effects in the movies Titanic and Waterworld.

The algorithms [4] are based on the observation of the real ocean and apply Fast Fourier Transforms (FFT) to synthesize the ocean animation statistically. This is a typical approach of creating

Eulerian water simulation using a mesh with grid layout like

Figure 3. Those algorithms are simultaneously adopted in the game code [5] and can produce beautiful ocean simulation at interactive rates on common personal computers.

Another technique can achieve interactive water simulation is the particle-based Lagrangian approach. One popular method known as Smoothed Particles Hydro-dynamics (SPH) [6,7,8] is applied to simulate fluid with free surfaces. According to SPH, a scalar quantity A is interpolated at location r by a weighted sum of contributions from all particles:

A

S

( r )

  j m j

A j

 j

W ( r  r j

, h ) where j iterates over all particles, m

j is the mass of particle j , r

j its position, ρ j the density, and A

j

the field quantity at r

j

.The function

W ( r,h ) is called the smoothing kernel with core radius h . In this paper we use the kernel functions and discrete summations proposed by M ü ller et al. [9].

In [10], the SPH model using a gridless data structure was proposed to interactively simulate the behavior of rivers.

Figure 3. Grid layout for FFT-based ocean surface.

2.2 Fluid Simulation with Rigid Body Interaction

The FFT algorithm mentioned before can yield very realistic waves, but it is difficult to handle the rigid body interaction problems. Moreover, in general, we will get a substantial frame rate loss for utilizing the FFT approach to deal with water and floating rigid body interactions. The iWave [11] avoids FFTs to compute water surface wave propagation that overcomes this limitation.

For physically based simulation, by solving the well known

Navier-Stokes equations which govern the movement of a viscous incompressible fluid coupled with interplay of rigid bodies, a plethora of research exists. The Rigid Fluid method [12] treats the rigid objects as if they were made of fluid and uses distributed

Lagrange multipliers to ensure two-way coupling that generates realistic motion for both solid objects and fluid as they interact with each other.

Another approach [13] is to use the SPH technique for simulating fluids that interact with rigid bodies, and vice versa.

That is the core idea implemented in this paper for real-time interaction of water and dynamic rigid bodies. We therefore give details about this approach in the following.

Dynamic rigid bodies are those moving during the game that might need to interact with the water. In our extension of the SPH model, we treat rigid bodies as a portion of the fluid representing the rigid body as a collection of particles that are updated in the same manner as water particles are. The only special treatment occurs when computing the pressure contribution between fluid and rigid particles. The rigid particles exert a pressure that pushes the fluid away from the rigid bodies. Likewise, the fluid particles apply a pressure that results in a net translation and/or rotation of rigid bodies.

Contrary to the traditional rigid-body simulation where a net force and a net torque are applied to cause the body to move as a whole, the pressure is applied individually to each rigid particle such that each of them is moving independently in our approach.

Because of the independent, unconstrained update of rigid particles, the rigid particles do not necessarily conform to the shape of the rigid body after an update. To achieve an end result in which the rigid particles do conform to the proper rigid body shape at the end of a time step, we apply a correction step to enforce the rigidity of the rigid body particles. The process of updating the particles independently followed by the enforcing rigidity step is illustrated in Figure 4.

To enforce rigidity, we use the particle positions and motion after the particle update to compute a new location and orientation for the rigid body, as well as values for other key rigid body dynamics properties. We then update the rigid particle positions to be located at their correct location relative to the new rigid body configuration. In computing the new rigid body position and orientation, we treat rigid body motion in an approximate way that is a bit simpler than full rigid-body simulation, and achieve stable interaction with the fluid particles.

The total rigid body mass M is given by Equation 1.

M

  j m j

(1)

Here, m j

is the mass of a single rigid particle j , and the velocity of the center of mass of a rigid body is given by Equation 2. v g

 1

N

 j v j

(2)

Here, N is the number of particles, and v j

is the velocity of a single particle j . The angular velocity of the rigid body ω is approximated using Equation 3.

  1

I

 q j

 j v j

(3)

Here, q j

is the location of a single rigid particle j , relative to its corresponding rigid-body center of mass r g

. They are defined by

Equation 4 and 5. r g q j

1

N r j

 j r g r j

(4)

(5)

The rigid-particle location vectors q j

are computed in the local rigid-body coordinate system at the beginning of the simulation and are never recomputed. They represent the relative position where the rigid particles must be located to maintain the rigid body shape. The scalar variable I is related to a moment of inertia of the rigid body, divided by its mass, and is defined by Equation

6.

I

  j q j

2 (6)

The rigid body properties computed in Equations 1 through 6 can be used to obtain an updated position and orientation of the rigid body as a whole. For example, often in simulations, a rigid body’s location is defined by its center of mass, and so Equation 4 directly provides the updated position. We can compute the updated position and orientation as follows.

We store a rotation matrix R (t) and the center-of-mass r g

( t ) for each whole rigid body. During the simulation, these are updated using Equation 7. r g

( t

  t )

 r g

( t )

  tv g t

1

2

 t

R ( t

  t )

R ( t )

  tQ t

1

2

 t (7)

Here, Q ( t ) is the time rate change of the rotation matrix at time t , given by Equation 8.

Q ( t )

ω

0

ω z y

 ω z

0

ω x

ω y

ω

0 x 

R ( t ) (8)

Once the rigid-body angular velocity and center-of-mass velocity are known, the kinematic velocity of each rigid-particle velocity constrained by rigid-body motion is computed using

Equation 9. v j

 v g

ω

 q j

(9)

The detailed algorithms were presented in [13].

Figure 4. Illustration of rigid body particle positions after initial update and after rigidity is enforced.

2.3 Hybrid Methods for Fluids Simulation

For intermediate to large scale fluid simulation, hybrid models are developed to handle different applications. As far as pure

Lagrangian methods are concerned, inflow and outflow of fluid is not allowed. Therefore, a gridless hybrid model using the movingparticle semi-implicit (MPS) [14] method was developed [15].

Full 3D Navier-Stokes solvers can produce beautiful water effects, but they do not scale well to large bodies of water in general. [16] presented an efficient method for simulating large bodies of water by coupling two and three dimensional techniques.

In order to animate large water surfaces, a hybrid 2D shallow water simulation using a full 3D free surface simulation scheme is used for the creation and simulation of drops [17].

3 M

ETHODOLOGIES

In OceanAut game, our main goal is not only to immerse the game players in the large ocean water environment, but also to capture the splashing of the water around the sailboard. In order to achieve interactive rates that a typical game application needs, we must carefully decide on a tradeoff from the realistic representation of such a scene to the overall performance of the system including the synchronization between the visual simulation and force feedback joystick.

Therefore, we choose to integrate two wave models that were both considered being able to be realized at interactive rates, the

FFT wave model and the SPH water simulation. The part of SPH water with the simulation of rigid body interactions is only carried out in a bounded region of interest i.e., the region around the sailboard. Therefore, the fast FFT ocean wave model is applied around this bounded region.

3.1 FFT Wave Model

In this subsection, we describe the core ocean wave algorithm which was explained in detail in [4]. The FFT wave model is a statistical sea model where the wave height is a random variable of horizontal position and time, h ( x , t). This model is able to decompose the wave height field as a sum of sine and cosine waves having different amplitudes and phases. The decomposition uses Fast Fourier Transforms to quickly evaluate the sums.

A FFT-based wave height field expresses the wave height h ( x , t) at the horizontal position x =( x , z ) as the sum of sinusoids with complex, time-dependent amplitudes: h ( x , t )

  j

~ h ( k , t ) exp( i k  x ) where t is the time and k is a two-dimensional wave vector with components k = (k x

, k z

), k x

= 2π n /L x

, k z

= 2π m /L z

, and n and m are integers with bounds – N /2 ≦ n < N /2 and M /2 ≦ m < M /2. The

~ value of h ( k , t ) is a complex number representing both amplitude and phase of wave k at time t.

For rendering the wave height field, we need to calculate the slope vector of the field to obtain surface normals and other aspects of optical modeling as well. We can use the finite difference between FFT grid points to compute the slope, but it can be a poor approximation to the slope of waves with small wavelengths.

A more accurate computation of the slope vector can be obtained using more FFTs:

 h ( x , t )

  k i k

~ h ( k , t ) exp( i k  x )

The FFT representation produces waves on a patch grid with horizontal dimensions L x

× L z

, outside of which the surface is perfectly periodic. The patch can be seamlessly tiled as desired

over an area. As long as the patch size is large compared to the field of view, this periodicity is unnoticeable. Also, if the camera is near the surface like in our game so that the effective horizon is one or two patch lengths away, the periodicity is not noticeable in the look-direction, but it may be visible as a repeating pattern across the field of view.

Next, we use the Phillips spectrum for wind-driven waves to create the amplitudes and phases. It is defined by the following equation:

P h

( k )

A exp(

1 /( kL ) 2 )

2 k 4 where L = V 2 / g is the largest possible waves arising from a continuous wind of speed V, g is the gravitational constant, and ŵ is the direction of the wind. A is a numeric constant. The cosine factor 

2

in the Phillips spectrum eliminates waves that move perpendicular to the wind direction. This model has poor convergence properties at high values of the wave number |k|. A simple fix is to suppress waves smaller than a small length l << L, and modify the Phillips spectrum by multiplying the equation with the following factor: exp(

 k

2 l

2

)

To build a random ocean wave height field, the Fourier amplitudes of a wave height field can be produced as

~ h

0

( k )

1

2

(

 r

  i

) P h

( k ) where ξ r and ξ i

are ordinary independent draws from a Gaussian random number generator, with mean 0 and standard deviation 1.

Finally, given a dispersion relation ω(k) and a time t, the

Fourier amplitudes of the wave field are calculated as follows,

~ h ( , )

 ~ h

0

( k ) exp{ i

( k ) t }

 ~* h 0

(

 k ) exp{

 i

( k ) t } where * is the complex conjugate operator and ω is angular frequency of wave k representing the speed at which the wave travels across the surface.

In deep water, where the bottom may be ignored, there is a relation between ω and the corresponding wave-vector k :

2 ( k )

 gk

The parameter k is the magnitude of vector k .

There are several conditions in which the dispersion relationship is modified. The most useful for our purpose is taking the depth D into consideration and the dispersion relation becomes

2

( k )

 gk tanh( kD )

Notice that if the bottom is very deep, the behavior of the tanh function reduces this dispersion relation to the previous one.

3.2 Mixing of the 2D/3D Models

The overview of our hybrid ocean water simulation model is depicted in Figure 5. The particle-based SPH water simulation is performed in the bounded region around the sailboard where the game player is most interested. Instead of simply superimposing the FFT wave heights on the SPH water particle’s position vector, we apply a Gaussian filter to smooth over the transition between the two regions.

The purpose of capturing the small scale details such as drops can be simplified using this approach. Furthermore, because we treat the sailboard as water particles and take the algorithm presented in [13] for calculating the rigid body interactions, the buoyant rigid object simulation is naturally realized.

z x

3D SPH water region

FFT water surface

Figure 5. An overview of our hybrid 2D and 3D physics based SPH water models. The two-dimensional FFT ocean water simulation is coupled with the full three-dimensional SPH water solver around the sailboard.

4 I MPLEMENTATION

The game and the water simulation are currently implemented using the Torque Game Engine, a low-cost source game engine developed by Garage Games [18]. We extend the fxRenderObject class and create a new fxSPHRenderObject for our SPH water simulation. To generate a mesh from the SPH particles, we use the marching cubes algorithm [19]. For rendering local water reflection and refraction, we also implement the environment cube map extension with nVidia Cg support.

The Torque Game Engine is able to cross multi-platforms, and the recently announced Torque for Wii developer kit offers a complete game development solution for the Nintendo's Wii

Console. The balance board joystick is just released to support the sports game applications, so we have the plan to port the game code to the other game console like Wii.

Figure 6 shows two snapshots of the game in action.

Figure 6. Snapshots of the game in action.

5 C ONCLUSIONS AND F UTURE W ORK

We describe an interactive water simulation and visualization method to efficiently simulate large scale open water fluids in the arcade game called “Oceanaut”. This is realized by integrating a two-dimensional FFT based ocean water simulator with a threedimensional particle based SPH water solver. The buoyant rigid bodies over the water are treated as water particles, which enables the interaction of fluid and rigid bodies. For the game play, it is able to arbitrarily move the 3D SPH simulation within the 2D

region then increases the flexibility.

Currently, the particle-based 3D water simulation is a single

CPU implementation. In the future, we plan to further speed up the computations by parallelization for multi-core machines.

Finally, the SPH method has been applied to the solution of shallow water equations (SWE) [20]. Therefore, the FFT wave model may be replaced by physics-based SWE simulation in near future to yield more physically accurate ocean waves.

6 A CKNOWLEDGMENTS

This work was supported by Industrial Technology Research

Institute (ITRI), Taiwan, under the grant number 6301XSWW10.

R EFERENCES

[1] CryENGINE 2. http://www.crytek.com/technology/cryengine-2/.

[2] SOURCE ENGINE. http://www.valvesoftware.com/business.html.

[3] Stam Jos. Stable Fluids. Proceeding of the 26th Annual Conference

On Computer Graphics and Interactive Techniques, ACM Press:

Pages. 121-128,1999.

[4] Jerry Tessendorf . Simulating Ocean Water. In Simulating Nature,

ACM SIGGRAPH Course Notes, available online at http://user.adelphia.net/~tessendorf/, 2002.

[5] Lass Jensen. Deep-Water Animation and Rendering. Available online at http://www.gamasutra.com/gdce/jensen/jensen_01.htm, 2001.

[6] R. Gingold and J. Monaghan. Smoothed Particle Hydrodynamics:

Theory and Application to Non-Spherical Stars. Monthly Notices of the Royal Astronomical Society , 181:375–398, 1977.

[7] M.B. Liu and G.R. Liu. Smoothed Particle Hydrodynamics: A

Meshfree Particle Method . World Scientific Publishing, 2003.

[8] J. Monaghan. Smoothed Particle Pydrodynamics. Annual Reviews of

Astronomy & Astrophysics , 30:543–574, 1992.

[9] Matthias Müller, David Charypar, and Markus Gross. Particle-Based

Fluid Simulation for Interactive Applications. Proceedings of the

2003 ACM SIGGRAPH/Eurographics Symposium on Computer

Animation, Eurographics Association: Pages: 154-159, 2003.

[10] Peter Kipfer and Rüdiger Westermann. Realistic and Interactive

Simulation of Rivers. Proceedings of the 2006 Conference on

Graphics Interface: Pages: 41-48, 2006.

[11]

Jerry Tessendorf. Interactive Water Surfaces. Game Programming

Gem 6, Charles River Media, 2006.

[12]

Mark Carlson, Peter J. Mucha, and Greg Turk. Rigid Fluid:

Animating the Interplay Between Rigid Bodies and Fluid.

Proceedings of the 2004 SIGGRAPH Conference, Pages: 377 – 384,

2004.

[13]

Takashi Amada. Real-Time Particle-Based Fluid Simulation with

Rigid Body Interaction, Game Programming Gems 6, Charles River

Media, 2006.

[14]

S. Koshizuka, H. Tamako and Y. Oka. A Particle Method for

Incompressible Viscous Flow with Fluid Fragmentation.

Computational Fluid Dynamic Journal ., 29(4), 1996.

[15]

H. Y. Yoon, S. Koshizuka and Y. Oka. A Particle Gridless Hybrid

Method for Incompressible Flows. International Journal for

Numerical Methods in Fluids, 29(4), 1996.

[16]

Geoffrey Irving, Eran Guendelman, Frank Losasso, and Ronald

Fedkiw. Efficient Simulation of Large Bodies of Water by Coupling

Two and Three Dimensional Techniques. ACM Transactions on

Graphics (TOG), vol. 25 no. 3, July 2006.

[17] Nils Thürey, Ulrich Rüde, and Marc Stamminger. Animation of

Open Water Phenomena with Coupled Shadow Water and Free

Surface Simulation. Proceedings of the 2006 ACM

SIGGRAPH/Eurographics Symposium on Computer Animation,

Pages: 157 – 164, 2006.

[18]

Garage Game Web site, http://www.garagegames.com/.

[19]

Jules Bloomenthal. An Implicit Surface Polygonizer. Graphics Gems

IV, Academic Press, Pages: 324-349, 1994.

[20]

Riadh Ata and Azzeddine Soula mani. A Stabilized SPH Method for

Inviscid Shallow Water Flows. International Journal for Numerical

Methods in Fluids, 47 :139-159, 2005.

Download