Method and apparatus for generating walk animation of virtual role, device and storage medium
View Patent ↗A method and apparatus for generating a walk animation of a virtual role includes: predicting touchdown points of a leg of the virtual role in the walk process according to a movement velocity and a movement direction of the virtual role; computing a position of a foot of the leg in a swing phase according to two adjacent touchdown points of the leg; performing, based on the position of the foot of the leg in the swing phase, inverse kinematics computation to obtain positions of bone points of the leg in the swing phase; and performing, based on the positions of the bone points of the leg in the swing phase, gait fusion to generate a walk animation of the virtual role.
1 . A method for generating a walk animation of a virtual role comprising n legs, the method being performed by a computer device, a walk process of a leg of the virtual role including alternating swing phases and stance phases, and the method comprising:
predicting a predicted movement trajectory of the virtual role in the walk process according to a movement velocity and a movement direction of the virtual role in a virtual environment;
sampling multiple touchdown points of a leg on the predicted movement trajectory by taking a current pose of the leg of the virtual role as a predicted starting point, comprising:
computing, in response to that a current pose of an i th leg of the virtual role is in a t th second state in a swing phase, a predicted duration based on a remaining duration of the swing phase and a duration of a stance phase;
determining a position of moving forward for a predicted length along the predicted movement trajectory as a body position of the virtual role at a time of touchdown by taking a position of the current pose of the virtual role on the predicted movement trajectory as a starting point, the predicted length being calculated based on the predicted duration and the movement velocity;
calculating, based on the body position of the virtual role at the time of touchdown and a relative position relationship between a body and the i th leg of the virtual role, touchdown points of the i th leg of the virtual role on the predicted movement trajectory,
wherein i is a positive integer not greater than n, and a previous touchdown point of two adjacent touchdown points is a lift-up point of a next touchdown point of the two adjacent touchdown points;
after the multiple touchdown points are determined, computing positions of a foot of the leg in a swing phase according to the two adjacent touchdown points of the leg;
performing, based on the positions of the foot of the leg in the swing phase, inverse kinematics computation to obtain positions of bone points of the leg in the swing phase; and
performing, based on the positions of the bone points of the leg in the swing phase, gait fusion to generate a walk animation of the virtual role.
2 . The method according to claim 1 , wherein the performing, based on the positions of the bone points of the leg in the swing phase, gait fusion to generate the walk animation of the virtual role comprises:
acquiring pre-configured gait parameters; and
performing, based on the gait parameters, gait fusion on the positions of the bone points of the leg in the swing phase to generate the walk animation of the virtual role.
3 . The method according to claim 2 , wherein the gait parameters comprise: a gait period and leg parameters of the leg within the gait period;
the performing, based on the gait parameters, gait fusion on the positions of the bone points of the leg in the swing phase to generate the walk animation of the virtual role comprises:
performing, within the gait period, gait fusion on the positions of the bone points of the leg in the swing phase according to the leg parameters of the leg within the gait period to generate the walk animation of the virtual role;
wherein the gait period is an alternating period between the swing phase and a stance phase, and the leg parameters comprise at least one of a lift time point, a duration of the swing phase and a pace midpoint of the stance phase.
4 . The method according to claim 3 , wherein the gait parameters comprise a first gait parameter in a first motion pattern and a second gait parameter in a second motion pattern;
the method further comprises:
performing interpolation on the first gait parameter and the second gait parameter to obtain a first blended gait parameter; and
performing, based on the first blended gait parameter, gait fusion on the positions of the bone points of the leg in the swing phase to generate a transition animation of the leg of the virtual role to switch from the first motion pattern to the second motion pattern.
5 . The method according to claim 3 , wherein the gait parameters comprise a third gait parameter in a first movement direction and a fourth gait parameter in a second movement direction;
the method further comprises:
performing interpolation on the third gait parameter and the fourth gait parameter to obtain a second blended gait parameter; and
performing, based on the second blended gait parameter, gait fusion on the positions of the bone points of the leg in the swing phase to generate a walk animation of the leg of the virtual role in the third movement direction;
wherein the third movement direction is a movement direction between the first movement direction and the second movement direction.
6 . The method according to claim 1 , wherein the predicted duration is a sum of the remaining duration of the swing phase and half of the duration of the stance phase.
7 . The method according to claim 1 , further comprising:
Computing, in response to a ground where a touchdown point of the multiple touchdown points is located being a non-flat ground, a first projection point of the touchdown point on the non-flat ground in a vertical direction;
extracting, based on a leg swing distance, a reference point, from a line between the touchdown point and the first projection point; and
using a second projection point of the reference point on the non-flat ground in the vertical direction as an updated touchdown point.
8 . The method according to claim 7 , further comprising:
deflecting a pose of the foot at the time of touchdown according to the normal direction of the ground where the updated touchdown point is located.
9 . The method according to claim 7 , comprising:
determining a spline curve, in response to that an obstacle exists below a body of the virtual role, based on positions of the two adjacent touchdown points and the highest point of the obstacle; and
superposing the spline curve with the leg swing curve to obtain an updated leg swing curve.
10 . The method according to claim 1 , wherein the computing the positions of the foot of the leg in the swing phase according to the two adjacent touchdown points of the leg comprises:
determining, based on positions of the two adjacent touchdown points, a leg swing curve, the leg swing curve indicating a swing trajectory of the foot in the swing phase; and
performing, based on the leg swing curve, interpolation computation on the foot of the leg to determine the positions of the foot of the leg in the swing phase.
11 . The method according to claim 1 , wherein the performing, based on the positions of the foot of the leg in the swing phase, inverse kinematics computation to obtain positions of bone points of the leg in the swing phase comprises:
performing a cyclic coordinate descent inverse kinematics (CCDIK) computation according to the two adjacent touchdown points of the leg to obtain the positions of the bone points of the leg in the swing phase;
or
performing a forward and backward reaching inverse kinematics (FABRIK) computation according to the two adjacent touchdown points of the leg to obtain the positions of the bone points of the leg in the swing phase.
12 . The method according to claim 1 , further comprising:
acquiring a torso animation of the virtual role, the torso animation is an animation of a body of the virtual role in the walk process; and
fusing the torso animation of the virtual role with the walk animation of the virtual role to obtain a bodily movement animation of the virtual role.
13 . The method according to claim 12 , wherein the fusing the torso animation of the virtual role with the walk animation of the virtual role to obtain the bodily movement animation of the virtual role comprises:
scaling a duration of the torso animation of the virtual role according to a duration of a gait period to obtain a scaled torso animation; the gait period being an overall period of one swing phase and one alternating stance phase; and
fusing the scaled torso animation with the walk animation of the virtual role to obtain the bodily movement animation of the virtual role.
14 . The method according to claim 1 , further comprising:
determining, in response to that a body of the virtual role comprise elastic components, at least two levels of bone nodes corresponding to the elastic components in a bone tree of the virtual role; and
performing vibration computation of a three-dimensional vibration model starting from a root node of the at least two levels of bone nodes by taking a previous-level bone node as an origin and a next-level bone node as a vibrator, and determine a bone update position of the next-level bone node, until a bone update position of the elastic component is updated.
15 . The method according to claim 1 , further comprising:
computing a stance vector of the leg of the virtual role, the stance vector indicating an inclination of a touchdown point of a current leg relative to a torso of the virtual role;
computing, based on the stance vector of the leg, a pose angle of the torso of the virtual role; and
performing, based on the pose angle, lean compensation on the torso of the virtual role.
16 . The method according to claim 1 , further comprising:
computing, in response to that the virtual role is above a convex ground, an average height difference between the touchdown point of the leg of the virtual role and a vertex of the convex ground; and
performing raising compensation on a height of a torso of the virtual role according to the average height difference.
17 . The method according to claim 1 , wherein the movement direction of the virtual role is controlled in response to a user operation in a virtual game.
18 . An apparatus for generating a walk animation of a virtual role comprising n legs, a walk process of a leg of the virtual role including alternating swing phases and stance phases, and the apparatus comprising:
predicting a predicted movement trajectory of the virtual role in the walk process according to a movement velocity and a movement direction of the virtual role in a virtual environment;
sampling multiple touchdown points of a leg on the predicted movement trajectory by taking a current pose of the leg of the virtual role as a predicted starting point, comprising:
computing, in response to that a current pose of an i th leg of the virtual role is in a t th second state in a swing phase, a predicted duration based on a remaining duration of the swing phase and a duration of a stance phase;
determining a position of moving forward for a predicted length along the predicted movement trajectory as a body position of the virtual role at a time of touchdown by taking a position of the current pose of the virtual role on the predicted movement trajectory as a starting point, the predicted length being calculated based on the predicted duration and the movement velocity; and
calculating, based on the body position of the virtual role at the time of touchdown and a relative position relationship between a body and the i th leg of the virtual role, touchdown points of the i th leg of the virtual role on the predicted movement trajectory,
wherein i is a positive integer not greater than n, and a previous touchdown point of two adjacent touchdown points is a lift-up point of a next touchdown point of the two adjacent touchdown points;
after the multiple touchdown points are determined, computing positions of a foot of the leg in a swing phase according to the two adjacent touchdown points of the leg;
performing, based on the position of the foot of the leg in the swing phase, inverse kinematics computation to obtain positions of bone points of the leg in the swing phase; and
performing, based on the positions of the bone points of the leg in the swing phase, gait fusion to generate a walk animation of the virtual role.
19 . A non-transitory computer-readable storage medium, storing a computer-readable instruction, and the computer-readable instruction being loaded and executed by one or more processors to implement:
predicting a predicted movement trajectory of a virtual role in a walk process according to a movement velocity and a movement direction of the virtual role in a virtual environment, the walk process of a leg of the virtual role including alternating swing phases and stance phases, and the virtual role comprising n legs;
sampling multiple touchdown points of a leg on the predicted movement trajectory by taking a current pose of the leg of the virtual role as a predicted starting point, comprising:
computing, in response to that a current pose of an i th leg of the virtual role is in a t th second state in a swing phase, a predicted duration based on a remaining duration of the swing phase and a duration of a stance phase;
determining a position of moving forward for a predicted length along the predicted movement trajectory as a body position of the virtual role at a time of touchdown by taking a position of the current pose of the virtual role on the predicted movement trajectory as a starting point, the predicted length being calculated based on the predicted duration and the movement velocity; and
calculating, based on the body position of the virtual role at the time of touchdown and a relative position relationship between a body and the i th leg of the virtual role, touchdown points of the i th leg of the virtual role on the predicted movement trajectory,
wherein i is a positive integer not greater than n, and a previous touchdown point of two adjacent touchdown points is a lift-up point of a next touchdown point of the two adjacent touchdown points;
after the multiple touchdown points are determined, computing positions of a foot of the leg in a swing phase according to the two adjacent touchdown points of the leg;
performing, based on the positions of the foot of the leg in the swing phase, inverse kinematics computation to obtain positions of bone points of the leg in the swing phase; and
performing, based on the positions of the bone points of the leg in the swing phase, gait fusion to generate a walk animation of the virtual role.