Real Time Animation of Trees Based on BBSC in Computer Games

That researchers in the field of computer games usually find it is difficult to simulate the motion of actual 3D model trees lies in the fact that the tree model itself has very complicated structure, and many sophisticated factors need to be considered during the simulation. Though there are some works on simulating 3D tree and its motion, few of them are used in computer games due to the high demand for real-time in computer games. In this paper, an approach of animating trees in computer games based on a novel tree model representation—Ball B-Spline Curves (BBSCs) are proposed. By taking advantage of the good features of the BBSC-based model, physical simulation of the motion of leafless trees with wind blowing becomes easier and more efficient. The method can generate realistic 3D tree animation in real-time, which meets the high requirement for real time in computer games.


Introduction
In current computer games, plants in scenes are usually consisted of simple plane pictures positioned in four orthogonal directions.3D models of plants are seldom used in computer games.Recently, 3D plants come forth in some computer games which make users feel more realistic.For example, in [1], a palm tree model with approximately 400 Polys was created by Amped Labs LLC for the use in the Rise of Power game.There are also some top-level visualization corporations like Interactive Data Visualization, Inc. (IDV) providing functional system like SpeedTree for modeling 3D trees and simulating simple tree animation in computer games [2].
However, in the scope of our knowledge, we do not find any research publications on discussing 3D tree motion in computer games.In fact, many researchers have made contributions in tree modeling and its motion, but none is actually applied in computer games.In tree modeling, the main methods include the followings: L-system [3], image based tree modeling [4][5][6] and space colonization algorithm [7].In the aspect of tree motion simulation, there are also many works.The earliest work can be retrieved was done by Wejchert and Haumann [8].They used four simple fluid flow including uniform, sink, source and vortex to design and control the movements of the wind.And then the animation of the leaves going with the wind is simulated by computing the movement produced by wind force from normal and tangential direction in accordance with the traditional Newton theory.Mikio Shinya created a stochastic wind area and then simulated the tree swaging in the wind based on a modal analysis method [9].Hiromi simulated tree motions like flying and breaking in tornado in the movie "twister" in which the tornado model was constructed with the turbulence theory [10].In Feng's study [11], a single branch is divided into several little segments, and each of these segments can be viewed as a pole which cannot deform in the axis direction.Then the position of each point on a little segment after motion can be computed by applying the deformation equations of pole.In Alkagi's work [12], level of detail (LOD) technique was employed to reduce the computational complexity, and the animation of trees in real-time was implemented.During the computation of tree motion, a single branch is divided into seven parts of coneshaped "links" that are interconnected by six "joints".And the bending of a branch is represented by the rotation of each of its joints.In [13], William Van Haevre realized tree motion at each arbitrary moment using a goal-based motion algorithm.As for recent works, Khalid Saleem animated tree branch breaking and flying effects in a 3D interactive visualization system for hurricanes and storm surge flooding [14].Yubo Zhang introduced a data-driven approach that synthesizes tree animations from a set of precomputed motion data [15].

International Journal of Computer Games Technology
However, because of the high demand for real time in computer games, most of the above work cannot be applied directly in computer games.Some can be used to animating trees in computer games like Akagi's work as extra speeding technique was employed to reduce the computational complexity, and thus real-time animation can be generated [12].
There are two main factors hampering the application of 3D tree motions in computer games.For one thing, most of the tree representations are too complicated to implement real-time animation; for another, the simulation of tree animation is a sophisticated work because many physical computations like animation aerodynamics, material mechanics, and pole kinematics are involved.
In our paper, a novel tree model based on BBSC is introduced, and the method of simulating tree motions based on this model is proposed [16].This model combined with this method is efficient for generating real-time tree motions in computer games.In the following sections, the paper is organized as follows.In Section 2, a novel tree model based on BBSC is described in detail; in Section 3, the model for physical simulation of wind is briefly introduced; in Section 4, the simulation of the tree animation is illustrated; in Section 5, the animation effect by our method is demonstrated, and the conclusion is given.

BBSC-Based Tree Modeling
Ball B-Spline Curve (BBSC) is a parametric solid representation of freeform tubular objects, which are skeleton-based parametric solid model.BBSC directly defines objects in B-Spline function form by using control sphere instead of control point in B-Spline curve.BBSC not only to describe every point inside 3D solid objects but also provides its center curve in B-Spline form directly.So the representation is more flexible for modeling, manipulation, and deformation.
The Ball B-Spline Curve (BBSC) is therefore defined as B (t) = n i=0 N i,p (t) P i ; r i , where P i are control points, and r i are control radii. As Ball B-Spline curve can be regard as two parts: a 3D B-Spline curve, that is, the center curve (or skeleton): c(t) = n i=0 N i,p (t)P i , and a B-Spline scalar function, that is, the radius function r(t) = n i=0 N i,p (t)r i .Therefore most properties and algorithms can be obtained by applying B-Spline curve and function to the two parts of BBSC, respectively.Owing to the perfect symmetry property of balls, the curve c(t) constructed from the centers of balls is exactly the center curve of the 3D region represented by the BBSC.Different from BBSC, B-spline curve only represent a curve in 3D space.But BBSC inherits good properties from B-Spline curves.Most algorithms in B-Splines can be extended to BBSC.For example, we also have interpolation and approximation algorithm generating  a BBSC.These algorithms are implemented by employing B-Spline curve's interpolation (approximation) algorithm to position data to get the center curve part of BBSC and B-Spline scalar function interpolation to these widths data to get radius function.Similarly we can modify the 3D shape by deforming BBSCs through modifying its control points and radii.Detailed description of the algorithm can be found in [16].In Figure 1(a), a BBSC generated by interpolation is shown, in which the red balls are the data spheres, and the green spheres are the control spheres.In fact, the two end spheres are both data spheres and control spheres.The whole curve is tessellated so that later rendering and texture mapping processes can be implemented.In this figure we can easily see that, different from traditional B-Spline curve with 2D control points, the BBSC has the control spheres consisted of center points and radii.Therefore, we can generate real-time animation of the BBSC-based trees easily.

Geometric Representation with BBSC.
BBSC is a parametric representation of 3D freeform solid objects [16].Its evaluation is precise and efficient, and it is flexible for manipulations, deformations, and morphing.These properties provide the potential to build flexible botanical tree model.Figure 2 shows the geometric relationship between these data spheres of a BBSC-based tree.The whole tree is consisted of several BBSCs which are created by interpolation.The red spheres are the data spheres used to be interpolated.Each sphere is consisted of its center point and radius.Each sphere is represented by its center point and radius.Thus a tree is described by these center points and radii of these data spheres.And in Figure 3, the resulting tree constructed from BBSCs is shown.Figure 3 Figure 4: Topological structure of representing a tree.

Topological Representation.
A graph-based data structure (tree data structure) is built to represent the complex hierarchical structures of trees shown in Figure 4.In each node of the tree data structure, the topological information of its parent and children and its geometric representation based on BBSC are stored.The construction of the topological model aims to generate real-feeling animation of the whole tree.The hierarchical structure will be made use of to compute the movements of the branches from low level to top level.

Model for Physical Simulation of Wind
In the wind model, we adopt Feng Jinhui's method for physical simulation of wind [11,17].Here, a summary of the method is given.

Wind Force Size.
In our method, the users are allowed to choose the wind force model and set the wind direction according to their requirements.Two kinds of wind force model are provided, and arbitrary wind direction in x-z panel can be set.

Gust of Wind.
The gust of wind increases gradually from zero to the highest point and then decreases gradually to zero again.The model can be represented in the following equation: (1)

Stable Wind.
The stable wind increases gradually from zero to certain grade, and for some seconds retains at this grade, then finally decreases gradually to zero.The model can be represented in the following equation: , mid time ≤ t ≤ max time.
(2)  In the above two equations, t c is the time constant, and different wind models can be easily obtained by modifying the model parameters.
Figure 5 shows the wind force changes with the time.Figure 5(a) gives an example of the gust of wind changing with the time, and Figure 5(b) is the example of the stable wind changing with the time.

Wind Force Direction.
Users are allowed to set arbitrary wind direction in x-z panel by inputting the angle between the wind direction and the x-axis positive direction.360 wind directions along with the counter-clockwise can be obtained by increasing the angle from zero degree to 360 degree.
The later computation of the motion of the branches is based on the above wind model.

Animation of BBSC-Based Trees
In the introduction part, we have noticed that when computing the motion of a certain branch, those researchers generally segment a certain tree branch into several segments and then view those little segments as poles.Therefore, the deformation method of a pole can be applied to the little segment very easily to generate relatively natural-looking tree animation.
As described in Section 2, our tree model based on BBSC is a proper and efficient model in computer games.In fact, this model shows more value when computing tree motion.Now that the branches are generated from several data spheres within, we can just use the position of the data spheres to segment the current branch.And considering a branch is an actually BBSC created by interpolating several data spheres, we need only compute the position of the data spheres after motion rather than every point within the segment.The new curve obtained by interpolating the new data spheres after motion is hence regarded to be the new representation of the branch after motion.With this model, the deformation of tree branches can be computed by defining the relationship between wind forces and data spheres repositioning.And the new position of the data spheres can be computed by simulating the bending of a pole.

Dynamics Model for Branches.
As shown in Figure 6(a), a pole with one end A fixed bends under the distribution force q.Then the displacement and the rotation angle can be computed for each position x.According to pole kinematics theory, the deformation of a pole can be represented by two parameters: the deflection and the rotation angle.The deflection can be just viewed as the displacement of the current position.However, in order to lessen the computation complexity, we consider only the rotation angle in our model.Furthermore, rather than each point in the current segment, we should only consider the rotation angle of the end B under force q, which can be obtained from the following equation: In the above formula, q is the wind force, L is the length of the pole, and I Z is the Bending Section Modulus.E is the Young's Modulus, which is used to measure the elastic characteristic of certain materials and is decided only by the physical feature of the material.We indeed have omitted many complex computation processes which are indispensable in the field of Mechanics of Materials; however it is fully accepted in computer games for realistic.And the BBSC-based tree's bending by simulating a pole's bending is shown in Figure 6(b), in which P j+1 is the original coordinates of the current moving point, P j+1 is the coordinates of the points after moving, P t j+1 is the position of P j+1 after horizontal translation, and P j is the coordinates of the former points after moving within the current branch.The rotation angle under the wind from x-axis direction is θ.By applying (3), we get In the above equation, F Wind is the wind force, and dist(P j , P t j+1 ) is the distance between P j and P t j+1 which represents the length of the current segment.

Solution of Motion.
In our model, the branches have been already divided into several segments, and each segment between two data spheres can be viewed as a pole.Considering the high request for real-time in computer games, we just apply simple deformation method of a pole to each segment.Therefore only bending is taken into account.The rotation along the cross section and the deformation along the axis direction are both neglected.The bending of a branch can then be described as three Eula angles which represent the rotation angles of the data spheres around the x-axis, y-axis, and z-axis, respectively.
Suppose the coordinate vectors of the data point before and after deformation are (x, y, z) and (x , y , z ), respectively.Then the two vectors has the relationship as in the following equation: In the above equation, R is the rotation matrix, which can be described as in (6).The rotation sequence is as follows: firstly, rotates around z-axis by angle θ z ; then rotates around the  .(6) In the above equation, c and s are the cosine and sine values of the related angles.And the position of any data points after deformation can be computed with this rotation matrix as long as all the angles have been figured out.
The three angles can be obtained by applying the pole deformation theory under the situation of decomposing the wind vector and the pole segment vector, respectively.The wind force vector can be decompounded into two vectors   which are along x-axis and z-axis as the wind force always lies in the x-z panel.And the vector between the start point and the end point of a segment can be decompounded into three vectors which are along x-axis, y-axis, and z-axis, respectively.The decomposition process is illustrated as in Figure 7.
Then there are four situations about the wind force acting on the segment vector.
(a) The wind force along the x-axis acting on the segment vector along the y-axis leads the segment to rotate around the z-axis by angle α z .
(b) The wind force along the x-axis acting on the segment vector along the z-axis leads the segment to rotate around the y-axis by angle α y1 .
(c) The wind force along the z-axis acting on the segment vector along the x-axis leads the segment to rotate around the y-axis by angle α y2 .
(d) The wind force along the z-axis acting on the segment vector along the y-axis leads the segment to rotate around the x-axis by angle α x .
In each above situation, the related angle can be computed through (4).
And finally, the rotation angle of the data points can be computed as follows: The rotation matrtix for the current data sphere can be obtained through (6).Then, the position of the data sphere after motion can be figured out by multiplying the rotation matrix to the original vector of the data sphere as (5).

Movements of the Whole Branch.
In fact, the solution of motion described as above just aims to the little segment between two data spheres.And the motion of the whole branch is obtained by computing the motion of its data spheres from bottom to top one by one and then interpolating the new data spheres after motion.For a backbone branch, the initial data sphere is the root; otherwise the initial data sphere is also within another branch.The root data sphere is obviously not moving.But the motion of the data spheres contained by more than two branches should be computed carefully.If the current branch is an upper level one, then the position of the initial data sphere could just employ the position obtained in lower level branch.For example, in Figure 8, the data sphere bounded by the rectangle is contained by three branches.Then for the upper level branches, the motion of the initial data sphere doesn't need to be computed anymore as it can be obtained by employing the motion which has been computed in the lower level branch directly.

Animation of the Whole Tree.
As the tree has been constructed in accordance with the hierarchical structure as in Figure 4, the motion of the whole tree can be obtained by computing the motion of the branches from root branch to the leave branch hierarchically.The depth-first traverse algorithm is employed to solve the computing sequence problem.

Results and Conclusions
5.1.Results.Giving related parameters and certain time t, the movements of each data sphere, furthermore each branch, and finally the whole tree under the wind force in the current moment can be gotten.And by giving a period of time, we can get the continuous animation of the tree under different wind model.In Figure 9, the states of one tree in the moment of 0 seconds, 3 seconds, 7 seconds, 10 seconds, 15 seconds, and 20 seconds during 20 seconds animation under the gust of wind from x-axis direction are shown.In Figure 10, eight states of one tree during the 40 seconds animation under the gust of wind from x-axis direction are demonstrated.

Conclusions.
In this paper, an approach of generating real-time animation of trees based on a novel model-BBSC-is proposed, which can be applied in computer games.BBSC is a good representation for 3D trees and plants in particular for computer games as its solid mathematical representation and more compact dataset.Moreover, animation of trees can be generated easily as the data spheres have divided the branches into little segments automatically thus the motion of the tree can be obtained by computing the motion of each of these data spheres.By interpolating these data spheres after moving, the motion of the branch, and finally the motion of the whole tree can be implemented.The experimental results show that this method is proper and efficient for simulating tree animation in computer games.
(a) The data spheres (red) and the control spheres (green) (b) The BBSC after transformation (c) The rendered BBSC
Figure 1(b) shows the BBSC in a different viewpoint, and Figure 1(c) is the rendering result of the transformed BBSC.The BBSC presented above has many features which make it very suitable to construct 3D trees in games.(a) Solid mathematical fundamentals.(b) Precise evaluation.(c) Flexibility of manipulations and deformations.(d) More compact dataset than discrete or linear representations when defining a freeform 3D object.
(a) is the tessellation result of the BBSC-based tree model, and Figure 3(b) is the rendering result.After tessellation, texture mapping technique can be applied.Therefore, various kinds of trees can be generated through texture mapping techniques in games.

F
(b) The stable wind model

Figure 5 :
Figure 5: The relationship between the wind force and the time.
rotated y-axis by angle θ y ; finally rotates around the rotated x-axis by angle θ x : θy c θz − c θx s θz s θx s θy s θz + c θx c θz c θy s θx c θx s θy c θz + s θx s θz c θx s θy s θz − s θx c θz c θy c θx

Figure 9 :
Figure 9: Six states extracted from the 20 seconds animation of a tree.

Figure 10 :
Figure 10: Eight states extracted from the 40 seconds animation of a tree.