CN111583367B - Hair simulation method and system - Google Patents

Hair simulation method and system Download PDF

Info

Publication number
CN111583367B
CN111583367B CN202010442123.6A CN202010442123A CN111583367B CN 111583367 B CN111583367 B CN 111583367B CN 202010442123 A CN202010442123 A CN 202010442123A CN 111583367 B CN111583367 B CN 111583367B
Authority
CN
China
Prior art keywords
hair
point
mapping
points
inum
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202010442123.6A
Other languages
Chinese (zh)
Other versions
CN111583367A (en
Inventor
林文林
郑泽彬
张彬彬
黄志超
朱健
卢雨晨
项博文
李多春
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Goufan Xiamen Information Technology Co ltd
Original Assignee
Goufan Xiamen Information Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Goufan Xiamen Information Technology Co ltd filed Critical Goufan Xiamen Information Technology Co ltd
Priority to CN202010442123.6A priority Critical patent/CN111583367B/en
Publication of CN111583367A publication Critical patent/CN111583367A/en
Application granted granted Critical
Publication of CN111583367B publication Critical patent/CN111583367B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T13/00Animation
    • G06T13/203D [Three Dimensional] animation
    • G06T13/403D [Three Dimensional] animation of characters, e.g. humans, animals or virtual beings
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2200/00Indexing scheme for image data processing or generation, in general
    • G06T2200/04Indexing scheme for image data processing or generation, in general involving 3D image data

Abstract

The invention provides a hair simulation method and a system in the field of computer graphics, wherein the method comprises the following steps: s10, setting an initial state of hair styling, and dividing the hair styling into a fixed area and a moving area; s20, generating a mapping skeleton of the hair based on the hair trends of the fixed area and the moving area; and S30, setting the motion parameters of the hair, and simulating the motion of the hair by using the motion parameters and the mapping bones. The invention has the advantages that: the real-time simulation of the movement of the complex hairstyle is realized.

Description

Hair simulation method and system
Technical Field
The invention relates to the field of computer graphics, in particular to a hair simulation method and a hair simulation system.
Background
In the fields of movie production, animation production, and the like, in order to achieve a more realistic effect, it is necessary to simulate hair. For the simulation of hair, the following method is conventionally employed: 1. the method comprises the steps of preparing playing animation of hair movement and playing conditions in advance, and playing the animation frame by frame to simulate the movement of hair when the playing conditions are met; 2. the method comprises the steps of adopting a physical simulation method of an FTL (hair follicle adapter) and a DFTL (dynamic hair follicle adapter) optimized on the FTL, namely generating hundreds or thousands of basic hairlines according to the characteristics of hair, adding spring mass point restraint to the basic hairlines, and then forming a hair bundle on the roots of the basic hairlines in an interpolation mode so as to simulate the whole hair.
However, the conventional method has the following disadvantages: 1. by playing the animation, the simulation effect of the hair depends on the experience of a 3D modeler; different animations need to be made for different situations; animation playing needs to be stored every frame, and the storage capacity is large; 2. the hair styling method can only aim at simple hair styles, and has insufficient stability and poor sense of reality during deformation of complex hair styles; in order to ensure the shape of the complicated hair, the number of basic hairlines must be increased, which results in large calculation amount; the selection of the roots of the base hair for different hairstyles is also a great task.
Therefore, how to provide a hair simulation method and system to realize real-time simulation of the motion of a complex hairstyle becomes an urgent problem to be solved.
Disclosure of Invention
The invention aims to provide a hair simulation method and a hair simulation system, which can realize real-time simulation of the motion of a complex hairstyle.
In one aspect, the present invention provides a hair simulation method, comprising the steps of:
s10, setting an initial state of hair styling, and dividing the hair styling into a fixed area and a moving area;
step S20, generating a mapping skeleton of the hair based on the hair trends of the fixed area and the moving area;
and S30, setting the motion parameters of the hair, and simulating the motion of the hair by using the motion parameters and the mapping bones.
Further, in step S10, the initial state is a default regression state of the hair style under the action of gravity only.
Further, in the step S10, the fixed area and the moving area both include a plurality of hairs; the hair of the fixed area pulls the hair of the moving area.
Further, the air conditioner is provided with a fan, the step S20 specifically includes:
step S21, settingThe hair of the fixed area is a point set P { P 1 ...p n -hair of said motion region is composed of a set of points Q 1 ...q n The connection relation between the fixed area and the moving area is L { L } 1 ,l 2 ...l n }; the set of points P { P 1 ...p n And a set of points Q Q 1 ...q n The connecting line of R { R } 1 ...r m R is a subset of L; the communication line R { R } 1 ...r m The set of midpoints is M { r } M1 ...r Mm };
Setting the positive direction of the head as a starting point S and the threshold value of the angle as D, searching the point closest to the starting point S in the counterclockwise direction, and adding a set H 1 (ii) a Counter-clockwise lookup with the set H 1 Nearest point, join set H 1 Until there are no points with an angle greater than said D;
judging the set H 1 Whether or not it is equal to the set of points Q Q 1 ...q n If yes, go to step S22; if not, counterclockwise searching is carried out on the set H 1 Nearest point, join set H 2 Counter-clockwise search with said set H 2 Nearest point, join set H 3 Up to H 1 +H 2 +...+H K = Q, and proceeds to step S22; wherein K is a positive integer;
step S22, setting the length and density of the mapped skeleton according to the set H 1 +H 2 +...+H K Dividing moving hair points into Q 1 ...Q K (ii) a Based on the set M { r M1 ...r Mm Get the moving hair point and the point set P { P } 1 ...p n Points connected with each other are set as starting points; finding a point farthest from the starting point, and setting the point as an end point;
determining a mapping bone of the hair based on the y-axis coordinate of the starting point, and evenly dividing the starting point based on the length and the density of the mapping bone to obtain a bone line;
s23, calculating the mapping relation between the moving hair point and the mapping skeleton by using a point and quadrilateral centroid coordinate formula:
u=(a*x+b*y+c)/(g*x+h*y+1);
v=(d*x+e*y+f)/(g*x+h*y+1);
wherein (u, v) represents a point falling inside a quadrilateral composed of four mapped bones, u being an abscissa and v being an ordinate; (x, y) represents a point on a quadrilateral comprised of four mapped bones, x being the abscissa and y being the ordinate; a. b, c, d, e, f, g and h represent parameters to be solved, and four groups (u, v) and (x, y) are used for solving;
step S24, recording a point P ' (P ') mapping bones from the nearest position to the farthest position of the hair points of the fixed area ' 0 ...P' n ) And are spaced apart from each other by L '(L' 1 ...L' n-1 ) (ii) a n represents the serial number of the point and is a positive integer;
is No. P' n When rotating around a point, a new position is P _ new (P _ nx, P _ ny, P _ nz), a home position is P _ old (P _ ox, P _ oy, P _ oz), a rotation angle is ir, the number of segments of hair is imnu, and a flexibility parameter is k, then a point P' n The positions of (A) are:
p_nx=p_ox*cos((1+k*n)*ir*n/inum)-p_oz*sin((1+k*n)*ir*n/inum);
p_nz=p_oz*cos((1+k*n)*ir*n/inum)-p_ox*sin((1+k*n)*ir*n/inum);
point P' n Constrained by pendulum, to point P' n-1 Until the length equals L' n-1
When point P' n Stretching in one direction and the stretching distance is (i) x ,i y ,i z ) Then point P' n The positions of (A) are:
p_nx=p_ox+i x *(1+k*n)*n/inum;
p_ny=p_oy+i y *(1+k*n)*n/inum;
p_nz=p_oz+i z *(1+k*n)*n/inum;
point P' n Constrained by pendulum, to point P' n-1 Until the length equals L' n-1
Further, in step S30, the motion parameters specifically include:
the position of the hair point on the current framep” n Speed V of hair point in current frame n The maximum movement speed of the hair point in the x-axis, return, and the maximum movement speed of the hair point in the z-axis, return;
p” n =p” n-1 +V n t;
V n t=V n-1 +at;
a=(F gravity force +F Tension force +F Other external forces )/m;
Where t represents the time of movement of the hair point, a represents the acceleration, m represents the mass of the hair, F Other external forces Finger pull or wind force.
In another aspect, the invention provides a hair simulation system comprising the following modules:
the hair styling initialization module is used for setting an initial state of hair styling and dividing the hair styling into a fixed area and a moving area;
a mapping skeleton generation module for generating a mapping skeleton of the hair based on the hair trends of the fixed area and the motion area;
and the hair simulation module is used for setting the motion parameters of the hair and simulating the motion of the hair by using the motion parameters and the mapping bones.
Further, in the hair style initialization module, the initial state is a default regression state of the hair style only under the action of gravity.
Further, in the hair styling initialization module, the fixed area and the moving area both include a plurality of hairs; the hair of the fixed area pulls the hair of the moving area.
Further, the mapping bone generation module specifically includes:
a recent hair point searching unit for setting a hair point set P { P) of the fixed region 1 …p n -hair of said motion region is composed of a set of points Q 1 …q n The connection relation between the fixed area and the moving area is L { L } 1 ,l 2 ...l n }; the set of points P { P 1 ...p n And a set of points Q Q 1 ...q n The connecting line of R { R } 1 ...r m R is a subset of L; the communication line R { R 1 ...r m The set of midpoints is M { r } M1 ...r Mm };
Setting the positive direction of the head as a starting point S and the threshold value of the angle as D, searching the point closest to the starting point S counterclockwise, and adding a set H 1 (ii) a Counter-clockwise lookup with the set H 1 Nearest point, join set H 1 Until there is no point with an angle greater than said D;
judging the set H 1 Whether or not it is equal to the set of points Q Q 1 ...q n If yes, entering a skeleton generation unit; if not, counterclockwise searching is carried out on the set H 1 Nearest point, join set H 2 Counter-clockwise search with said set H 2 Nearest point, join set H 3 Up to H 1 +H 2 +...+H K = Q, and enter a bone generation unit; wherein K is a positive integer;
a bone generation unit for determining the length and density of the mapped bone from the set H 1 +H 2 +...+H K Dividing moving hair points into Q 1 ...Q K (ii) a Based on the set M { r M1 ...r Mm Get the moving hair point and the point set P { P } 1 ...p n A point connected with the point is set as a starting point; finding a point farthest from the starting point, and setting the point as an end point;
determining a mapping bone of the hair based on the y-axis coordinate of the starting point, and evenly dividing the starting point based on the length and the density of the mapping bone to obtain a bone line;
the mapping relation calculation unit is used for calculating the mapping relation between the moving hair point and the mapping skeleton by using the point and the quadrilateral centroid coordinate formula:
u=(a*x+b*y+c)/(g*x+h*y+1);
v=(d*x+e*y+f)/(g*x+h*y+1);
wherein (u, v) represents a point falling inside a quadrilateral composed of four mapped bones, u being an abscissa and v being an ordinate; (x, y) represents a point on a quadrilateral comprised of four mapped bones, x being the abscissa and y being the ordinate; a. b, c, d, e, f, g and h represent parameters to be solved, and four groups (u, v) and (x, y) are used for solving;
a hair point position calculating unit for recording a point mapping a bone from a nearest position to a farthest position from the hair point of the fixed region as P '(P' 0 ...P' n ) And are spaced apart from each other by L '(L' 1 ...L' n-1 ) (ii) a n represents the serial number of the point and is a positive integer;
when point P' n When rotating around a point, a new position is P _ new (P _ nx, P _ ny, P _ nz), a home position is P _ old (P _ ox, P _ oy, P _ oz), a rotation angle is ir, the number of segments of hair is imnu, and a flexibility parameter is k, then a point P' n The positions of (A) are:
p_nx=p_ox*cos((1+k*n)*ir*n/inum)-p_oz*sin((1+k*n)*ir*n/inum);
p_nz=p_oz*cos((1+k*n)*ir*n/inum)-p_ox*sin((1+k*n)*ir*n/inum);
point P' n Constrained by pendulum, to point P' n-1 Is retracted until the length equals L' n-1
Is No. P' n Stretching in one direction and the stretching distance is (i) x ,i y ,i z ) Then point P' n The positions of (A) are:
p_nx=p_ox+i x *(1+k*n)*n/inum;
p_ny=p_oy+i y *(1+k*n)*n/inum;
p_nz=p_oz+i z *(1+k*n)*n/inum;
point P' n Bound by a pendulum to point P' n-1 Is retracted until the length equals L' n-1
Further, in the hair simulation module, the motion parameters specifically include:
position p of hair point in current frame " n Speed V of hair point in current frame n The maximum movement speed of the hair point in the x-axis, returnx, and the maximum movement speed of the hair point in the z-axis, returnz;
p” n =p” n-1 +V n t;
V n t=V n-1 +at;
a=(F gravity force +F Tension force +F Other external forces )/m;
Where t represents the time of movement of the hair point, a represents the acceleration, m represents the mass of the hair, F Other external forces Finger pull or wind force.
The invention has the advantages that:
the hair styling device is characterized in that the hair styling device is divided into a fixed area and a moving area, a mapping skeleton of the hair is generated based on the hair trend of the fixed area and the moving area, after the moving parameter of the hair is set, the moving parameter and the mapping skeleton are used for simulating the movement of the hair, the complexity of the hair can be guaranteed, the hair can be simulated in real time according to the mechanical condition of a physical environment and the movement condition of a human body, the hair styling device is suitable for the conditions that the hair swings along with the human body and the hair flutters, and the initial state is finally recovered under the condition of no force, namely, the real-time simulation of the movement of a complex hairstyle is realized.
Drawings
The invention will be further described with reference to the following examples with reference to the accompanying drawings.
Fig. 1 is a flow chart of a hair simulation method of the present invention.
Fig. 2 is a schematic diagram of a hair simulation system according to the present invention.
Fig. 3 is a diagram illustrating the effects of the fixed area and the moving area according to the present invention.
Fig. 4 is a graph of the effect of the inventive bone line.
FIG. 5 is a diagram of the effect of the invention of hair-point and mapping bone bindings.
Fig. 6 is a diagram of the effect of hair movement simulation of the present invention.
Detailed Description
Referring to fig. 1 to 6, a preferred embodiment of a hair simulation method according to the present invention includes the following steps:
step S10, setting an initial state of hair styling, and dividing the hair styling into a fixed area (a part attached to the scalp) and a moving area;
step S20, generating a mapping skeleton of the hair based on the hair trends of the fixed area and the moving area; the skeleton mapping is a general method in the field of model animation, and is generally used for human motion; the number of mapped bones of the hair can be determined through parameters, and tens of thousands of hair points can be mapped into 100 mapped bones in order to improve the calculation efficiency;
and S30, setting the motion parameters of the hair, and simulating the motion of the hair in the motion area by using the motion parameters and the mapping bone.
The application is also applicable to the movement of any flexible model.
In step S10, the initial state is a default regression state of the hair style only under the action of gravity.
In the step S10, the fixed area and the moving area both include a plurality of hairs; the hair of the fixed area pulls the hair of the moving area.
The step S20 specifically includes:
step S21, setting a hair by point set P { P) of the fixed area 1 …p n -hair of said motion region is composed of a set of points Q 1 …q n The connection line relationship between the fixed area and the motion area is L { L } 1 ,l 2 ...l n }; the set of points P { P 1 ...p n Q and the set of points Q Q 1 ...q n The connecting line of R { R } 1 ...r m R is a subset of L; the communication line R { R 1 ...r m The set of midpoints is M { r } M1 ...r Mm };
The hairs are attached to the periphery of the head of a person and distributed, the positive direction of the head of the person is set as a starting point S, the threshold value of the angle is set as D, the point closest to the starting point S is searched anticlockwise, and a set H is added 1 (ii) a Searching counterclockwise with the set H 1 Nearest point, join set H 1 Until there is no point with an angle greater than said D; the D is used for dividing the hair into blocks by taking the positive direction of the head as a starting point according to the angle;
judgment postThe above-mentioned set H 1 Whether or not it is equal to the set of points Q Q 1 ...q n If yes, go to step S22; if not, counterclockwise searching is carried out on the set H 1 Nearest point, join set H 2 Counter-clockwise search with said set H 2 Nearest point, join set H 3 Up to H 1 +H 2 +...+H K = Q, and proceeds to step S22; wherein K is a positive integer;
the hair is composed of a plurality of hair points, including a point set P { P } 1 ...p n } and a set of points Q Q 1 ...q n Hair points form lines, the lines form triangles, and the triangles form grids, namely hair styling; a portion of the hair points are moving and a portion of the hair points are stationary; one end of the communication line is a moving hair point and the other end is a fixed hair point.
Step S22, setting the length and density of the mapped skeleton according to the set H 1 +H 2 +...+H K Dividing moving hair points into Q 1 ...Q K (ii) a Based on the set M { r M1 ...r Mm Get the moving hair point and the point set P { P } 1 ...p n Points connected with each other are set as starting points; finding a point farthest from the starting point, and setting the point as an end point;
determining a mapping bone of the hair based on the y-axis coordinate of the starting point, and evenly dividing the starting point based on the length and the density of the mapping bone to obtain a bone line;
the hair movement process is influenced most by gravity and pulling force, the trend of the mapping skeleton is not dependent on the trend of the hair point, because in the physical simulation, the hair is acted by gravity and should be straightened theoretically, but in reality, the hair is rolled up in various bends, so the rolling up is considered as the hairstyle state of the hair, and the hair must be maintained, so the y-axis value of the starting point is directly taken to determine the mapping skeleton of the hair.
Step S23, calculating the mapping relation between the moving hair point and the mapping skeleton by using a point and quadrilateral centroid coordinate formula:
u=(a*x+b*y+c)/(g*x+h*y+1);
v=(d*x+e*y+f)/(g*x+h*y+1);
wherein (u, v) represents a point falling inside a quadrilateral composed of four mapped bones, u being an abscissa and v being an ordinate; (x, y) represents a point on a quadrilateral comprised of four mapped bones, x being the abscissa and y being the ordinate; a. b, c, d, e, f, g and h represent parameters to be solved, and four groups (u, v) and (x, y) are used for solving;
the hair points on the hair can fall between the four mapping bones certainly, so that the relationship between one hair point and the four mapping bones is established; one mapping skeleton has mechanical relation with the adjacent mapping skeleton, tension and bending force with the mapping skeleton with interval to avoid hair folding, and the adjacent mapping skeleton and the interval mapping skeleton are added to form 15 mapping skeletons;
each point in the skeleton line is related to 15 mapping skeletons at most, one hair point is related to four mapping skeletons at most, and the hair point moves depending on the four mapping skeletons; the mapping bones of the hair are divided into a plurality of sets according to the distance, the mapping bones among the sets keep the constraint relation with the mapping bones in the same set, different sets have no mechanical relation, and the mapping bones are collided with each other to avoid interpenetration.
Step S24, the hair is pulled and simulated in a pendulum mode, the hair is flexible but has no stretchability, and the hair is pulled by the hair point above, under the action of gravity and constrained by the hair points beside at the same time. The hair will return to its original state under the action of the pulling and gravity of the upper hair point. The constraint of the side hair points is used to avoid the hair from being interspersed with the surrounding hair points during the restoration of styling. The calculation process mainly comprises two mechanical calculations, wherein the first is the state when the hair is pulled suddenly, and the other is the motion simulation process of restoring the initial state of the hair under the non-initial state:
recording a point mapping skeleton from a closest position to a farthest position from a hair point of the fixed region as P '(P' 0 ...P' n ) And are spaced apart from each other by L '(L' 1 ...L' n-1 ) (ii) a n represents the serial number of the point and is a positive integer; the hair is suddenly pulledThe state at the time of motion is point P' 0 Is momentarily pulled, P' 1 ...P' n Followed by P 'under inertia and tension' 0 Movement, which produces a hair pulling effect;
is No. P' n When rotating around a point, such as a rotor, let the new position be P _ new (P _ nx, P _ ny, P _ nz), the original position be P _ old (P _ ox, P _ oy, P _ oz), the rotation angle be ir, the number of segments of hair be imnu, the flexibility parameter be k, then point P' n The positions of (A) are:
p_nx=p_ox*cos((1+k*n)*ir*n/inum)-p_oz*sin((1+k*n)*ir*n/inum);
p_nz=p_oz*cos((1+k*n)*ir*n/inum)-p_ox*sin((1+k*n)*ir*n/inum);
point P' n Bound by a pendulum to point P' n-1 Is retracted until the length equals L' n-1
When the head rotates, the hair point at the hair root rotates along with the rotation, the rotation angle is smaller when the hair point goes downwards, and the imnu and the k are used for controlling the rotation angle which decreases progressively;
is No. P' n Stretching in one direction, e.g. a person running forward, and stretching over a distance of (i) x ,i y ,i z ) Then point P' n The positions of (A) are:
p_nx=p_ox+i x *(1+k*n)*n/inum;
p_ny=p_oy+i y *(1+k*n)*n/inum;
p_nz=p_oz+i z *(1+k*n)*n/inum;
point P' n Constrained by pendulum, to point P' n-1 Until the length equals L' n-1
According to point P' n P _ ny, namely a point P ', is calculated according to the constraint length of the pendulum' n To point P' n-1 Is retracted.
In step S30, the motion parameters specifically include:
position p of hair point in current frame " n Speed V of hair point in current frame n The maximum movement speed of the hair point in the x-axis, returnx, and the maximum movement speed of the hair point in the z-axis, returnz; y axisConstrained by the pendulum, so the maximum speed of motion is not defined here;
p” n =p” n-1 +V n t;
V n t=V n-1 +at;
a=(F gravity force +F Tension force +F Other external forces )/m;
Where t represents the time of movement of the hair point, a represents the acceleration, m represents the mass of the hair, F Other external forces Finger pull or wind force. F Tension force Mainly comes from the fifteen peripheral mapped bones, the adjacent mapped bones restrict stretching transition, and the spaced mapped bones restrict bending folding.
The invention relates to a preferred embodiment of a hair simulation system, which comprises the following modules:
the device comprises a hair styling initialization module, a movement module and a control module, wherein the hair styling initialization module is used for setting an initial state of hair styling and dividing the hair styling into a fixed area (attached to a scalp part) and a movement area;
a mapping skeleton generation module for generating a mapping skeleton of the hair based on the hair trends of the fixed area and the motion area; the skeleton mapping is a general method in the field of model animation, and is generally used for human motion; the number of mapped bones of the hair can be determined through parameters, and tens of thousands of hair points can be mapped into 100 mapped bones in order to improve the calculation efficiency;
and the hair simulation module is used for setting the motion parameters of the hair and simulating the motion of the hair in the motion area by using the motion parameters and the mapping bone.
The application is also applicable to the movement of any flexible model.
In the hair styling initialization module, the initial state is a default regression state of the hair styling only under the action of gravity.
In the hair styling initialization module, the fixed area and the moving area both comprise a plurality of hairs; the hair of the fixed area pulls the hair of the moving area.
The mapping bone generation module specifically comprises:
a recent hair point searching unit for setting a hair point set P { P) of the fixed region 1 ...p n -hair of said motion area is composed of a set of points Q 1 ...q n The connection relation between the fixed area and the moving area is L { L } 1 ,l 2 ...l n }; the set of points P { P 1 ...p n And a set of points Q Q 1 ...q n The connecting line of R { R } 1 ...r m R is a subset of L; the communication line R { R 1 ...r m The set of midpoints is M { r } M1 ...r Mm };
The hairs are attached to the periphery of the head of a person and distributed, the positive direction of the head of the person is set as a starting point S, the threshold value of the angle is set as D, the point closest to the starting point S is searched anticlockwise, and a set H is added 1 (ii) a Counter-clockwise lookup with the set H 1 Nearest point, join set H 1 Until there is no point with an angle greater than said D; the D is used for dividing the hair into blocks by taking the positive direction of the head as a starting point according to the angle;
judging the set H 1 Whether or not it is equal to the set of points Q Q 1 …q n If yes, entering a skeleton generation unit; if not, counterclockwise searching is carried out on the set H 1 Nearest point, join set H 2 Counter-clockwise search with said set H 2 Nearest point, join set H 3 Up to H 1 +H 2 +...+H K = Q, and enter a bone generation unit; wherein K is a positive integer;
the hair is composed of a plurality of hair points, including a point set P { P } 1 ...p n And a set of points Q Q 1 ...q n Hair points form lines, the lines form triangles, and the triangles form grids, namely hair styling; a portion of the hair points are moving and a portion of the hair points are stationary; one end of the communication line is a moving hair point and the other end is a fixed hair point.
A bone generation unit for determining the length and density of the mapped bone from the set H 1 +H 2 +...+H K Dividing moving hair points into Q 1 ...Q K (ii) a Based on the set M { r M1 ...r Mm Get the moving hair point and the point set P { P } 1 ...p n Points connected with each other are set as starting points; finding a point farthest from the starting point, and setting the point as an end point;
determining a mapping bone of the hair based on the y-axis coordinate of the starting point, and evenly dividing the starting point based on the length and the density of the mapping bone to obtain a bone line;
the hair movement process is influenced most by gravity and pulling force, the trend of the mapping skeleton is not dependent on the trend of the hair point, because in the physical simulation, the hair is acted by gravity and should be straightened theoretically, but in reality, the hair is rolled up in various bends, so the rolling up is considered as the hairstyle state of the hair, and the hair must be maintained, so the y-axis value of the starting point is directly taken to determine the mapping skeleton of the hair.
The mapping relation calculation unit is used for calculating the mapping relation between the moving hair point and the mapping skeleton by using the point and the quadrilateral centroid coordinate formula:
u=(a*x+b*y+c)/(g*x+h*y+1);
v=(d*x+e*y+f)/(g*x+h*y+1);
wherein (u, v) represents a point falling inside a quadrilateral composed of four mapped bones, u being an abscissa and v being an ordinate; (x, y) represents a point on a quadrilateral comprised of four mapped bones, x being the abscissa and y being the ordinate; a. b, c, d, e, f, g and h represent parameters to be solved, and four groups (u, v) and (x, y) are used for solving;
the hair points on the hair can fall between the four mapping bones certainly, so that the relationship between one hair point and the four mapping bones is established; one mapping skeleton has mechanical relation with the adjacent mapping skeleton, tension and bending force with the mapping skeleton with interval to avoid hair folding, and the adjacent mapping skeleton and the interval mapping skeleton are added to form 15 mapping skeletons;
each point in the skeleton line is related to 15 mapping skeletons at most, one hair point is related to four mapping skeletons at most, and the hair point moves depending on the four mapping skeletons; the mapping bones of the hair are divided into a plurality of sets according to the distance, the mapping bones among the sets keep the constraint relation with the mapping bones in the same set, different sets have no mechanical relation, and the mapping bones are collided with each other to avoid interpenetration.
The hair is pulled in a pendulum mode, the hair is flexible but has no stretchability, and the hair is pulled by an upper hair point, under the action of gravity and restrained by a side hair point at the same time. The hair will return to its original state under the action of the pulling and gravity of the upper hair point. The constraint of the side hair points is used to avoid the hair from being interspersed with the surrounding hair points during the restoration of styling. The calculation process mainly comprises two mechanical calculations, wherein the first is the state when the hair is pulled suddenly, and the second is the motion simulation process for restoring the hair to the initial state under the non-initial state.
A hair point position calculating unit for recording a point mapping a bone from a nearest position to a farthest position from the hair point of the fixed region as P '(P' 0 ...P' n ) And are spaced apart from each other by L '(L' 1 ...L' n-1 ) (ii) a n represents the serial number of the point and is a positive integer; the state when the hair is suddenly pulled is point P' 0 Is instantaneously pulled to P' 1 …P' n Followed by P 'under inertia and tension' 0 The hair is moved to generate the hair pulling effect;
is No. P' n When rotating around a point, like a rotor, a new position is set as P _ new (P _ nx, P _ ny, P _ nz), a home position is set as P _ old (P _ ox, P _ oy, P _ oz), a rotation angle is ir, the number of segments of hair is imnu, and a flexibility parameter is k, then a point P' n The positions of (A) are:
p_nx=p_ox*cos((1+k*n)*ir*n/inum)-p_oz*sin((1+k*n)*ir*n/inum);
p_nz=p_oz*cos((1+k*n)*ir*n/inum)-p_ox*sin((1+k*n)*ir*n/inum);
point P' n Constrained by pendulum, to point P' n-1 Is retracted until the length equals L' n-1
When the head rotates, the hair point at the hair root rotates along with the rotation, the rotation angle is smaller when the hair point goes downwards, and the imnu and the k are used for controlling the rotation angle which decreases progressively;
is No. P' n Stretching in one direction, e.g. a person running forward, and stretching over a distance of (i) x ,i y ,i z ) Then point P' n The positions of (A) are:
p_nx=p_ox+i x *(1+k*n)*n/inum;
p_ny=p_oy+i y *(1+k*n)*n/inum;
p_nz=p_oz+i z *(1+k*n)*n/inum;
point P' n Constrained by pendulum, to point P' n-1 Until the length equals L' n-1
According to point P' n P _ ny, namely a point P ', is calculated according to the constraint length of the pendulum' n To point P' n-1 Is retracted.
In the hair simulation module, the motion parameters specifically include:
position p of hair point in current frame " n Speed V of hair point in current frame n The maximum movement speed of the hair point in the x-axis, returnx, and the maximum movement speed of the hair point in the z-axis, returnz; the y-axis is constrained by the pendulum, so the maximum speed of motion is not defined here;
p” n =p” n-1 +V n t;
V n t=V n-1 +at;
a=(F gravity force +F Tension force +F Other external forces )/m;
Where t represents the time of movement of the hair point, a represents the acceleration, m represents the mass of the hair, F Other external forces Finger pull or wind force. F Tension force Mainly comes from the fifteen peripheral mapped bones, the adjacent mapped bones restrict stretching transition, and the spaced mapped bones restrict bending folding.
In summary, the invention has the advantages that:
the hair styling device is characterized in that the hair styling device is divided into a fixed area and a moving area, a mapping skeleton of the hair is generated based on the hair trend of the fixed area and the moving area, after the moving parameter of the hair is set, the moving parameter and the mapping skeleton are used for simulating the movement of the hair, the complexity of the hair can be guaranteed, the hair can be simulated in real time according to the mechanical condition of a physical environment and the movement condition of a human body, the hair styling device is suitable for the conditions that the hair swings along with the human body and the hair flutters, and the initial state is finally recovered under the condition of no force, namely, the real-time simulation of the movement of a complex hairstyle is realized.
Although specific embodiments of the invention have been described above, it will be understood by those skilled in the art that the specific embodiments described are illustrative only and are not limiting upon the scope of the invention, and that equivalent modifications and variations can be made by those skilled in the art without departing from the spirit of the invention, which is to be limited only by the appended claims.

Claims (8)

1. A method of hair simulation, comprising: the method comprises the following steps:
s10, setting an initial state of hair styling, and dividing the hair styling into a fixed area and a moving area;
step S20, generating a mapping skeleton of the hair based on the hair trends of the fixed area and the moving area;
s30, setting motion parameters of the hair, and simulating the motion of the hair by using the motion parameters and the mapping bones;
the step S20 specifically includes:
step S21, setting a hair by point set P { P) of the fixed area 1 ...p n -hair of said motion area is composed of a set of points Q 1 ...q n The connection relation between the fixed area and the moving area is L { L } 1 ,l 2 ...l n }; the set of points P { P 1 ...p n And a set of points Q Q 1 ...q n The connecting line of R { R } 1 ...r m R is a subset of L; the communication line R { R 1 ...r m The set of midpoints is M { r } M1 ...r Mm };
Head for peopleThe positive direction of (2) is a starting point S, the threshold value of the angle is D, the point closest to the starting point S is searched anticlockwise, and a set H is added 1 (ii) a Counter-clockwise lookup with the set H 1 Nearest point, join set H 1 Until there is no point with an angle greater than said D;
judging the set H 1 Whether or not it is equal to the set of points Q Q 1 ...q n If yes, go to step S22; if not, counterclockwise searching is carried out on the set H 1 Nearest point, join set H 2 Counter-clockwise search with said set H 2 Nearest point, join set H 3 Up to H 1 +H 2 +...+H K = Q, and proceeds to step S22; wherein K is a positive integer;
step S22, setting the length and density of the mapping skeleton according to the set H 1 +H 2 +...+H K Dividing moving hair points into Q 1 ...Q K (ii) a Based on the set M { r M1 ...r Mm Get the moving hair point and the point set P { P } 1 ...p n Points connected with each other are set as starting points; finding a point farthest from the starting point, and setting the point as an end point;
determining a mapping bone of the hair based on the y-axis coordinate of the starting point, and evenly dividing the starting point based on the length and the density of the mapping bone to obtain a bone line;
s23, calculating the mapping relation between the moving hair point and the mapping skeleton by using a point and quadrilateral centroid coordinate formula:
u=(a*x+b*y+c)/(g*x+h*y+1);
v=(d*x+e*y+f)/(g*x+h*y+1);
wherein (u, v) represents a point falling inside a quadrilateral composed of four mapped bones, u being an abscissa and v being an ordinate; (x, y) represents a point on a quadrilateral comprised of four mapped bones, x being the abscissa and y being the ordinate; a. b, c, d, e, f, g and h represent parameters to be solved, and four groups (u, v) and (x, y) are used for solving;
step S24, recording a point P ' (P ') mapping bones from the nearest position to the farthest position of the hair points of the fixed area ' 0 ...P' n ) And are spaced apart from each other by L '(L' 1 ...L' n-1 ); n The serial number of the representing point is a positive integer;
when point P n When rotating around a point, the new position is P _ new (P _ nx, P _ ny, P _ nz), the original position is P _ old (P _ ox, P _ oy, P _ oz), the rotation angle is ir, the number of hair segments is imnu, and the flexibility parameter is k, then the point P is n The positions of' are:
p_nx=p_ox*cos((1+k*n)*ir*n/inum)-p_oz*sin((1+k*n)*ir*n/inum);
p_nz=p_oz*cos((1+k*n)*ir*n/inum)-p_ox*sin((1+k*n)*ir*n/inum);
is No. P' n Stretching in one direction and the stretching distance is (i) x ,i y ,i z ) Then point P' n The positions of (A) are:
p_nx=p_ox+i x *(1+k*n)*n/inum;
p_ny=p_oy+i y *(1+k*n)*n/inum;
p_nz=p_oz+i z *(1+k*n)*n/inum;
point P' n Constrained by pendulum, to point P' n-1 Is retracted until the length equals L' n-1
2. A hair simulation method according to claim 1, wherein: in step S10, the initial state is a default regression state of the hair style only under the action of gravity.
3. A hair simulation method according to claim 1, wherein: in the step S10, the fixed area and the moving area both include a plurality of hairs; the hair of the fixed area pulls the hair of the moving area.
4. A hair simulation method according to claim 1, wherein: in step S30, the motion parameters specifically include:
position p of hair point in current frame " n Speed V of hair point in current frame n The hair is dotted onThe maximum movement speed of the x-axis, returnx, and the maximum movement speed of the hair point in the z-axis, returnz;
p” n =p” n-1 +V n t;
V n t=V n-1 +at;
a=(F gravity force +F Tension force +F Other external forces )/m;
Where t represents the time of movement of the hair point, a represents the acceleration, m represents the mass of the hair, F Other external forces Finger pull or wind force.
5. A hair simulation system, characterized by: the system comprises the following modules:
the hair styling initialization module is used for setting an initial state of hair styling and dividing the hair styling into a fixed area and a moving area;
a mapping skeleton generation module for generating a mapping skeleton of the hair based on the hair trends of the fixed area and the motion area;
the hair simulation module is used for setting the motion parameters of the hair and simulating the motion of the hair by using the motion parameters and the mapping bones;
the mapping skeleton generation module specifically comprises:
a recent hair point searching unit for setting a hair point set P { P) of the fixed region 1 ...p n -hair of said motion region is composed of a set of points Q 1 ...q n The connection relation between the fixed area and the moving area is L { L } 1 ,l 2 ...l n }; the set of points P { P 1 ...p n And a set of points Q Q 1 ...q n The line of communication is R { R } 1 ...r m R is a subset of L; the communication line R { R 1 ...r m The set of midpoints is M { r } M1 ...r Mm };
Setting the positive direction of the head as a starting point S and the threshold value of the angle as D, searching the point closest to the starting point S in the counterclockwise direction, and adding a set H 1 (ii) a Counter-clockwise lookup with the set H 1 More recently, the development of new and more recently developed devicesPoint of (3), add set H 1 Until there is no point with an angle greater than said D;
judging the set H 1 Whether or not it is equal to the set of points Q Q 1 ...q n If yes, entering a skeleton generation unit; if not, counterclockwise searching is carried out on the set H 1 Nearest point, join set H 2 Counter-clockwise search with said set H 2 Nearest point, join set H 3 Up to H 1 +H 2 +...+H K = Q, and enter a bone generation unit; wherein K is a positive integer;
a bone generation unit for determining the length and density of the mapped bone from the set H 1 +H 2 +...+H K Dividing moving hair points into Q 1 ...Q K (ii) a Based on the set M { r } M1 ...r Mm Get the moving hair point and the point set P { P } 1 ...p n Points connected with each other are set as starting points; finding a point farthest from the starting point, and setting the point as an end point;
determining a mapping bone of the hair based on the y-axis coordinate of the starting point, and evenly dividing the starting point based on the length and the density of the mapping bone to obtain a bone line;
the mapping relation calculation unit is used for calculating the mapping relation between the moving hair point and the mapping skeleton by using the point and the quadrilateral centroid coordinate formula:
u=(a*x+b*y+c)/(g*x+h*y+1);
v=(d*x+e*y+f)/(g*x+h*y+1);
wherein (u, v) represents a point falling inside a quadrilateral composed of four mapped bones, u being an abscissa and v being an ordinate; (x, y) represents a point on a quadrilateral comprised of four mapped bones, x being the abscissa and y being the ordinate; a. b, c, d, e, f, g and h represent parameters to be solved, and four groups (u, v) and (x, y) are used for solving;
a hair point position calculating unit for recording a point mapping a bone from a closest position to a farthest position from the hair point of the fixed area as P '(P' 0 ...P' n ) And are spaced apart from each other by L '(L' 1 ...L' n-1 ) (ii) a n represents the number of dots and is positiveAn integer number;
when point P' n When rotating around a point, a new position is P _ new (P _ nx, P _ ny, P _ nz), a home position is P _ old (P _ ox, P _ oy, P _ oz), a rotation angle is ir, the number of segments of hair is imnu, and a flexibility parameter is k, then a point P' n The positions of (A) are:
p_nx=p_ox*cos((1+k*n)*ir*n/inum)-p_oz*sin((1+k*n)*ir*n/inum);
p_nz=p_oz*cos((1+k*n)*ir*n/inum)-p_ox*sin((1+k*n)*ir*n/inum);
is No. P' n Stretching in one direction and the stretching distance is (i) x ,i y ,i z ) Then point P' n The positions of (A) are:
p_nx=p_ox+i x *(1+k*n)*n/inum;
p_ny=p_oy+i y *(1+k*n)*n/inum;
p_nz=p_oz+i z *(1+k*n)*n/inum;
point P' n Constrained by pendulum, to point P' n-1 Is retracted until the length equals L' n-1
6. A hair simulation system according to claim 5, wherein: in the hair styling initialization module, the initial state is a default regression state of the hair styling only under the action of gravity.
7. A hair simulation system according to claim 5, wherein: in the hair styling initialization module, the fixed area and the moving area both comprise a plurality of hairs; the hair of the fixed area pulls the hair of the moving area.
8. A hair simulation system according to claim 5, wherein: in the hair simulation module, the motion parameters specifically include:
position p of hair point in current frame " n Speed V of hair point in current frame n Maximum movement speed of the hair point in the x-axis, return, and maximum movement speed of the hair point in the z-axisThe movement speed returnz;
p” n =p” n-1 +V n t;
V n t=V n-1 +at;
a=(F gravity force +F Tension force +F Other external forces )/m;
Where t represents the time of movement of the hair point, a represents the acceleration, m represents the mass of the hair, F Other external forces Finger pull or wind force.
CN202010442123.6A 2020-05-22 2020-05-22 Hair simulation method and system Active CN111583367B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010442123.6A CN111583367B (en) 2020-05-22 2020-05-22 Hair simulation method and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010442123.6A CN111583367B (en) 2020-05-22 2020-05-22 Hair simulation method and system

Publications (2)

Publication Number Publication Date
CN111583367A CN111583367A (en) 2020-08-25
CN111583367B true CN111583367B (en) 2023-02-10

Family

ID=72112694

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010442123.6A Active CN111583367B (en) 2020-05-22 2020-05-22 Hair simulation method and system

Country Status (1)

Country Link
CN (1) CN111583367B (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112508993B (en) * 2020-11-18 2023-11-07 奇幻熊(厦门)信息技术有限公司 Clothes movement simulation method, terminal equipment and storage medium
CN114219877A (en) * 2021-12-06 2022-03-22 北京字节跳动网络技术有限公司 Portrait hair flowing special effect processing method, device, medium and electronic equipment
CN115311403B (en) * 2022-08-26 2023-08-08 北京百度网讯科技有限公司 Training method of deep learning network, virtual image generation method and device
CN116152405B (en) * 2023-04-23 2023-07-07 腾讯科技(深圳)有限公司 Service processing method and device, computer equipment and storage medium
CN116570920A (en) * 2023-07-12 2023-08-11 腾讯科技(深圳)有限公司 Data management method, device, computer and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2004206329A (en) * 2002-12-25 2004-07-22 Toshiba Corp Simulation device, method and program
CN102419868A (en) * 2010-09-28 2012-04-18 三星电子株式会社 Device and method for modeling 3D (three-dimensional) hair based on 3D hair template
CN103778661A (en) * 2013-12-24 2014-05-07 中国科学院深圳先进技术研究院 Method for generating three-dimensional motion model of speaker, system and computer thereof
CN105976418A (en) * 2016-06-28 2016-09-28 珠海金山网络游戏科技有限公司 Design system and method for human dynamic bone
CN106023288A (en) * 2016-05-18 2016-10-12 浙江大学 Image-based dynamic substitute construction method
CN109147052A (en) * 2018-08-22 2019-01-04 福州智永信息科技有限公司 A kind of hair simulation production method and system based on Unity3D engine

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2004206329A (en) * 2002-12-25 2004-07-22 Toshiba Corp Simulation device, method and program
CN102419868A (en) * 2010-09-28 2012-04-18 三星电子株式会社 Device and method for modeling 3D (three-dimensional) hair based on 3D hair template
CN103778661A (en) * 2013-12-24 2014-05-07 中国科学院深圳先进技术研究院 Method for generating three-dimensional motion model of speaker, system and computer thereof
CN106023288A (en) * 2016-05-18 2016-10-12 浙江大学 Image-based dynamic substitute construction method
CN105976418A (en) * 2016-06-28 2016-09-28 珠海金山网络游戏科技有限公司 Design system and method for human dynamic bone
CN109147052A (en) * 2018-08-22 2019-01-04 福州智永信息科技有限公司 A kind of hair simulation production method and system based on Unity3D engine

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
《基于动态超螺旋线的三维头发建模》;孙武峰等;《计算机应用研究》;20100330;第27卷(第1期);396-398页 *

Also Published As

Publication number Publication date
CN111583367A (en) 2020-08-25

Similar Documents

Publication Publication Date Title
CN111583367B (en) Hair simulation method and system
Park et al. On‐line motion blending for real‐time locomotion generation
Yamane et al. Animating non-humanoid characters with human motion data
CN102289836B (en) Method for synthesizing plant animation
TW200809695A (en) Goal-directed cloth simulation
CN104867171A (en) Transition animation generating method for three-dimensional roles
CN115641375B (en) Method, device, equipment and storage medium for processing hair of virtual object
JP4936522B2 (en) Image processing method and image processing apparatus
CN111508080B (en) Method for realizing adhesive tape winding simulation based on UE4 engine and related equipment
CN115115752A (en) Virtual garment deformation prediction method and device, storage medium and electronic equipment
JP3780512B2 (en) PROGRAM, RECORDING MEDIUM, AND GAME DEVICE
CN107146273B (en) Adaptive floating tangent matching method for image-based hair modeling
CN111047675A (en) Method and device for simulating hair
JP2009020874A (en) Hair simulation method, and device therefor
CN112562050A (en) Virtual object wind animation generation method and device, storage medium and terminal
CN104463934A (en) Automatic generation method for point set model animation driven by mass point-spring system
Yu et al. Research of simulation in character animation based on physics engine
CN114882153A (en) Animation generation method and device
Choi et al. Image morphing using mass-spring system
JP2007048151A (en) Method for mapping object mesh model onto three-dimensional curved surface
CN116258801B (en) Hair processing method and device for digital virtual object and storage medium
JP4462704B2 (en) GAME DEVICE AND INFORMATION STORAGE MEDIUM
CN117475045A (en) Method and device for generating software flutter effect and electronic equipment
CN108198234B (en) Virtual character generating system and method capable of realizing real-time interaction
Oliveira et al. Synthesis of variable dancing styles based on a compact spatiotemporal representation of dance

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant