Hybrid Motion Graphs for Character Animation

Many works in the literature have improved the performance of motion graphs for synthesis the humanlike results in limited domains that necessity few constraints like dance, navigation in small game like environments or in games by the gesture of feedback on a snowboard tutorial. The humanlike cannot exist in an environment without interacting with the world surrounding them; the naturalness of the entire motion extremely depends on the animation of the walking character, the chosen path and the interaction motions. Addressing exact position of end-effectors is the main disadvantage of motion graphs which cause less importance expended to the search for motions with no collision in complex environments or manipulating motions. This fact motivates this approach which is the proposition of an hybrid motion graphs taking advantages of motion graphs to synthesis a natural locomotion and overcoming their limitations in synthesis manipulation motions by combined it with an inverse kinematic method for synthesis the upper-body motions. Keywords—motion graphs; inverse kinematic; virtual human; animation


INTRODUCTION
Virtual humans have a wide range of applications with the developments of interactive entertainments such as games, learning and training applications or film animations. Responding to the needs of these applications, believable synthetic characters must populate the virtual environments. Character interactions and moves must be realistic to suit the visual richness of the virtual environments. To meet the interactivity demands, character must efficiently be animated and controllable by the simulation.
In literature model-based and data-driven are two semiautomatic techniques classes developed for creating human animations.
Simulation, search, and optimization are applied by modelbased approaches to synthesis character motion by limiting the space of possible motion using biomechanical , kinematic, dynamic models, the representation of motion in these approaches is flexible , but may suffer from the difficulty of construction and control [11]. It was well used addressing human-like characters manipulating objects, , but could fail to produce a motions with natural looking if the models do not appropriately constrain the motion particularly for motions with low energy, such as locomotion.
Data-driven approaches mainly refer to the reuse of existing 3D motion data to generate new motions. Which do not present a perfect solution either because when the motion is highly dynamic or involves constrained interactions with the environment or other characters, the adaption of existing captured motions to new situations will mostly be difficult. To address these issues, several researchers have been proposed, the most popular approach is motion graphs where locomotion synthesis has been an active area of study. The search techniques based on motion graphs provide lowest distortion of the captured motions, and naturally allow the exploration of solutions in complex environments.
The main contribution of this paper is the proposition of a hybrid motion graphs based on the idea of using motion graphs to synthesis the locomotion motions to reach different locations in the environment and to achieve the reaching range of objects mainly needed for the forward and backward stages of the inverse kinematic method used to control the trajectories of the end-effectors in the generation of the upper body motions. Our hybrid approach proves to be very efficient for producing object manipulation in different locations in the environment with user contro by allowing a coordination of hyper body actions with locomotion, and could be suitable for interactive application. Avoiding problems related to the explosion of the motion graph size in case of including both locomotion and upper-body actions which cause absolutely an increase of the search time and a complication of the search method which may fail to find the right motion in the right time, or problems related to only base on inverse kinematic methods that may fail in the generation of natural looking for low energy motions such as locomotion, the proposed hybrid motion graphs present a good solution for decrease search time also address a wide range of virtual character motions and could be useful to many applications in humanoid robotics, ergonomics, training, entertainment.
The paper is organized as follow: In the first section, a review of works of the literature related to character locomotion, a discussion about data-driven methods, their advantages and drawbacks. Also works related to the inverse kinematic methods for the hyper body character animation. In the second section an overview on the proposed method that allows the synthesis of a natural locomotion and hyper body motions with a description of each step. In the third section a discussion of the obtained results of the proposed method.

A. Locomotion motions
Data-driven motion synthesis generates new motion from a library of motion clips. A lot of approaches have been proposed like blending approaches that create new motion by (IJACSA) International Journal of Advanced Computer Science and Applications, Vol. 7, No. 1, 2016 46 | P a g e www.ijacsa.thesai.org blending multiple motions depending on blending weights, for synthesizing new motions that parameterize high level interesting features, it has been used to synthesize locomotion animation to lead a virtual character [9,24,26,27].
This approach have trouble to deal with the planning around obstacles, and problems in the generation of motions able to cover a sufficiently large solution space.
Motion capture data have been integrated with Planning methods in many way, Lau and Kuffner [14] use motion planning with pre-computed search trees to synthesis a long motion sequences even in dynamic environments containing many characters.
Motion clips are abstracted as high-level behaviours and then associated with a behaviour finite-state machine , motions are generated automatically by a planning algorithm that makes a global search of the state machine and computes a sequence of behaviours for the character that meet user requirements [15]. The motion database is annotated. Labels are used to describe the desired action, which is then built using dynamic programming [21].
Extracting motions from a motion graph structure is a popular approach for producing realistic full-body motions. Automatically processing motion capture data is the objective of motion graphs to facilitate the parameterization and interpolation of motions, and allow the motion planners to operate in the created parametric spaces. The motion graph structure is based on the idea of connecting similar frames in a database of motion capture clips. Once a motion graph is available, a graph search is performed to extract motions with desired properties [12,13,20,22].
The following work based motion graphs concentrated on achieving good connectivity in motion graphs by using interpolated motion clips with further similar poses than the original motion data to construct a well-connected motion graph [17], minimizing the size of the graphs by proposing an approach to select a good motion set by searching from a large motion graph that represent the motion capture data for a minimum size subgraph and using an Iterative Sub-graph Algorithm, to find a good approximation to the optimal solution [18], optimizing the search operations in motion graphs [28,29]. Mahmudi and Kallmann [20] propose featurebased motion graphs for the synthesis of locomotion motions among obstacles where transitions is chosen based on relevant features. They use a channel search method in motion graph search to avoid obstacles. Planning locomotion using motion graphs have received a lot of attention, in contrast to the manipulation of objects around obstacles because using motion graphs it is in general very hard to generate motion that needs tight coupling to the environment, like pointing to an object in the world, or walking up a stairs, unless exactly those motions are in the database. As more motion constraints are added, fewer paths will become available [7].
Yazhou [8] proposes a locomotion planner based motion graphs coupling with an upper-body actions planner that use a blending method to produce realistic motions of locomotion and interaction with the environment. The locomotion planner does a lot of iterations that required the execution of the upper body motion each test to reach the target and in some cases it fails.
The interaction of the virtual human with the environment involves posing the character body to respect new constraints, motion graphs have the inconvenient to not precise the end effectors positions; methods of research sometimes can fail to generate the desired motion sequence because the motion corpus itself does not contain motion clips required.

B. Manipulation motions
The Animation of virtual character to realise many task and object interactions have been treated by many approaches, motion blending was used to generate reaching and grasping motions that satisfy spatial constraints [3,8].
Physics-based and procedural animation offers a great amount of control over motion by employing a mathematical model in the generation of the desired character motion depending on high-level parameters. Physically-based techniques use physic laws such as Newton's laws and conservation of energy. Determining the human motion using this techniques, require information more than joint angles and position, it need Information such as mass distribution for each body part and torques generated by each joint which is not easy specially for the synthesis of hyper body motions which involve object manipulation like reaching, grasp and displacing objects, often the Inverse Kinematics (IK) and collision avoidance are used to solve this type of problem, the samplingbased planners' methods are required when several obstacles are on the way.
Methods based on Inverse Kinematics (IK) mainly control the trajectories of the end-effectors, and can integrate some reactive collision avoidance behaviour in order to cope with obstacles. Inverse Kinematics is a method used to solve the problem of computing joint rotations in order to reach given targets with the end-effectors [19]. The analytical methods are the best choice to handle with simple kinematic chain that contains a few degrees of freedom [5]. These methods are fast but not support the complex articulated chain. Numerical methods based on Jacobian matrix are proposed to deal with complex articulated chain but suffer from the computational time, the heuristic method are proposed to solve this inconvenient [4,16,23]. Searching for a sequence of suitable hand locations in the workspace is one approach for reaching and arm planning. To reach each intermediate hand location, the IK method is used to lead the arm posture. Through interpolation of the postures, the final valid motion is obtained [11,25,30]. FABRIK (Forward And Backward Reaching Inverse Kinematics) [1,2] produces visually realistic poses with low computational cost, it bases on geometric algebra to resolve the inverse kinematic problem and support multiple chains with multiple end effectors because Constraints can easily be incorporated within FABRIK.
The virtual character is required to interact with different objects in different locations in the surrounding environment which involve posing the character body to respect new constraints, often in combination with environment navigation tasks. Motion graphs have the inconvenient to not precise the end effectors positions, this fact motivates this approach to (IJACSA) International Journal of Advanced Computer Science and Applications, Vol. 7, No. 1, 2016 47 | P a g e www.ijacsa.thesai.org synthesis reactive motions in real-time, based on the use of the motion graphs in combination with an inverse kinematic method.

III. HYBRID MOTION GRAPHS
The proposed approach presents a solution to avoid many problems related to the explosion of motion graph size in case of including both locomotion and upper-body actions and preserve produced realistic motions. We propose a hybrid motion graphs taking advantage of motion graphs to synthesis a natural locomotion and overcoming their limitations to synthesis manipulation motions by combined it with an inverse kinematic method for synthesis the upper-body motion.

A. Overview of the proposed method
An overview of the proposed method is illustrated in the  The proposed method has two phases:

1) Offline phase:
Allows the construction of the motion graphs according to Kovar and Gleicher [13] steps: a) Finding Candidate Transition Points: Distance metrics are used to detect the similar frames for choosing the transition points, taking into account the relative importance of joints, changes in joint-velocity and acceleration and identifying compatible coordinate systems.
To calculate the distance D(A j , B k ) between two frames A j and B k , a point clouds is made over two windows of frames with length l defined by the user, every point cloud is composed of smaller point clouds that represent every frame position in the window.
The distance between A j and B k is calculated as follow: Where p i and p j are the corresponding points in the two point clouds, a linear transformation T formed of a rotation by θ degrees about the vertical axis and followed by a translation of (x 0 , z 0 ) in the floor plane is applied to the second point cloud . Fig. 2 illustrates a point clouds made over two windows of frames. The weights w i may be taken to assign different importance to each joint in each frame and can be chosen by the user. Fig. 3 illustrates list of weights for each bones of an ASF/AMC skeleton [6]. The distance metrics discussed above is computed for each pair of frames in the database to form a sampled 2D error function.

b) Selecting transition points:
The distance that is found in this manner can be thought of to be a sampled 2D error or distance function. This function is normalized, so that, all the distances lie in the range [0,1]. We take this function and select only the local minima of this function, which gives us the candidate transition points. To guarantee that those local minima of this error function are actually good enough for transitions, a threshold must be defined by the user and the D(A j , B k ) ) must be smaller than it. The value of the threshold effect on the quality of the generated transitions, and the connectivity of the graph. c) Creating transition clips: We have said that transitions are clips designed to connect two pieces of original θ,x 0 ,z 0 min ∑ w i || p i − T p j || 2 θ,x 0 ,z 0 i θ,x 0 ,z 0 www.ijacsa.thesai.org data, it is created by identifying the sufficiently similar portions of the initial clips that straight forward blending will produce a valid transitions. If the distance between frames A j and B k is less than the threshold and it is selected as a transition point, then we need to create the transition frames and add them as edges in the motion graph, by blending between the frames of the two windows of frames for A j and B k starting by applying the appropriate aligning 2D transformation to motion B. The frames A j to A j+l-1 and B k -l+1 to B k are interpolated as follows: (2) Where R p means the position of the root joint in frame p of the transition. The interpolation between the rotations is performed by: The following conditions must be fulfilled by the weight function of the interpolation ( ((((( (4) To ensure the continuity: (5) To maintain the constraints of the original motion clips and ensure that the interpolation will not hurt it , the constraint will be activated in the first half of the new transition frames and passive in the second half in case it was active in the first clip but not in the second.

d) Pruning the Graph:
In the resulted graph there may be portions with very high connectivity, and there may be portions with very low connectivity that may contain dead end nodes, which are nodes that are not part of any cycle in the graph, also contain other nodes that could be a part of one or more cycles which called sinks. These nodes may halt the motion search. To eliminate these problematic nodes we prune the graph by calculating the largest strongly connected component of the graph.
2) Online phase The online phase allows the interactive generation of motions. This approach is similar to previous techniques that use sketching; the user draw the path sketched which will be followed by the character in the locomotion motions.
User chooses the end effectors position for the hyper body limbs before, after or during the locomotion motion which help the character to avoid obstacle (like moving head to avoid a bar) and reach objects.
The search method use a depth first search to obtain graph walks. Branch-and-bound strategy and incremental search are used to improve the efficiency [13].
The user supplies a scalar function g(w ;e) to evaluates the additional error accrued by appending an edge e to the existing path w The total error f(w) of a graph walk is: Where w is comprised of the edges e 1 ,….., e n . We assumed that g(w,e) is never negative Therefore, the total error cannot decrease by adding an edge to a graph walk.
f is evaluated for all graph walks using a depth-search , then the best graph walks is selected.
We use branch and bound algorithm in which we prune any graph incapable of producing an optimal graph walk.
We apply path synthesis that is generating a motion stream that follows a user specified path P. The idea is to estimate the actual path P′ travelled by the character through a graph walk and measure how different it is from P [13].
To compare the original paths P and the generated path P', at each frame, the root joint of the character is projected on the floor giving a linear curve. Then calculate P(s) is the point on P with arc-length distance from the start of P is s. The completeness condition of P' is if P' is sufficient long or surpasses the length of P. For the hyper body IK method, the virtual character is modeled as a chain composed of rigid links attached at their ends by rotating joints, the chains can be formalized as follows: All joints with no children are labeled as end-effectors. FABRIK uses points and lines to solve the IK , it divide the problem into two relevant phases , a forward step and a backward steps , and support all the rotational joints limits and joints orientations by repositioning and re-orienting the target at each step.
The structure of the human skeleton is divided into smaller kinetic chains which are then sequentially adapted into the body posture in a hierarchical order [1,2]. Fig. 5 shows the hierarchical structure of the hyper body used in the approach.
(IJACSA) International Journal of Advanced Computer Science and Applications, Vol. 7, No. 1, 2016 49 | P a g e www.ijacsa.thesai.org Fig. 5. Bones of the skeleton applied within the IK method [6] The FABRIK method may be applied starting from the right hand (end effectors) until the root (pelvis), from the left hand (end effector) until the root, from the root until the head When synthesizing reaching motion using the standard FABRIK, the focus tends to be on arms control, if the target is not reachable because the distance between the target and the first joint (root) is higher than the summation of the length of each links , the method do not provide a solution . However stepping motion can be a solution because humans often step in the direction of the target in order to help their reaching action. In doing so, the target falls within the convenient reaching range ,in this approach this solution is provided by allowing the search method to place the character near the target location and ensure that the target is reachable by identifying a reaching range H where H = D -∑ (8) D is the distance between the target and the first joint (root), d i is the joints distances of the chain.
To follows the user specified sketch presented by a 2D path planner on the floor plan, the branching factor of the search must be limited to only allow expansions nearby this path, else when the users choose to manipulate an object which is far from reaching, an extensions is integrated to customize the locomotion toward the object location.
The extension is a new root position that insures that the target is in the reaching range. Whenever the locomotion search expansion generates a character position that is close enough to the target the forward and backward stages are applied. An example of the unrolling of the motion graph with the expansions obtained is illustrated in Fig. 6.
To show the progress of the IK method an example of eight link manipulator is used Fig. 7, which is similar to the virtual human hands; the same principal is applied for the head but for fewer links (joints). The initial pose of end effectors and target position and each point is expressed by the coordinate of Cartesian space. The Fabrik [1] algorithm is extended as follow: Input : The target position T The joints positions P 1 ,P 2, , ……. ,P 9 Distances between each joint d 1 ,d 2 ,……..,d 8 Output : The generated joint positions for P 1 ,P 2, , ……. ,P 9 1-Distance test Check that the distance between the target T and the first joint P 1 is within the summation of length of each link. D = P 1 −T If D ≤ (d 1 + d 2 ,……..,+d 8 ) target is reachable 2-run Forward stage (a) Move the hand P 9 end effectors to the target position, and the wrist point P 8 . P 8 was moved on the line from P 9 to create P′ 9 and P′ 8 . The distance between P′ 9 and P′ 8 is the same as d 8 (b) Continue step (a) until new P′ 1 is reached 3-Run Backward stage (c) Move P′ 1 to its initial position P 1 .
(d) Repeat procedure as (c), and P′′ 9 moves closer to the target than P 9 .
Run the Forward stage until the end-effectors is satisfactorily close to the target.

IV. RESULTS
In this section we investigate the results of the performed experiments relative to the automatic construction of motion graphs based on connecting between different motion clips in the database and then searching in the resulted graph for motions that satisfy user constraints using the procedures discusses above and the interactive generation of realistic controllable locomotion motions for character locomotion, other results demonstrate the hyper-body motions adjustment to reach different location using the inverse kinematic method.
For the locomotion motion the graph is automatically generated from an input set of motion clips like running clips, sharp turns used to animate a human-like character in a virtual environment. In experimentation the time to build the motion graph was 40 seconds for an example of a motion graph formed over 8 motion clips. Fig. 8 illustrates the motion clips list, the weight of each joints and the generated point cloud of the distance metric. For the path synthesis the user first draw a sketch using the mouse, this sketch will be followed in the phase of generation of the new motions   Fig. 10, illustrates the path synthesis and the generation of the new motion following the yellow line represents the user sketched path and the white lines represent the edges in the graph walk and red line represents the actual path followed by the character. The hyper-body pose are adjusted to new constraints using the inverse kinematic method. Fig. 11 and Fig. 12 illustrate right and left hand adjustment using the IK method. Hybrid motion graphs is a framework for generating realistic, controllable whole-body motion through the combination between two techniques, motion graphs and Inverse kinematic method to resolve the problems related to including both locomotion and upper-body actions in the same graph from the explosion of the size of the graph, the increase of the search time and the complication of the search method, also problems related to the fail in the generation of natural motions in case of using just inverse kinematic methods.

V. CONCLUSION
In this paper we have proposed a hybrid motion graphs for generating realistic whole body motion taking advantages of motion graphs to synthesis a natural locomotion and overcoming their limitations to synthesis manipulation motions by combined it with an inverse kinematic method for synthesis the upper-body motion.
ACKNOWLEDGMENT A special thanks to lucas panian for his help with the motion graphs implementation.