Data migration method and device, electronic device, and readable storage medium
Through the data migration method, the data of the first model is migrated to the second model with the same topological relationship, and the position coordinates of the nodes are weighted by the influence factor, the problem of insufficient action accuracy of the 3D model is solved, achieving higher action accuracy and universality.
Patent Information
- Application Number
- CN202111062893.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-10
- Publication Date
- 2025-04-04
- Estimated Expiration
- 2041-09-10
AI Technical Summary
The prior art lacks universality in improving the accuracy of the 3D model display movements, resulting in some 3D models still having the problem of "model penetration" when displaying the movements.
Through a data migration method, the data of the first model is migrated to a second model with the same topological relationship. The specific steps include obtaining the position coordinates of the reference point, determining the distance between the reference point and the node, calculating the influencing factor of the reference point according to the preset rules, and using these factors to weight the position coordinates of the node to achieve migration.
This method improves the accuracy of the 3D model movements, makes the actions of the virtual object closer to the actions of the entity, and has high versatility and is suitable for more models.
Smart Images

Figure CN113744375B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of electronic information, and in particular to a data migration method and device, an electronic device, and a readable storage medium. Background Art
[0002] The production of 3D virtual objects (usually including people and animals) is widely used in scenes such as animation production and movie special effects. Taking 3D virtual characters as an example of 3D virtual objects, the general process of producing 3D virtual characters is: using motion capture technology to capture various actions of entities such as actors, generate data indicating these actions, and then assign the data to a specified 3D model.
[0003] Currently, there are many ways to improve the accuracy of the movements displayed by 3D models, but the versatility of these methods needs to be improved. In other words, these methods can improve the accuracy of the movements displayed by some 3D models, but for other 3D models, even if these methods are used, the accuracy of the movements displayed by the 3D models still needs to be improved. For example, when the 3D model displays movements, there will still be a "penetration" problem. "Punching" means that the 3D model makes some movements that do not conform to the principles of physics, such as limbs extending into the body, such as Figure 1 As shown in the circled area, the right arm of the two-dimensional virtual idol has penetrated into the body.
[0004] It can be seen that how to propose a more universal method to improve the motion accuracy of 3D models is a problem that needs to be solved at present. Summary of the invention
[0005] The present application provides a data migration method and device, an electronic device, and a readable storage medium, the purpose of which is to propose a method for improving the motion accuracy of a 3D model with high versatility.
[0006] In order to achieve the above objectives, this application provides the following technical solutions:
[0007] A data migration method for migrating data of a first model to a second model with the same topological relationship, comprising:
[0008] According to the rotation data of the nodes in the first model, obtaining the position coordinates of the reference point of the first model, where the reference point of the first model is a point in the grid of the first model;
[0009] Determine a distance between a first reference point and a first node in the first model according to a position coordinate of the first reference point and a position coordinate of the first node, wherein the first reference point is any reference point of the first model and the first node is any node;
[0010] Determine an influence factor of the first reference point according to a preset rule, wherein the preset rule includes that the distance is inversely correlated with the influence factor, and the influence factor indicates the influence degree of a target grid on the first node, and the target grid is the grid where the first reference point is located;
[0011] Taking the influence factor of the reference point of the first model as the weight, the migration position coordinates obtained after migrating the position coordinates of the nodes of the first model to the corresponding nodes in the second model are determined according to the weighted sum of the pointing displacement coordinates of the reference point of the first model, and the pointing displacement coordinates are determined according to the reference point of the first model and the position coordinates of the nodes.
[0012] Optionally, determining the influence factor of the first reference point according to a preset rule includes:
[0013] If the distance is greater than a preset minimum value, determining the impact factor according to the reciprocal of the distance;
[0014] If the distance is not greater than the minimum value, the influence factor is determined according to the inverse of the minimum value.
[0015] Optionally, determining the impact factor according to the inverse of the distance includes:
[0016] Determining the impact factor according to the product of the area of the target grid and the reciprocal of the distance;
[0017] Determining the impact factor according to the reciprocal of the minimum value includes:
[0018] The influence factor is determined according to the product of the area of the target grid and the reciprocal of the minimum value.
[0019] Optionally, determining the impact factor according to the product of the area of the target grid and the reciprocal of the distance includes:
[0020] The product of the nth power of the area and the reciprocal of the distance is used as the influence factor;
[0021] Determining the influencing factor according to the product of the area of the target grid and the reciprocal of the minimum value includes:
[0022] The product of the nth power of the area and the reciprocal of the minimum value is taken as the influence factor, where n is an integer greater than or equal to 1.
[0023] Optionally, the using the influence factor of the reference point in the first model as the weight and determining the migration position coordinates obtained after migrating the position coordinates of the node in the first model to the corresponding node in the second model according to the weighted sum of the pointing displacement coordinates of the reference point in the first model includes:
[0024] Determine, based on the influence factors of each reference point of the first model and the weighted sum of the pointing displacement coordinates of each reference point, the migration position coordinates obtained after migrating the position coordinates of the first node to the corresponding first node, the pointing displacement coordinates of the first reference point being the coordinates obtained after moving the first reference point along the direction of the pointing vector of the first reference point by the length of the pointing vector;
[0025] Among them, the pointing vector of the first reference point is obtained by normalizing the first vector using a preset first parameter and then denormalizing it to the second model using a preset second parameter. The first vector is the vector pointing from the first reference point to the first node in the first model.
[0026] Optionally, the method for obtaining the first vector includes:
[0027] Determine the initial displacement coordinates of the first reference point according to the position coordinates of the first node, where the initial displacement coordinates of the first reference point are coordinates obtained by moving the first reference point along the direction of the first vector by the length of the first vector;
[0028] The first vector is obtained according to the initial displacement coordinates of the first reference point and the position coordinates of the first reference point.
[0029] A motion data migration device, characterized by comprising:
[0030] A first acquisition module, configured to acquire position coordinates of a reference point of the first model according to rotation data of a node in the first model, wherein the reference point of the first model is a point in a grid of the first model;
[0031] a first determining module, configured to determine a distance between a first reference point and a first node in the first model according to a position coordinate of the first reference point and a position coordinate of a first node in the first model, wherein the first reference point is any reference point of the first model, and the first node is any node;
[0032] A second determination module is used to determine the influence factor of the first reference point according to a preset rule, wherein the preset rule includes an inverse correlation between the distance and the influence factor, and the influence factor indicates the influence degree of a target grid on the first node, and the target grid is the grid where the first reference point is located;
[0033] A migration module is used to use the influence factor of the reference point of the first model as a weight, and determine the migration position coordinates obtained after migrating the position coordinates of the nodes of the first model to the corresponding nodes in the second model based on the weighted sum of the pointing displacement coordinates of the reference point of the first model, wherein the pointing displacement coordinates are determined based on the first reference point of the first model and the position coordinates of the nodes.
[0034] Optionally, the second determining module is configured to determine, according to a preset rule, an influencing factor of the first reference point, including:
[0035] The second determination module is specifically used to determine the impact factor according to the reciprocal of the distance if the distance is greater than a preset minimum value; and to determine the impact factor according to the reciprocal of the minimum value if the distance is not greater than the minimum value.
[0036] An electronic device, comprising:
[0037] Processor and memory;
[0038] The memory is used to store programs, and the processor is used to run the programs to implement the above-mentioned motion data migration method.
[0039] A computer-readable storage medium stores a program, and when an electronic device runs the program, the above-mentioned motion data migration method is implemented.
[0040] The method and device described in the present application obtain the position coordinates of the reference point in the first model according to the rotation data of the node in the first model, determine the distance between the first reference point and the first node according to the position coordinates of the first reference point and the position coordinates of the first node in the first model, determine the influence factor of the first reference point indicating the influence degree of the target grid on the first node according to the preset rule of anti-correlation between the distance and the influence factor, use the influence factor of the reference point of the first model as a weight, and determine the migration position coordinates obtained after migrating the position coordinates of the node of the first model to the corresponding node in the second model based on the weighted sum of the pointing displacement coordinates of the reference point of the first model determined according to the first reference point of the first model and the position coordinates of the node, because the position coordinates of the reference point are used to realize data migration, so the action presented by the virtual object driven by the second model according to the migration position coordinates can be close to the action of the entity, that is, it has high accuracy. In addition, because the distance between the reference point and the node is taken into account in the process of data migration, it is applicable to more models, so it has high versatility. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0042] Figure 1 An example diagram of a virtual animated character “wearing a model” as an example of a virtual object;
[0043] Figure 2a Example diagrams of human 3D models represented by different numbers of meshes;
[0044] Figure 2b An example diagram of a 3D human body model corresponding to a part of the joint points of the human body;
[0045] Figure 2c for Figure 2b An example diagram of a mesh obtained by driving the model shown;
[0046] Figure 2d An example diagram of the distance between the reference point and the node;
[0047] Figure 3 A flowchart of a data migration method disclosed in an embodiment of the present application;
[0048] Figure 4 A flowchart of another data migration method disclosed in an embodiment of the present application;
[0049] Figure 5 A schematic diagram of the structure of a data migration device disclosed in an embodiment of the present application. DETAILED DESCRIPTION
[0050] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0051] During the research process, the applicant discovered that because the actions performed by the entity need to be displayed, the driving skeleton nodes (hereinafter referred to as nodes) in the specified 3D model usually have the same topological relationship with the joint points in the entity, that is, the driving skeleton nodes in the specified 3D model correspond one-to-one to all or part of the joint points in the entity.
[0052] However, the ratio of node distances in a specified 3D model is not necessarily the same as the ratio of the lengths of the corresponding joint points in the entity. Therefore, the actions displayed by the specified 3D model may deviate greatly from the actions performed by the entity.
[0053] Therefore, the applicant proposes that:
[0054] In order to improve the accuracy of the virtual object's movements, a 3D model that matches the entity can be constructed first, hereinafter referred to as the first model. The captured data is assigned to the first model to obtain the data of the nodes in the first model (position coordinates and rotation data), and then the data of the nodes in the first model are migrated to the specified 3D model, hereinafter referred to as the second model, and the virtual object is driven by the second model.
[0055] In the following embodiments, a technical solution is proposed for migrating data of nodes in a first model to nodes in a second model, with the aim of shielding the difference in the distance ratio between nodes in the first model and the second model, so that the actions displayed by the second model according to the migrated data are closer to the actions of the entity, that is, the actions of the virtual objects are more accurate.
[0056] However, the applicant also found during the research process that the above data migration method can improve the accuracy of the actions of some second models, while for some second models, the accuracy of the actions is still not high.
[0057] The applicant found that the reasons for the above problems are:
[0058] When a 3D model is represented using a mesh, Figure 2a As shown in the figure, the number of grids used by the model decreases in each column from left to right. For the rightmost column, because the number of grids is small, each grid has a greater impact on the node, so the impact weights can be regarded as the same or a fixed impact weight can be used. However, for the leftmost column, because the number of grids is much larger than that of the rightmost column, the degree of influence of different grids on the nodes varies greatly. In this case, if the degree of influence of the grid on the node is not distinguished or only a fixed weight parameter is simply used, even if the above data migration method is used, the action accuracy of the second model is still not high.
[0059] In summary, the applicant proposes a data migration method as described in the following embodiments. During the data migration process, the influence weight of the grid on the node is further distinguished to achieve a more versatile method that can improve the motion accuracy of the 3D model.
[0060] Here are some definitions and explanations:
[0061] Topological relationships refer to the types of nodes and the connection relationships between nodes. Figure 2bThe present invention is an example of a human 3D model used in an embodiment of the present application, Hips represents the hip node, Spine1 represents the first (closed) node of the spine, Spine2 represents the second (closed) node of the spine, Neck represents the neck (closed) node, Head represents the head (closed) node, LeftShoulder represents the left shoulder (closed) node, RightShoulder represents the right shoulder (closed) node, LeftElbow represents the left elbow (closed) node, RightElbow represents the right elbow (closed) node, LeftWrist represents the left wrist (closed) node, RightWrist represents the right wrist (closed) node, LeftHips represents the left hip (closed) node, RightHips represents the right hip (closed) node, LeftKnee represents the left knee (closed) node, RightKnee represents the right-left knee (closed) node, LeftAnkle represents the left ankle (closed) node, and RightAnkle represents the right ankle (closed) node.
[0062] The type of the node is the type of the joint point in the corresponding entity, for example Figure 2b It is understood that Figure 2b Shown are nodes corresponding to joints of a portion of the human body.
[0063] The first model and the second model are both 3D models, wherein the node data included therein include position coordinates and rotation data. The definition of rotation data can refer to the prior art.
[0064] The ratio of node distances refers to the ratio of the distance S1 between the first node A and the second node B to the distance S2 between the other two nodes C and D, that is, S1 / S2. The distance can be calculated from the position coordinates of the nodes. Figure 2b For example, using the position coordinates of Hips and LeftHips Hips, we get the distance S1 between Hips and LeftHips. Using the position coordinates of Hips and RightHips, we get the distance S2 between Hips and RightHips. Dividing S1 by S2, we get the ratio of the node distances.
[0065] The ratio of the joint lengths in an entity refers to the ratio of the bone lengths between the joints. For example, the bone length between joint 1 and joint 2 is S3, and the bone length between joint 3 and joint 4 is S4. S3 / S4 is a joint length ratio.
[0066] The first model and the entity are adapted to each other by: the nodes in the first model correspond one-to-one with the joint points in the entity, and the ratio of the node distances in the first model is the same as the ratio of the lengths of the corresponding joint points in the entity, for example, Figure 2bThe ratio of the distance between Hips and LeftHips divided by the distance between Hips and RightHips is equal to the ratio of the bone length between Hips and LeftHips in the human body divided by the bone length between Hips and RightHips in the human body.
[0067] The correspondence between the nodes in the model and the joint points in the entity means that if the data assigned to a node in the model is the data collected from the displacement or rotation of a joint point in the entity, then the node corresponds to the joint point.
[0068] The mesh of a model refers to a plane surrounding the 3D model obtained by driving the rotation data of the nodes in the 3D model. If the connected nodes in the 3D model are regarded as a skeleton, the mesh can be regarded as the "flesh" that wraps the skeleton.
[0069] Usually, 3D software such as Unity or Blender is used to drive the 3D model using the rotation data of the 3D model to obtain the mesh. The specific process will not be described here.
[0070] When driving the rotation data of a 3D model to obtain a mesh, the shape of the mesh can be set. The reference point is a point in the mesh, which can be specified before obtaining the mesh. For example, the mesh can be a rectangle, and the reference point can be the upper left vertex of the rectangle.
[0071] When the first model and the second model are constructed, each node is assigned a default position coordinate and selection data, and the motion data collected from the entity has not yet been assigned to the model. The state of the model at this time is called the initial state. Taking the human body model as an example, usually, the initial state of the model is the T-Pose state, that is, the connection lines of the nodes in the model are in a "T" shape.
[0072] Based on the above content, it can be known that the first model and the second model have the same topological relationship, and the nodes in the first model correspond one-to-one with the nodes in the second model, that is, the nodes in the first model have unique corresponding nodes in the second model.
[0073] Figure 2c Based on Figure 2b An example of a mesh of a generated model, where the mesh is represented by a triangle. The reference point is represented by the centroid of the triangle. The mesh includes a head mesh and a torso mesh.
[0074] Figure 2c The head mesh shown in is denoted as:
[0075] Figure 2c The torso mesh shown in
[0076] The reference points of each head mesh are The reference points for each torso mesh are Therefore, the reference point of the first model is ref A =ref A-H +ref A-B .
[0077] Where T represents the triangle in the mesh. 1 A-B Represents triangle T 1 A-B The center of gravity can be regarded as the position coordinates of a reference point.
[0078] Based on the above definition of mesh, it can be seen that the mesh is closer to the entity than the skeleton formed by node connections.
[0079] In the following embodiments, any node to be migrated in the first model is referred to as a first node, and the corresponding node of the first node in the second model is referred to as a corresponding first node. The topological relationship represented by any node (such as the first node) in the first model is the same as the topological relationship represented by the corresponding node (such as the corresponding first node) in the second model, that is, the corresponding node of any node is a node representing the same relationship in the topological relationship.
[0080] For example, Figure 2b As shown, the first node is LeftWrist in the first model, and LeftWrist in the second model is the corresponding first node. The topological relationship of LeftWrist in the first model is connected to LeftElbow, and the topological relationship of LeftWrist in the second model is also connected to LeftElbow.
[0081] The data migration process proposed in the embodiment of the present application will be described in detail below.
[0082] Figure 3 The process of a data migration method disclosed in an embodiment of the present application includes the following steps:
[0083] S31. Acquire the position coordinates of a reference point of the first model according to the rotation data of the nodes in the first model.
[0084] The specific implementation method of S31 is as described above and will not be repeated here.
[0085] S32. Determine the distance between the first reference point and the first node according to the position coordinates of the first reference point and the position coordinates of the first node in the first model.
[0086] The first reference point is any reference point in the first model, and the first node is any node in the first model.
[0087] S33. Determine the influence factor of the first reference point according to a preset rule.
[0088] The preset rule includes that the distance is inversely correlated with the influence factor. The influence factor indicates the influence degree of the target grid on the first node.
[0089] The target mesh is the mesh where the first reference point is located. Therefore, the first reference point can be a point on the target mesh, such as a vertex, or a centroid, as described above.
[0090] The rule of inverse correlation between distance and impact factor means that the greater the distance, the smaller the impact factor, and the smaller the distance, the greater the impact factor.
[0091] According to the rule of anti-correlation between distance and influence factor, a specific implementation method for determining the influence factor of the first reference point can be: preset a correspondence between distance and influence factor, the relationship satisfies the above anti-correlation rule, query the correspondence based on the distance, and thus determine the influence factor.
[0092] In the following embodiment, a more accurate calculation method is also provided.
[0093] S34, using the influence factor of the reference point in the first model as a weight, and determining the migration position coordinates obtained by migrating the position coordinates of the nodes of the first model to the corresponding nodes in the second model according to the weighted sum of the pointing displacement coordinates of the reference points of the first model.
[0094] The pointing displacement coordinates are determined based on the reference point of the first model and the position coordinates of the node, and the specific implementation method will be described in the following embodiments.
[0095] Because the closer a node is to a grid, the greater the influence of the grid on the node, so in this embodiment, the influence factor of the reference point is obtained based on the distance, and then the influence factor is used as a weight to determine the migration position coordinates obtained after migrating the position coordinates of the node in the first model to the corresponding node in the second model. Therefore, the accuracy of the position coordinates after migration can be improved, so that the action presented by the virtual object driven by the second model based on the position coordinates can be close to the action of the entity, that is, it has higher accuracy.
[0096] The following is an example of applying the above embodiment to Figure 2b as well as Figure 2c The process of the human body 3D model is shown in the figure, and the specific implementation of S33 is also explained in detail:
[0097] 1. According to the rotation data of the nodes in the first model, obtain the position coordinates of the reference points in the grid of the first model.
[0098] 2. Determine the distance between the first reference point and the first node based on the position coordinates of the first reference point and the position coordinates of the first node in the first model.
[0099] As mentioned above, the first node is any node in the first model. In this step and the following embodiments, an example of the first node is LeftWrist.
[0100] The first reference node is Figure 2d The centroid R of triangle ABC is shown as an arbitrary mesh.
[0101] The distance between the first reference point and the first node is: the absolute value of the difference between the position coordinates of the first reference point and the position coordinates of the first node LeftWrist (abbreviated as P).
[0102] 3. Based on the rule that distance and impact factor are inversely correlated, determine the impact factor of the first reference point.
[0103] Specifically, if the distance is greater than the minimum value, the impact factor is determined based on the reciprocal of the distance. For example, the reciprocal of the distance is used as the impact factor. If the distance is not greater than the minimum value, the impact factor is determined based on the reciprocal of the minimum value. For example, the reciprocal of the minimum value is used as the impact factor.
[0104] Because the distance may be zero, when the distance is zero, the reciprocal of the distance cannot be calculated. Therefore, the minimum value is used as the threshold to distinguish between two calculation methods to ensure that the impact factor can be obtained.
[0105] Furthermore, the applicant has found that the area of the grid is also related to the degree of influence of the grid on the node. The larger the area of the grid, the greater the influence on the node. Therefore, in this embodiment, the area of the grid is introduced into the calculation of the influence factor, that is, the influence factor is determined based on the product of the area of the target grid and the reciprocal of the distance, and the influence factor is determined based on the product of the area of the target grid and the reciprocal of the minimum value.
[0106] Optionally, the impact factor is determined as follows:
[0107]
[0108] λ is the impact factor, S ABC is the area of the grid, is the distance, eps is the minimum value, the specific value is 0.00001.
[0109] Wherein, n is an integer greater than 0.
[0110] Optionally, in order to further increase the influence of the area on the impact factor, n is greater than 1. Figure 2a The grid order shown is for n = 3 or 4.
[0111] It is understandable that, as mentioned above, because the points constituting the grid are obtained by the 3D software using the rotation data of the 3D model, the coordinates of each point are known, so the area of the grid can be obtained based on the coordinates of each point, which will not be repeated here.
[0112] 4. Using the influence factor of the reference point in the first model as the weight, and according to the weighted sum of the pointing displacement coordinates of the reference point in the first model, determine the migration position coordinates obtained after migrating the position coordinates of the nodes of the first model to the corresponding nodes in the second model.
[0113] The method described in this embodiment obtains the influence factor of the grid on the node based on the distance between the reference point and the node and the area of the grid to which the reference point belongs. Therefore, the influence factor can accurately reflect the difference in the degree of influence of different grids on different nodes, thereby further improving the accuracy of the post-migration position coordinates obtained by data migration.
[0114] The data migration process will be described in more detail below in conjunction with the influencing factors determined in the above embodiment.
[0115] Figure 4 The process of a data migration method disclosed in an embodiment of the present application includes the following steps:
[0116] S41, collecting data of nodes of the first model.
[0117] The data of the nodes of the first model include position data and rotation data of the nodes in the first model.
[0118] As mentioned above, the motion capture technology can be used to collect data of each joint point of the entity during the movement, and the collected data can be assigned to the nodes in the first model. The data of any node in the first model includes the position coordinates and rotation data of the node.
[0119] It can be understood that if the motion data is collected continuously, multiple frames of motion data can be formed. In this embodiment, any frame of motion data of the first model is recorded as:
[0120] Rotate data:
[0121]
[0122] Among them, src represents the first model, Hips represents the hip (off) node, Spine1 represents the first (off) node of the spine, Spine2 represents the second (off) node of the spine, Neck represents the neck (off) node, Head represents the head (off) node, LeftShoulder represents the left shoulder (off) node, RightShoulder represents the right shoulder (off) node, LeftElbow represents the left elbow (off) node, RightElbow represents the right elbow (off) node, LeftWrist represents the left wrist (off) node, RightWrist represents the right wrist (off) node, LeftHips represents the left hip (off) node, RightHips represents the right hip (off) node, LeftKnee represents the left knee (off) node, RightKnee represents the right left knee (off) node, LeftAnkle represents the left ankle (off) node, and RightAnkle represents the right ankle (off) node.
[0123] Location Data:
[0124]
[0125] S42. Obtain the position coordinates of the reference point of the first model according to the rotation data.
[0126] S43. Using the position coordinates of the trunk node in the first model as the migration position coordinates of the corresponding node in the second model.
[0127] The trunk node refers to a node located in the trunk part. That is, for the position data of the node on the trunk in the human body 3D model, the position coordinates assigned to the first model by motion capture technology can be directly used as the position coordinates of the corresponding node in the second model without the need to migrate through the following steps.
[0128] Because the trunk nodes of the human body do not participate in the movement or their contribution to the movement is limited, the position coordinates of the trunk nodes have little effect on the accuracy of the movement. Therefore, directly using the position coordinates of the trunk nodes of the first model as the migration position coordinates of the corresponding nodes in the second model can save computing power and reduce latency without significantly reducing the accuracy of the virtual object's movement.
[0129] S44. According to the position coordinates of the nodes in the first model and the position coordinates of the reference point, obtain a vector from the first reference point to the first node as a first vector.
[0130] As mentioned above, the first node is any node in the first model to which data is to be migrated. In this step and the following embodiments, an example of the first node is LeftWrist.
[0131] The first reference node is Figure 2c The centroid of any triangle shown.
[0132] For the sake of convenience, any reference point among the reference points of the first model is referred to as a first reference point.
[0133] Specifically, the position coordinates of the LeftWrist node and the reference point are used as known data and substituted into: Get multiple vectors v i .
[0134] Among them, ref i A is the reference point, where i = 1, 2, ... n, and different values of i represent different reference points. i is the influence factor of each reference point determined by the method described in the above embodiment. It can be understood that in the above formula (1), for the reference point ref i A ,λ i For ref i A The influence factor of the grid on the LeftWrist node.
[0135] Hereinafter, the vector pointing from the first reference point to the LeftWrist node is referred to as the first reference vector.
[0136] It can be understood that the meaning of formula (1) is: the position coordinate of the LeftWrist node is the weighted sum of the second vectors of each reference point, where the second vector of the first reference point is the sum of the first reference vector of the first reference point and the position coordinate of the first reference point in the first model.
[0137] In other words, the above process can also be expressed as: according to the position coordinates of the target node, the initial displacement coordinates of the first node are determined, and the initial displacement coordinates of the first reference point are the coordinates obtained by moving the first reference point along the direction of the first vector by the length of the first vector. According to the initial displacement coordinates of the first reference point and the position coordinates of the first reference point, the first vector is obtained.
[0138] It can be understood that, for each reference point, the corresponding first vector can be obtained according to the above process.
[0139] S45. Use a preset first parameter to normalize the first vector to obtain a normalized first vector.
[0140] One way to set the first parameter may be to use the sum of the projection lengths of the vectors of the first model on the first vector as the first parameter.
[0141] Each vector of the first model is a vector from the previous node of two adjacent nodes to the next node in the first node sequence. The first node sequence is a sequence of nodes passed in the order in which they are passed in the process of moving from the node closest to the first reference point to the first node on the first model.
[0142] The length of the vector from the previous node to the next node is obtained by the difference between the position coordinates of the previous node and the next node, and the direction is the direction from the previous node to the next node.
[0143] by Figure 2a For example, assume that the node closest to the first reference point is Figure 2a As shown in the figure, in the process of moving from Hips in the first model to LeftWrist, the nodes passed in sequence are: Hips->Spine1->Spine2->LeftShoulder->LeftElbow->LeftWrist. Therefore, the first node sequence is (Hips, Spine1, Spine2, LeftShoulder, LeftElbow, LeftWrist).
[0144] The first model vectors are:
[0145]
[0146]
[0147]
[0148]
[0149]
[0150] In the above formulas, P represents the position coordinates, and src represents the first model.
[0151] Any first model vector The length of the projection onto the first vector is expressed as:
[0152] In formula (1) represents the unit vector of the first vector, express is the unit vector, so Indicates v i and The cosine value of the angle between express In v iThe projection length on .
[0153] The first parameter of the i-th node is Taking the first node sequence mentioned above as an example, m=5.
[0154] It can be seen from the calculation formula of the first parameter that the first parameter represents the length component of the path formed by the nodes in the first node sequence in the first vector direction.
[0155] Specifically, the normalized first vector is: Because the first parameter represents the length component of the path formed by the nodes in the first node sequence in the direction of the first vector, the normalized first vector obtained by using the first parameter can be regarded as a vector that eliminates the specificity of the length. That is, in the path formed by the first node sequence in the first model, the influence of the distance between the nodes on the normalized first vector has been eliminated.
[0156] It can be understood that the above formula for calculating the normalized vector is only an example and may also be in other forms, for example, multiplying the above formula by a coefficient.
[0157] S46. Denormalize the normalized first vector to the second model using a preset second parameter to obtain a pointing vector of the first reference point.
[0158] One way to set the second parameter may be to use the sum of the projection lengths of the vectors of the second model on the first vector as the second parameter.
[0159] Each vector of the second model is a vector in the second node sequence, where the previous node of two adjacent nodes points to the next node. The second node sequence is a sequence of nodes passed in the order in which they are passed in the process of moving from the corresponding node of the node closest to the first reference point to the corresponding first node on the second model.
[0160] According to the above definition of corresponding nodes, an example of a second node sequence corresponding to an example of a first node sequence in the first model is the following sequence of nodes in the second model:
[0161] (Hips,Spine1,Spine2,LeftShoulder,LeftElbow,LeftWrist).
[0162] The second model vectors are:
[0163]
[0164]
[0165]
[0166]
[0167]
[0168] In the above formulas, P represents the position coordinates, and tar represents the second model.
[0169] The second parameter is It can be seen from the calculation formula of the second parameter that the second parameter represents the length component of the path formed by the nodes in the second node sequence in the direction of the first vector.
[0170] The pointing vector of the first node is: The second parameter represents the length component of the path formed by the nodes in the second node sequence in the direction of the first vector, so the normalized first vector multiplied by the second parameter can be regarded as mapping the normalized first vector to the second model. That is, the pointing vector has the distance characteristics between the nodes in the path formed by the second node sequence.
[0171] S47, after moving the first reference point along the direction of the pointing vector of the first reference point by the length of the pointing vector, the pointing displacement coordinates of the first reference point are obtained.
[0172] It can be understood that, according to the method of acquiring the pointing displacement coordinates of the first reference point, the pointing displacement coordinates of each reference point can be acquired.
[0173] S48. Determine the migration position coordinates obtained by migrating the position coordinates of the first node to the corresponding first node according to the influence factors of each reference point of the first model and the weighted sum of the directional displacement coordinates of each reference point.
[0174] Specifically, the migration position coordinates of the LeftWrist node in the second model are:
[0175]
[0176] in, is the pointing displacement coordinate of the first reference point. i is the influence factor of the first reference point.
[0177] Because the target node is any node except the trunk node, the above processing is performed on the nodes except the trunk node in sequence to obtain the migration position coordinates of all other nodes except the trunk node.
[0178] S49, determining migration rotation data corresponding to the first node according to the migration position coordinates corresponding to the first node and the initial position coordinates of the nodes in the second model.
[0179] The initial position coordinates can be configured when constructing the second model and are known data for this step.
[0180] Specifically, the IK algorithm may be used to determine the migration rotation data based on the migration position coordinates and the initial position coordinates, which will not be described in detail here.
[0181] It can be understood that the method of determining the migration rotation data using the post-migration position coordinates and the initial position coordinates is easier to implement than the method of determining the migration position coordinates, so it can also save computing power and time resources.
[0182] After removing the influence of human body proportions from the data in the first model by normalization, the data is then assigned to the second model, and the body proportions of the second model are taken into consideration when assigning the data to the second model. In addition, reference points that can reflect the "fatness" of the human body are introduced, so that the actions of the virtual characters driven by the second model can be closer to the actions of the entity, thereby having higher accuracy. In addition, because the influence factor of each reference point is determined based on the distance of the grid to the node and the area of the grid, this method is applicable to a wider range of models and has higher versatility.
[0183] Figure 5 A motion data migration device disclosed in an embodiment of the present application includes:
[0184] A first acquisition module, configured to acquire position coordinates of a reference point of the first model according to rotation data of a node in the first model, wherein the reference point of the first model is a point in a grid of the first model;
[0185] a first determining module, configured to determine a distance between a first reference point and a first node in the first model according to a position coordinate of the first reference point and a position coordinate of a first node in the first model, wherein the first reference point is any reference point of the first model, and the first node is any node;
[0186] A second determination module is used to preset a rule to determine an influence factor of the first reference point, wherein the preset rule includes an inverse correlation between the distance and the influence factor, wherein the influence factor indicates the influence degree of a target grid on the first node, and the target grid is a grid where the first reference point is located;
[0187] A migration module is used to use the influence factor of the reference point of the first model as a weight, and determine the migration position coordinates obtained after migrating the position coordinates of the nodes of the first model to the corresponding nodes in the second model based on the weighted sum of the pointing displacement coordinates of the reference point of the first model, wherein the pointing displacement coordinates are determined based on the first reference point of the first model and the position coordinates of the nodes.
[0188] Optionally, the specific implementation method of the second determination module for determining the influence factor of the first reference point according to a preset rule includes: the second determination module is specifically used to determine the influence factor according to the inverse of the distance if the distance is greater than the minimum value; if the distance is not greater than the minimum value, determine the influence factor according to the inverse of the minimum value.
[0189] Optionally, the second determination module is used to determine the impact factor based on the inverse of the distance, and the specific implementation method includes: the second determination module is used to determine the impact factor based on the product of the area of the target grid and the inverse of the distance; the second determination module is used to determine the impact factor based on the inverse of the minimum value, and the specific implementation method includes: the second determination module is used to determine the impact factor based on the product of the area of the target grid and the inverse of the minimum value.
[0190] Optionally, the second determination module is used to determine the impact factor based on the product of the area of the target grid and the inverse of the distance. The specific implementation method includes: the second determination module is specifically used to take the product of the nth power of the area and the inverse of the distance as the impact factor; the second determination module is used to determine the impact factor based on the product of the area of the target grid and the inverse of the minimum value. The specific implementation method includes: the second determination module is specifically used to take the product of the nth power of the area and the inverse of the minimum value as the impact factor, and n is an integer greater than or equal to 1.
[0191] Optionally, the migration module is used to use the influence factor of the reference point in the first model as a weight, and determine the migration position coordinates obtained after the position coordinates of the node in the first model are migrated to the corresponding node in the second model according to the weighted sum of the pointing displacement coordinates of the reference point of the first model. The specific implementation method includes: the migration module is specifically used to determine the migration position coordinates obtained after the position coordinates of the first node are migrated to the corresponding first node according to the influence factor of each reference point of the first model and the weighted sum of the pointing displacement coordinates of each reference point, the pointing displacement coordinates of the first reference point are the coordinates obtained by moving the first reference point along the direction of the pointing vector of the first reference point by the length of the pointing vector; wherein, the pointing vector of the first reference point is obtained by normalizing the first vector using a preset first parameter, and then denormalizing it to the second model using a preset second parameter, and the first vector is the vector pointing from the first reference point to the first node in the first model.
[0192] Optionally, a specific implementation method of the migration module for obtaining the first vector includes: the migration module is specifically used to determine the initial displacement coordinates of the first reference point based on the position coordinates of the first node, the initial displacement coordinates of the first reference point being the coordinates obtained by moving the first reference point along the direction of the first vector by the length of the first vector; obtaining the first vector based on the initial displacement coordinates of the first reference point and the position coordinates of the first reference point.
[0193] The device described in this embodiment is used to migrate data of a first model to a second model with the same topological relationship, so that the movement accuracy of a virtual object driven by the second model with the migrated data is higher, and this device is generally applicable to models represented by more grids and fewer grids.
[0194] An embodiment of the present application further discloses an electronic device, including: a processor and a memory, wherein the memory is used to store a program, and the processor is used to run the program to implement the data migration method described in the above embodiment.
[0195] The embodiment of the present application further discloses a computer-readable storage medium on which a program is stored, characterized in that when the electronic device runs the program, the data migration method described in the above embodiment is implemented.
[0196] If the functions described in the method of the embodiment of the present application are implemented in the form of software functional units and sold or used as independent products, they can be stored in a storage medium readable by a computing device. Based on this understanding, the part of the embodiment of the present application that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions to enable a computing device (which can be a personal computer, server, mobile computing device or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program code.
[0197] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0198] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A data migration method for migrating data from a first model to a second model with the same topological relationship, characterized in that: include: According to the rotation data of the nodes in the first model, obtaining the position coordinates of the reference point of the first model, where the reference point of the first model is a point in the grid of the first model; Determine a distance between a first reference point and a first node in the first model according to position coordinates of the first reference point and the position coordinates of a first node in the first model, wherein the first reference point is any reference point of the first model and the first node is any node in the first model; Determine an influence factor of the first reference point according to a preset rule, wherein the preset rule includes that the distance is inversely correlated with the influence factor, and the influence factor indicates the influence degree of a target grid on the first node, and the target grid is the grid where the first reference point is located; Using the influence factor of the reference point of the first model as a weight, determining the migration position coordinates obtained after migrating the position coordinates of the node of the first model to the corresponding node in the second model according to the weighted sum of the pointing displacement coordinates of the reference point of the first model, wherein the pointing displacement coordinates are determined according to the position coordinates of the reference point and the node of the first model; The method of using the influence factor of the reference point in the first model as a weight and determining the migration position coordinates obtained by migrating the position coordinates of the nodes in the first model to the corresponding nodes in the second model according to the weighted sum of the pointing displacement coordinates of the reference points in the first model includes: Determine, based on the influence factors of each reference point of the first model and the weighted sum of the pointing displacement coordinates of each reference point, the migration position coordinates obtained by migrating the position coordinates of the first node to the corresponding first node, where the corresponding first node is the corresponding node of the first node in the second model, and the pointing displacement coordinates of the first reference point are the coordinates obtained by moving the first reference point along the direction of the pointing vector of the first reference point by the length of the pointing vector; Among them, the pointing vector of the first reference point is obtained by normalizing the first vector using a preset first parameter and then denormalizing it to the second model using a preset second parameter. The first vector is the vector pointing from the first reference point to the first node in the first model.
2. The method according to claim 1, characterized in that Determining the influencing factor of the first reference point according to a preset rule includes: If the distance is greater than a preset minimum value, determining the impact factor according to the reciprocal of the distance; If the distance is not greater than the minimum value, the influence factor is determined according to the inverse of the minimum value.
3. The method according to claim 2, characterized in that Determining the impact factor according to the inverse of the distance includes: Determining the impact factor according to the product of the area of the target grid and the reciprocal of the distance; Determining the impact factor according to the reciprocal of the minimum value includes: The influence factor is determined according to the product of the area of the target grid and the reciprocal of the minimum value.
4. The method according to claim 3, characterized in that The determining the influencing factor according to the product of the area of the target grid and the reciprocal of the distance comprises: The product of the nth power of the area and the reciprocal of the distance is used as the influence factor; Determining the influencing factor according to the product of the area of the target grid and the reciprocal of the minimum value includes: The product of the nth power of the area and the reciprocal of the minimum value is taken as the influence factor, where n is an integer greater than or equal to 1.
5. The method according to claim 1, characterized in that The method for obtaining the first vector includes: Determine the initial displacement coordinates of the first reference point according to the position coordinates of the first node, where the initial displacement coordinates of the first reference point are coordinates obtained by moving the first reference point along the direction of the first vector by the length of the first vector; The first vector is obtained according to the initial displacement coordinates of the first reference point and the position coordinates of the first reference point.
6. A motion data migration device, used to migrate data of a first model to a second model with the same topological relationship, characterized in that: include: A first acquisition module, configured to acquire position coordinates of a reference point of the first model according to rotation data of a node in the first model, wherein the reference point of the first model is a point in a grid of the first model; a first determining module, configured to determine a distance between a first reference point and a first node in the first model according to a position coordinate of the first reference point and a position coordinate of a first node in the first model, wherein the first reference point is any reference point of the first model, and the first node is any node in the first model; A second determination module is used to determine the influence factor of the first reference point according to a preset rule, wherein the preset rule includes an inverse correlation between the distance and the influence factor, and the influence factor indicates the influence degree of a target grid on the first node, and the target grid is the grid where the first reference point is located; A migration module, used to use the influence factor of the reference point of the first model as a weight, and determine the migration position coordinates obtained after migrating the position coordinates of the nodes of the first model to the corresponding nodes in the second model according to the weighted sum of the pointing displacement coordinates of the reference point of the first model, wherein the pointing displacement coordinates are determined according to the first reference point of the first model and the position coordinates of the nodes; The migration module uses the influence factor of the reference point in the first model as a weight, and determines the migration position coordinates obtained after migrating the position coordinates of the nodes in the first model to the corresponding nodes in the second model according to the weighted sum of the pointing displacement coordinates of the reference points in the first model, specifically for: According to the influence factors of each reference point of the first model and the weighted sum of the pointing displacement coordinates of each reference point, the migration position coordinates obtained after migrating the position coordinates of the first node to the corresponding first node are determined, the corresponding first node is the corresponding node of the first node in the second model, and the pointing displacement coordinates of the first reference point are the coordinates obtained by moving the first reference point along the direction of the pointing vector of the first reference point by the length of the pointing vector; wherein, the pointing vector of the first reference point is obtained by normalizing the first vector using a preset first parameter, and then denormalizing it to the second model using a preset second parameter, and the first vector is the vector pointing from the first reference point to the first node in the first model.
7. The device according to claim 6, characterized in that The second determination module is used to determine the influencing factor of the first reference point according to a preset rule, including: The second determination module is specifically used to determine the impact factor according to the reciprocal of the distance if the distance is greater than a preset minimum value; and to determine the impact factor according to the reciprocal of the minimum value if the distance is not greater than the minimum value.
8. An electronic device, characterized in that: include: Processor and memory; The memory is used to store a program, and the processor is used to run the program to implement the data migration method described in any one of claims 1 to 5.
9. A computer-readable storage medium having a program stored thereon, characterized in that: When the electronic device runs the program, the data migration method described in any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Bone binding method and device of human body model and electronic equipment
CN113034691A
Animation migration method and device, equipment and storage medium
CN113313794A