Dynamic bone simulation method and apparatus, computer program product and electronic device
By adding preset constraints and solving the constraints of the bone chains in dynamic bone simulation, the problems of stretching and clipping between bone chains are solved, achieving a ring structure and realistic animation effects, thus improving the animation quality.
Patent Information
- Application Number
- CN202410853101.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-27
- Publication Date
- 2025-11-21
- Estimated Expiration
- 2044-06-27
AI Technical Summary
In existing technologies, dynamic skeleton simulation based on tree structures cannot realize the ring structure and effective constraints between skeleton chains, resulting in unrealistic animation effects, especially in the simulation of planar cloth and ribbons, where there are stretching and clipping problems.
By adding preset constraints between the bones of the skeletal chain to be simulated, pausing the forward dynamics simulation when constraints exist, updating the starting bones, solving the constraint set, and continuing until all bones have completed the forward dynamics simulation, constraint binding between arbitrary bones is achieved, avoiding stretching and clipping.
It enriches the scenes of dynamic skeleton simulation, realizes ring structure and more realistic animation effects, avoids stretching and clipping problems between bone chains, and improves the display quality of animation.
Smart Images

Figure CN118734578B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present disclosure relates to the field of computer technology, and in particular, to a dynamic bone simulation method, a dynamic bone simulation device, a computer readable storage medium, a computer program product and an electronic device. BACKGROUND
[0002] With the development of computer technology, dynamic bone simulation technology is widely used in the fields of film and television, games and the like. Dynamic bone simulation refers to re-performing physical simulation calculation on each bone in actual animation, and considering the collision response of wind, gravity in the scene and the collision body on the character and the environmental collision body, so that the object motion becomes more rich and can be interacted in real time.
[0003] In the related art, dynamic bone simulation is performed based on a tree structure, that is, in forward dynamics, each bone is driven by its parent bone, and in reverse dynamics, each bone is driven by its child bone.
[0004] That is, in the related art, a certain bone only has constraints with two bones, that is, the parent bone and the child bone of the bone, so the implementation scenarios of the bone are limited. For example, since there is no constraint between the root bone and the leaf bone in the simulation based on the tree structure, the leaf bone and the root bone cannot be bound together to realize a ring structure, and there is a problem of obvious stretching caused by too far or too close distance between bone chains, which affects the display effect of the animation.
[0005] It should be noted that the information disclosed in the above background section is only used to strengthen the understanding of the background of the present disclosure, and therefore can include information that does not constitute prior art known to those of ordinary skill in the art. SUMMARY
[0006] The purpose of the present disclosure is to provide a dynamic bone simulation method and device, a computer readable storage medium, a computer program product and an electronic device, thereby at least to some extent improving the simulation effect of dynamic bone simulation.
[0007] Other characteristics and advantages of the present disclosure will become apparent from the following detailed description, or will be learned by practice of the present disclosure.
[0008] According to a first aspect of the present disclosure, a dynamic bone simulation method is provided, comprising: starting from a current starting bone of a bone chain to be simulated, performing forward dynamics simulation on bones in the bone chain to be simulated, at least two bones in the bone chain to be simulated having preset constraints; in the case that a current bone has a constraint, pausing the forward dynamics simulation on the bone chain to be simulated, and updating the current starting bone according to the current paused bone; in the case that each bone chain to be simulated is paused, obtaining a current to-be-solved set according to constraints existing in all current paused bones of each bone chain to be simulated, solving the constraints in the current to-be-solved set; in the case that no unsolved constraint exists in the current paused bone of the bone chain to be simulated, repeating the above-mentioned forward dynamics simulation process starting from the current updated current starting bone of the bone chain to be simulated until a leaf bone in the bone chain to be simulated completes the forward dynamics simulation, and determining that the simulation of the bone chain to be simulated is completed; wherein, when performing the forward dynamics simulation on the bone chain to be simulated for the first time, the current starting bone comprises a root bone of the bone chain to be simulated.
[0009] Optionally, the obtaining of the current to-be-solved set according to the constraints existing in the current paused bones of each bone chain to be simulated comprises: determining a collection constraint set according to the constraints existing in the current paused bones of each bone chain to be simulated; and determining constraints in which all constrained bones have completed the forward dynamics simulation from the collection constraint set to obtain a current to-be-solved constraint set.
[0010] Optionally, the constraints comprise distance constraints for limiting a distance range between bones; and the solving of the constraints in the current to-be-solved set comprises: solving the distance constraints in the current to-be-solved set until the solving result causes the distance between the bones limited by the distance constraints in the current to-be-solved set to satisfy the distance range indicated by the distance constraints or a preset solving number of times is reached, and determining that the solving of the distance constraints is completed.
[0011] Optionally, the solving of the distance constraints in the current to-be-solved set comprises: solving the distance constraints in the current to-be-solved set according to a preset priority.
[0012] Optionally, the solving the distance constraint in the current to-be-solved set comprises: in a case where an actual distance between the bones limited by the distance constraint is greater than a maximum distance indicated by the distance constraint, moving the bones limited by the distance constraint in a distance-reducing direction so that the actual distance between the bones limited by the distance constraint is equal to the maximum distance indicated by the distance constraint; in a case where the actual distance between the bones limited by the distance constraint is less than a minimum distance indicated by the distance constraint, moving the bones limited by the distance constraint in a distance-increasing direction so that the actual distance between the bones limited by the distance constraint is equal to the minimum distance indicated by the distance constraint.
[0013] Optionally, the manner of moving the bones limited by the distance constraint comprises: moving the bones limited by the distance constraint according to bone weights, so that a moving distance of a bone with a large bone weight is greater than a moving distance of a bone with a small bone weight.
[0014] Optionally, the constraint comprises a collision body constraint, the collision body constraint is used to limit a constraint edge to be located outside a collision body, the constraint edge is determined according to a connecting line between two bones existing the constraint, and the solving the constraint in the current to-be-solved set comprises: after the distance constraint is solved, determining whether the constraint edge is located inside the collision body according to a perpendicular line length between the constraint edge and a collision body axis; in a case where the constraint edge is located inside the collision body, determining moving distances of the two bones indicated by the constraint edge, and moving the bones according to the moving distances to move the constraint edge to the outside of the collision body.
[0015] Optionally, the determining whether the constraint edge is located inside the collision body according to the distance between the constraint edge and the collision body axis comprises: in a case where the perpendicular line length between the constraint edge and the collision body axis is less than a radius of the collision body, determining that the constraint edge is located inside the collision body.
[0016] Optionally, the determining the moving distances of the two bones indicated by the constraint edge comprises: determining the moving distances of the two bones indicated by the constraint edge according to bone weights of the two bones indicated by the constraint edge.
[0017] Optionally, the determining the moving distances of the two bones indicated by the constraint edge according to the bone weights of the two bones indicated by the constraint edge comprises: in a case where the bone weights of the two bones indicated by the constraint edge are equal, determining a perpendicular line length between the constraint edge and the collision body axis; and determining the moving distances of the two bones indicated by the constraint edge according to a difference between the radius of the collision body and the perpendicular line length.
[0018] Optionally, the determining the moving distance of the two bones indicated by the constraint edge comprises: in the case that the bone weights of the two bones indicated by the constraint edge are not equal, determining the length of the perpendicular line between the constraint edge and the axis of the collision body; determining the difference between the radius of the collision body and the length of the perpendicular line; determining the first moving distance of the first bone in the range greater than or equal to 0 and less than or equal to the difference; and determining the second moving distance of the second bone according to the difference, the first moving distance, the distance from the first bone to the target point, and the distance from the second bone to the target point, wherein the target point is determined according to the nearest point between the constraint edge and the axis of the center of the collision body; wherein the first bone is the bone with smaller bone weight in the two bones indicated by the constraint edge, and the second bone is the bone with larger bone weight in the two bones indicated by the constraint edge.
[0019] Optionally, the constraint comprises a bone weight, and the bone weight is used to indicate the degree of influence of the constraint on the bone; and the pausing the forward dynamics simulation of the to-be-simulated bone chain in the case that the current bone exists the constraint and updating the current starting bone according to the current staying bone comprises: in the case that the current bone exists the constraint and the bone weight is a first preset coefficient, pausing the forward dynamics simulation of the to-be-simulated bone chain and updating the current starting bone according to the current staying bone.
[0020] Optionally, the pausing the forward dynamics simulation of the to-be-simulated bone chain in the case that the current bone exists the constraint and updating the current starting bone according to the current staying bone comprises: in the case that the current bone exists the constraint and the bone weight is a second preset coefficient, determining whether the number of child bones of the current bone is greater than 1; in the case that the number of child bones is greater than 1, pausing the forward dynamics simulation of the to-be-simulated bone chain and updating the current starting bone according to each child bone respectively.
[0021] Optionally, the method further comprises: in the case that the current staying bone of each to-be-simulated bone chain exists an unsolved constraint, determining that the remaining unsolved constraint is an invalid constraint, and performing the forward dynamics simulation on the bone not traversed in each to-be-simulated bone chain until the leaf bone in the to-be-simulated bone chain completes the forward dynamics simulation, and determining that the simulation of the to-be-simulated bone chain is completed, wherein the invalid constraint does not pause the forward dynamics simulation of the to-be-simulated bone chain; and in the case that the simulation of each to-be-simulated bone chain is completed, determining that the dynamic bone simulation is completed.
[0022] Optionally, the constraint comprises a bone weight, in a case where two bones limited by the constraint have an ancestor-descendant relationship, a bone weight of an ancestor bone among the two bones is configured as 0, and a bone weight of a descendant bone among the two bones is configured as 1, the bone weight being used to indicate an influence degree of the bone being constrained.
[0023] According to a second aspect of the present disclosure, a dynamic bone simulation method is provided, comprising: in response to a bone constraint adding operation, traversing bones in a target bone chain in which a bone to which a constraint is added is located, starting from a current starting bone of the target bone chain; in a case where a currently traversed bone has a constraint, pausing the traversal of the target bone chain, and updating the current starting bone according to a current pause bone, the current pause bone being determined according to a bone at which the traversal is paused; in a case where the traversal of each of the target bone chains is paused, marking a constraint for which bones limited by the constraint have all been traversed, in a case where the current pause bone has the constraint; in a case where the current pause bone does not have an unmarked constraint, continuing the traversal of the target bone chain corresponding to the current pause bone to repeat the above process; and determining an adding result of the bone constraint according to the marking of the constraint, and performing dynamic bone simulation according to the adding result.
[0024] Optionally, the traversing bones in the target bone chain in which the bone to which the constraint is added is located, starting from the current starting bone of the target bone chain, in response to the bone constraint adding operation, comprises: in response to the bone constraint adding operation, checking whether a to-be-added bone constraint is legal; and in a case where the to-be-added bone constraint is legal, traversing bones in the target bone chain in which the bone to which the constraint is added is located, starting from the current starting bone of the target bone chain.
[0025] Optionally, the checking whether the to-be-added bone constraint is legal comprises: checking whether bones limited by the to-be-added bone constraint are the same bone; and / or checking whether the bones limited by the to-be-added bone constraint have a parent-child relationship.
[0026] Optionally, the traversing bones in the target bone chain in which the bone to which the constraint is added is located, starting from the current starting bone of the target bone chain, in a case where the to-be-added bone constraint is legal, comprises: in a case where the to-be-added bone constraint is legal, checking whether bones limited by the to-be-added bone constraint belong to the same bone chain; and in a case where the bones limited by the to-be-added bone constraint do not belong to the same bone chain, traversing bones in the target bone chain in which the bone to which the constraint is added is located, starting from the current starting bone of the target bone chain.
[0027] Optionally, the method further comprises: in a case where the bones to be added with the bone constraint belong to the same bone chain, configuring a bone weight of an ancestor bone in the restricted bones as 1 and a bone weight of a child bone in the restricted bones as 0, the bone weight being used to indicate an influence degree of the bone constraint.
[0028] Optionally, the adding result of the bone constraint is determined according to the marking of the constraint, and the dynamic bone simulation is performed according to the adding result, comprising: adding the marked constraint as a valid bone constraint and adding the unmarked constraint as an invalid bone constraint, and performing the dynamic bone simulation according to the valid bone constraint.
[0029] Optionally, the method further comprises: generating prompt information of the invalid bone constraint, and displaying the prompt information of the invalid bone constraint on a bone constraint adding interface.
[0030] According to a third aspect of the present disclosure, a dynamic bone simulation device is provided, comprising: a forward dynamics simulation module configured to perform forward dynamics simulation on bones in a bone chain to be simulated, starting from a current starting bone of the bone chain to be simulated, at least two bones in the bone chain to be simulated having a preset constraint; a first updating module configured to pause the forward dynamics simulation on the bone chain to be simulated in a case where a current bone has a constraint, and update the current starting bone according to the current bone; a to-be-solved set determining module configured to, in a case where each bone chain to be simulated is paused, obtain a current to-be-solved set according to the constraint existing in the current bone of each bone chain to be simulated, and solve the constraint in the current to-be-solved set; and a first repeating module configured to, in a case where the current bone of the bone chain to be simulated has no unsolved constraint, repeat the operations of the above modules starting from the updated current starting bone of the bone chain to be simulated until a leaf bone in the bone chain to be simulated completes the forward dynamics simulation, and determine that the bone chain to be simulated is simulated to an end; wherein, when performing the forward dynamics simulation on the bone chain to be simulated for the first time, the current starting bone comprises a root bone of the bone chain to be simulated.
[0031] According to a fourth aspect of the present disclosure, a dynamic bone simulation device is provided, comprising: a traversal module configured to, in response to a bone constraint addition operation, traverse bones in a target bone chain in which the added constraint is located, starting from a current starting bone of the target bone chain; a second update module configured to, in a case where a currently traversed bone has a constraint, pause the traversal of the target bone chain and update the current starting bone according to a current pause bone, the current pause bone being determined according to the bone at which the traversal is paused; a marking module configured to, in a case where each of the target bone chains is paused, mark a constraint for which a bone subject to the constraint has been traversed, in a case where the current pause bone has a constraint; a second repetition module configured to, in a case where the current pause bone does not have an unmarked constraint, continue the traversal of the target bone chain corresponding to the current pause bone to repeat the operations of the above modules; and a constraint addition module configured to determine an addition result of the bone constraint according to the marking of the constraint, and perform dynamic bone simulation according to the addition result.
[0032] According to a fifth aspect of the present disclosure, a computer program product containing instructions which, when executed on a computer, cause the computer to perform the steps of the dynamic bone simulation method according to the first aspect and / or the dynamic bone simulation method according to the second aspect.
[0033] According to a sixth aspect of the present disclosure, a computer-readable storage medium is provided, having stored thereon a computer program which, when executed by a processor, implements the dynamic bone simulation method according to the first aspect and / or the dynamic bone simulation method according to the second aspect.
[0034] According to a seventh aspect of the present disclosure, an electronic device is provided, comprising: a processor; and a storage device for storing one or more programs, which, when executed by the one or more processors, cause the one or more processors to implement the dynamic bone simulation method according to the first aspect and / or the dynamic bone simulation method according to the second aspect.
[0035] From the above technical solutions, it can be seen that the dynamic bone simulation method, the dynamic bone simulation device, and the computer program product, the computer-readable storage medium, and the electronic device for implementing the dynamic bone simulation method in the exemplary embodiments of the present disclosure have at least the following advantages and positive effects:
[0036] In the technical solution provided by some embodiments of the present disclosure, firstly, the forward dynamics simulation is performed on the bones in the bone chain to be simulated, starting from the current starting bone of the bone chain to be simulated; then, in the case that the current bone exists constraints, the forward dynamics simulation is paused, and the current starting bone is updated according to the current bone; in the case that the simulation of each bone chain to be simulated is paused, the current to-be-solved set is determined; finally, the forward dynamics simulation is performed on the bone chain to be simulated according to the solving result of the constraints existing in the current bone, until the simulation of the bone chain to be simulated ends. On the one hand, the dynamic bone simulation method in the present disclosure can add constraints between any bones, which enriches the scene of the dynamic bone simulation, for example, the root bone and the leaf bone of the same bone chain can be bound together to realize a ring structure by adding constraints between them; on the other hand, since the dynamic bone simulation method in the present disclosure can add constraints between any bones, when the constraints exist between the bones of different bone chains, the problem of obvious stretching between the bone chains due to being too close or too far apart can be avoided, the display effect of the animation is improved, and the animation display is more realistic.
[0037] It should be understood that the foregoing general description and the following detailed description are only exemplary and explanatory, and are not limiting to the present disclosure. BRIEF DESCRIPTION OF DRAWINGS
[0038] The accompanying drawings, which are incorporated into and form part of the specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure. Obviously, the drawings in the following description are only some embodiments of the present disclosure, and other drawings can be obtained according to these drawings without creative labor for those skilled in the art.
[0039] Figure 1 A schematic diagram showing the implementation process of the existing cloth simulation technology is shown;
[0040] Figure 2 A schematic diagram showing an exemplary system architecture to which embodiments of the present disclosure can be applied is shown;
[0041] Figure 3 A flowchart showing a dynamic bone simulation method in an exemplary embodiment of the present disclosure is shown;
[0042] Figure 4 A schematic diagram showing a forward dynamics simulation and a reverse dynamics simulation in an exemplary embodiment of the present disclosure is shown;
[0043] Figure 5A A schematic diagram showing a self-constraint in an exemplary embodiment of the present disclosure is shown;
[0044] Figure 5BA schematic diagram showing a bone chain inter-restriction in an example embodiment of the present disclosure;
[0045] Figure 6 A schematic diagram showing a distance restriction in an example embodiment of the present disclosure;
[0046] Figure 7A A schematic diagram showing a collision insertion of a restriction edge and a capsule in an example embodiment of the present disclosure;
[0047] Figure 7B A schematic diagram showing a bone movement in collision detection in an example embodiment of the present disclosure;
[0048] Figure 7C A schematic diagram showing another bone movement in collision detection in an example embodiment of the present disclosure;
[0049] Figure 8A A schematic diagram showing a self-dependence in an example embodiment of the present disclosure;
[0050] Figure 8B A schematic diagram showing a cross-dependence in an example embodiment of the present disclosure;
[0051] Figure 8C A schematic diagram showing a circular dependence in an example embodiment of the present disclosure;
[0052] Figure 9 A schematic diagram showing a flow of a constraint solving method in an example embodiment of the present disclosure;
[0053] Figure 10 A schematic diagram showing a flow of another dynamic bone simulation method in an example embodiment of the present disclosure;
[0054] Figure 11 A schematic diagram showing a flow of an implementation method of a traversal strategy for a bone chain in an example embodiment of the present disclosure;
[0055] Figure 12 A schematic diagram showing a dynamic bone simulation process in an example embodiment of the present disclosure;
[0056] Figure 13 A schematic diagram showing a flow of still another dynamic bone simulation method in an example embodiment of the present disclosure;
[0057] Figure 14 A schematic diagram showing a flow of a method of adding bone constraints in an example embodiment of the present disclosure;
[0058] Figure 15 A constraint display interface in an editor state in an example embodiment of the present disclosure;
[0059] Figure 16 FIG. 1 shows a structural schematic diagram of a dynamic bone simulation device according to an exemplary embodiment of the present disclosure;
[0060] Figure 17 FIG. 2 shows a structural schematic diagram of another dynamic bone simulation device according to an exemplary embodiment of the present disclosure;
[0061] Figure 18 FIG. 3 shows a structural schematic diagram of an electronic device according to an exemplary embodiment of the present disclosure. DETAILED DESCRIPTION
[0062] Example implementations will now be described more fully with reference to the accompanying drawings. Example implementations can be implemented in any
[0063] In this specification, the use of the phrases "one", "a", "the", and "said" are used to mean that "one or more" of the elements / components / etc. is present; the use of the phrases "include", "includes", and "including" are used to mean that "including but not limited to" is intended; the use of the phrases "first", "second", and the like are used to merely identify initial or other successive elements / components / etc. and do not imply a quantity limitation.
[0064] In addition, the drawings are merely schematic and are not necessarily drawn to scale. Like reference numerals designate like elements throughout the drawings and the description, whereupon repeated descriptions can be omitted. Some of the block components shown in the drawings can be functional entities that do not necessarily have to correspond to physically or logically independent entities. These functional entities can be implemented in software, or in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.
[0065] In both game and movie field, realistic effect is the goal that every 3D (three-dimensional) game or movie segment strives to achieve. Realistic effect includes rendering effect and physical effect, and physical simulation determines the authenticity of the movement of flexible objects such as clothes, ribbons and even hair in the scene.
[0066] Taking cloth simulation as an example, in the current cloth simulation technology, there are usually multiple layers of decision-making, as shown in the figure. Figure 1 The first layer is to make cloth skeleton animation by an animator in software such as 3dmax, Maya, etc., to drive the motion trajectory of the cloth. In this layer, the skeleton motion trajectory is fixed, so if there is only this layer of simulation, the motion performance of the cloth will be very single in the actual effect, and cannot be interacted in real time. The second layer of dynamic skeleton simulation technology makes up for the shortcomings of the first layer. Taking a game scene as an example, in the game process, the dynamic skeleton simulation technology re-performs physical simulation calculation on each bone, and considers the wind force, gravity and collision response of the collision body on the character and the environmental collision body in the scene, etc., so that the motion of the cloth will become more abundant and can be interacted in real time. The third layer is to perform calculation on the (skin) vertex level, usually using PBD (Position Based Dynamics) algorithm, at this time each vertex on the cloth will independently perform physical simulation, and will also be subject to various constraints, such as distance constraint, area constraint, angle constraint, etc. These constraints make the distance between vertices, the bending degree of triangular faces, etc. not exceed the limit, so that the cloth always maintains the original shape. Therefore, the third layer of simulation can make the cloth have more details, such as wrinkles of clothes, etc.
[0067] Taking a game as an example, the three layers of decision-making are complementary in actual use. The first layer determines the overall motion trajectory of the cloth, the second layer is to make the cloth be affected by environmental factors such as wind force and gravity during the motion, and interact with the collision body in the scene. The third layer is to make the cloth generate more rich details on the surface during the motion, and perform more realistic. The third layer is the most critical part of cloth simulation, but it is also the most consuming part. Generally speaking, all characters on the screen in the scene cannot all start the third layer simulation, because this will cause very large calculation pressure, causing the game frame rate to drop sharply. Therefore, the character controlled by the general player will start the third layer simulation, while some other players or NPCs (Non Player Character) may only start the second layer simulation, and some games even do not have the third layer simulation, maximizing the performance consumption.
[0068] Therefore, from the perspective of saving performance consumption, the second layer of dynamic skeleton simulation is crucial, which can greatly save computing resources.
[0069] Dynamic bones are generally executed in post-processing of animation, which is to perform real-time physics calculation on bones after the pose of a character is switched and fused by an animation state machine. Bones are tree structure, and the driving relationship is from top to bottom, such as: elbow bending will drive the whole arm to rotate, twisting waist will twist the whole upper body, and so on. Therefore, the simulation of dynamic bones must also follow the top-down simulation order, that is, forward kinematics (FK) simulation. This means that FK must start from the root bone and simulate its child bones after the simulation is completed. The leaf nodes in a bone chain are always the last to be simulated.
[0070] Since all other bones except the root bone are only driven by the ancestor bones, FK cannot arbitrarily modify the state of the child bone. For example, normal playback of bone animation may cause the palm to sink into the wall, and if you want to move the palm outside the wall, you need to correct the position and angle of the wrist, elbow, etc. to ensure the correct pose of the hand bone. This is inverse kinematics (IK) simulation. It is to conduct the affected bones (generally leaf nodes) to the ancestor bones to correct the state of the ancestor bones within a certain depth range.
[0071] The implementation mechanism of dynamic bones in related technologies is to first simulate the whole bone tree by FK, and then determine whether the bone needs to be corrected. If so, IK simulation is performed on the bone.
[0072] Since bones are tree structure, the simulation of bones must be based on forward kinematics, that is, the parent node is always simulated before the child node, and the connection between tree structure bones is limited, each bone can only be driven by its parent bone (forward kinematics) or its child bone (inverse kinematics), and cannot be driven by its sibling node or ancestor node. That is, bones only have constraints on two bones (parent bone and child bone), and have no direct constraints on their ancestors or descendants. Therefore, the algorithm of dynamic bones based on tree structure has many limitations for the simulation of planar cloth and the like, such as the inability to bind the root node and the leaf node of the bone together to realize a ring structure. And there is no constraint between bone chains, such as the inability to realize the animation effect of binding two ribbons together without separating.
[0073] For a ribbon, it is a long strip itself, a single bone chain can be well simulated, while for cloth, it is a surface (such as a skirt) structure, so it needs multiple bone chains to drive. In the dynamic bone simulation, there is no constraint between the bone chains, so each is simulated freely, which can cause obvious stretching due to the distance between two adjacent bone chains being too far or too close. At the same time, since there is no edge between the two bone chains, collision detection is only performed between the two bone chains and the collision body. In some cases, such as when the leg capsule of a character collides with the two bone chains of a skirt, the two bone chains can slide from both sides of the capsule, so that the leg collision body passes through the two bone chains without any obstacles, resulting in a through model. Therefore, the current dynamic bone simulation scene is limited, and the simulation effect is not realistic enough.
[0074] To solve the above problems, the present disclosure provides a dynamic bone simulation method and device, which can be applied to Figure 2 the system architecture of an exemplary application environment as shown.
[0075] As Figure 2 shown, the system architecture 200 can include a terminal device 210 and a server 220. The terminal device 210 can be a smart phone, a tablet computer, a desktop computer, a notebook computer, a smart wearable device, etc. The server 220 refers to a background system that provides related services of the dynamic bone simulation method in the present exemplary embodiment, which can be a server or a cluster formed by multiple servers. The terminal device 210 and the server 220 can be connected through a wired or wireless communication link to interact with each other.
[0076] In an exemplary embodiment, the dynamic bone simulation method described above can be executed by the terminal device 210. Correspondingly, the dynamic bone simulation device can be arranged in the terminal device 210 to realize the corresponding module functions. For example, a user uses the terminal device 210 to operate a game character, and the terminal device 210 performs dynamic bone simulation on the bone chain to be simulated in the game character according to the dynamic bone simulation method described above to realize the corresponding animation effect.
[0077] In an exemplary embodiment, the dynamic bone simulation method described above can be executed by the server 220. Correspondingly, the dynamic bone simulation device can be arranged in the server 220 to realize the corresponding module functions. For example, the server 220 responds to the game operation of a user in the terminal device 210, and performs dynamic bone simulation on the bone chain to be simulated corresponding to the game operation based on the dynamic bone simulation method described above, so as to display the corresponding animation effect in the terminal device 210.
[0078] It should be understood that Figure 2The number of terminal devices and servers in the system is merely illustrative. Any number of terminal devices and servers can be provided according to implementation needs. For example, the server 220 can be a standalone physical server, a server cluster or a distributed system formed by multiple physical servers, a cloud server providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDNs, and basic cloud computing services such as big data and artificial intelligence platforms. The dynamic skeleton simulation method in an embodiment of the present disclosure can run on a local terminal device or a server. When the dynamic skeleton simulation method runs on a server, the method can be implemented and executed based on a cloud interaction system, wherein the cloud interaction system includes a server and a client device.
[0079] In an optional embodiment, various cloud applications can run under the cloud interaction system, for example, cloud games. Taking cloud games as an example, cloud games refer to a game mode based on cloud computing. In the running mode of cloud games, the running subject of a game program and the presentation subject of a game picture are separated, and the storage and running of a game interaction method are completed on a cloud game server. The client device is used for receiving and sending data and presenting a game picture. For example, the client device can be a display device close to a user side and having a data transmission function, such as a mobile terminal, a television, a computer, a palm computer, etc. However, the information processing is performed by the cloud game server in the cloud. When playing a game, a player operates the client device to send operation instructions to the cloud game server, the cloud game server runs the game according to the operation instructions, encodes and compresses game picture data, returns the data to the client device through a network, and finally, the game picture is decoded and output by the client device.
[0080] In an optional embodiment, taking games as an example, a local terminal device stores a game program and is used for presenting a game picture. The local terminal device is used for interacting with a player through a graphical user interface, that is, a conventional game program is downloaded and installed on an electronic device and is run. The way in which the local terminal device provides the graphical user interface to the player can include multiple ways, for example, the graphical user interface can be rendered and displayed on a display screen of the terminal, or the graphical user interface can be provided to the player through holographic projection. For example, the local terminal device can include a display screen used for presenting a graphical user interface including a game picture and a processor used for running the game, generating the graphical user interface, and controlling the display of the graphical user interface on the display screen.
[0081] However, it is easy for those skilled in the art to understand that the above application scenarios are merely examples and the present exemplary embodiments are not limited thereto.
[0082] In a possible implementation, the embodiment of the present application provides a dynamic bone simulation method, which provides a graphical user interface including at least part of a game scene through a terminal device. The terminal device can be the local terminal device mentioned above or the client device in the cloud interaction system mentioned above.
[0083] Figure 3 A flowchart of the dynamic bone simulation method in an example embodiment of the present disclosure is shown. Referring to FIG. 3, the method includes the following steps. Figure 3
[0084] In step S310, forward dynamics simulation is performed on the bones in the bone chain to be simulated, starting from a current starting bone of the bone chain to be simulated, and there is a preset constraint between at least two bones in the bone chain to be simulated.
[0085] In step S320, the forward dynamics simulation of the bone chain to be simulated is paused in the case that the current bone has a constraint, and the current starting bone is updated according to the current staying bone.
[0086] In step S330, in the case that each bone chain to be simulated is paused, a current to-be-solved set is obtained according to the constraint existing in the current staying bone of each bone chain to be simulated, and the constraint in the current to-be-solved set is solved.
[0087] In step S340, in the case that the current staying bone of the bone chain to be simulated does not have an unsolved constraint, the forward dynamics simulation process described above is repeated, starting from the updated current starting bone of the bone chain to be simulated, until the leaf bone in the bone chain to be simulated is completed, and the simulation of the bone chain to be simulated is determined to be ended.
[0088] In the first forward dynamics simulation of the bone chain to be simulated, the current starting bone includes the root bone of the bone chain to be simulated.
[0089] In the case that the terminal device is the local terminal device, the method further includes the following steps. Figure 3 In the technical solution provided by the embodiment, firstly, forward dynamics simulation is performed on the bones in the bone chain to be simulated starting from the current starting bone of the bone chain to be simulated; then, the forward dynamics simulation is paused under the condition that the current bone exists constraints, and the current starting bone is updated according to the current bone; the current to-be-solved set is determined under the condition that the simulation of each bone chain to be simulated is paused; finally, the forward dynamics simulation is performed on the bone chain to be simulated according to the solving result of the constraints existing in the current bone, until the simulation of the bone chain to be simulated is completed. On the one hand, the dynamic bone simulation method in the present disclosure can add constraints between any bones, which enriches the scene of dynamic bone simulation. For example, the root bone and the leaf bone of the same bone chain can be bound together to realize a ring structure. On the other hand, since the dynamic bone simulation method in the present disclosure can add constraints between any bones, when the constraints exist between the bones of different bone chains, the problem of obvious stretching between bone chains due to being too close or too far apart can be avoided, the display effect of the animation is improved, and the animation display is more realistic.
[0090] The specific implementation of each step in the embodiment is described in detail as follows: Figure 3 The specific implementation of each step in the embodiment is described in detail as follows:
[0091] In step S310, forward dynamics simulation is performed on the bones in the bone chain to be simulated starting from the current starting bone of the bone chain to be simulated.
[0092] In an exemplary embodiment, there is a preset constraint between at least two bones in the bone chain to be simulated. The bone chain to be simulated can be determined according to requirements. The bone chain to be simulated can include a bone chain to be subjected to dynamic bone simulation to generate an animation effect. The number of bone chains to be simulated can be one or multiple. For example, in the case of only needing to complete the binding of the root node and the leaf node of the bone to realize a ring structure, the number of bone chains to be simulated can be one.
[0093] In the case that the number of bone chains to be simulated is multiple, for each bone chain to be simulated in the multiple bone chains to be simulated, forward dynamics simulation is respectively performed on the bones in each bone chain to be simulated starting from the current starting bone of each bone chain to be simulated.
[0094] In other words, the present disclosure can perform forward dynamics simulation on the bones in each bone chain to be simulated starting from the current starting bone of each bone chain to be simulated for each bone chain to be simulated in the at least one bone chain to be simulated.
[0095] In an example embodiment, since there are constraints between parent and child bones in the animation mechanism, no new constraint is needed, and therefore, the two bones with preset constraints in the present disclosure do not include parent and child bones.
[0096] In another example embodiment, preset constraints can be added to parent and child bones according to actual needs to achieve preset functions, that is, the two bones with preset constraints in the present disclosure can also include parent and child bones.
[0097] In the present disclosure, the bone chains to be simulated can include bone chains corresponding to objects or characters in a game, such as bone chains corresponding to clothes of game characters, and can also include bone chains corresponding to objects or characters in a film or television work, such as bone chains corresponding to clothes of animated characters in an animated film, etc. Of course, the bone chains to be simulated in the present disclosure can also include other bone chains that can be dynamically simulated, and the example embodiment does not specially limit this.
[0098] In an example embodiment, when performing forward dynamics simulation on the bone chains to be simulated for the first time, the current starting bone includes the root bone of the bone chain to be simulated. When the bone chains to be simulated include multiple bone chains, the bones in each bone chain to be simulated are respectively simulated from the root bone of each bone chain to be simulated.
[0099] For example, for each bone chain to be simulated, the root bone thereof can be taken as the first current starting bone, and then the bones in the bone chain to be simulated are traversed from top to bottom starting from the root bone, and the bones traversed are simulated by forward dynamics, that is, the bones in the bone chain to be simulated are traversed in the order of parent bone first and child bone second, and the bones traversed are simulated by forward dynamics.
[0100] Forward dynamics describes a calculation process. In the field of robotics, forward dynamics refers to the process of calculating the acceleration of a robot at the next time point from the known joint driving torque and the motion state (such as angle and angular velocity) at the previous time point, and then integrating to obtain the velocity and angle. In short, forward dynamics focuses on calculating the output (such as the motion state) of the system from the known input (such as the driving torque).
[0101] In the field of animation, forward dynamics (FK) is also known as “forward” dynamics, which refers to the process of transforming from parent to child level by level. This “forward” means that the parent can affect the child but the child cannot affect the parent. The advantage of this method is that the calculation is simple and the operation speed is fast, but the disadvantage is that the efficiency may not be as high as inverse dynamics (IK).
[0102] Inverse dynamics, as opposed to forward dynamics, in robotics, involves calculating the robot's driving forces and torques based on the known motion states of the robot at various moments (such as acceleration, velocity, and angle). Also known as "backward" or "inverse" dynamics, it calculates the transformations of the parent robot level by reversing the transformations of the child robots level by level. The advantages of inverse dynamics are high efficiency and the ability to flexibly adjust the robot's posture.
[0103] In practical applications, animators or game developers may choose to use forward dynamics or inverse dynamics, or a combination of both, depending on their needs. For example, when creating character animation, two sets of rigging might be used for the character's limbs: one using forward dynamics (FK) and the other using inverse dynamics (IK), allowing them to switch between the most suitable methods as needed during production.
[0104] For example, the following are examples Figure 4 The process of forward and backward dynamics simulations will be further explained using examples. Figure 4 The left side shows the state of a certain skeletal chain under skeletal animation. In the calculation of dynamic bones, assuming that this skeletal chain is affected by gravity, the calculation of dynamic bones is a FK (Flying Kinematics) process. The movement of one bone will drive the movement of all its child bones. For example, bending the elbow will drive the rotation of the entire arm, twisting the waist will twist the entire upper body, etc. It is a process where the parent bone drives the child bones. Therefore, the simulation of dynamic bones needs to be simulated in the traversal order from the root node to the leaf node. That is, when a certain bone calculates its own movement, it must ensure that it has already calculated the impact of the movement of all its ancestor bones on it.
[0105] Figure 4 The middle image shows the result from FK. Under the influence of gravity, the entire skeletal chain moves downwards, and we can assume one bone sinks into the ground. The goal is to modify the position of this bone to push it out of the ground and prevent it from intersecting. However, the position of the bone cannot be arbitrarily modified because the bone length is fixed and cannot be stretched. In reality, the bone's range of motion is limited to a circle centered on its parent bone and with its length as the radius (i.e.,...). Figure 4 (The dotted circle in the image). To arbitrarily adjust the position of this bone, its parent bone must also be modified to maintain the distance between the two bones. Modifying the parent bone's position will also cause the grandparent bone's position to change; this is the IK process, a process where the child bone drives the parent bone, completely opposite to FK. Furthermore, this process traces back a certain number of ancestral bones. Figure 4 The right image shows the result of applying IK to the skeletal animation. After the bone that was stuck in the ground was pushed out of the ground, its parent and grandparent bones were adjusted so that the bone could maintain its original length.
[0106] In other words, the forward dynamics simulation can be understood as updating the position according to the velocity, calculating the inertia, wind force, gravity, collision detection, etc., and then pulling it back to the correct position according to the position relationship between the bones to prevent bone deformation, etc.
[0107] In step S320, the forward dynamics simulation of the to-be-simulated bone chain is paused in the presence of a constraint on the current bone, and the current starting bone is updated according to the current staying bone.
[0108] In an exemplary embodiment, the current staying bone is determined according to the bone that currently causes the to-be-simulated bone chain to pause simulation.
[0109] For example, the bones in the to-be-simulated bone chain can be traversed to perform forward dynamics simulation on the bones in the to-be-simulated bone chain, the forward dynamics simulation of the to-be-simulated bone chain is paused in the presence of any preset constraint on the current bone of the to-be-simulated bone chain that is traversed at the time of pausing simulation, and the current starting bone is updated according to the current staying bone, i.e., the bone that is traversed at the time of pausing simulation is updated as the current starting bone.
[0110] In an exemplary embodiment, the above-described preset constraint can be established between any bones in the animation bone as needed, and the preset constraint in the present disclosure can include at least one of a distance constraint and a collision body constraint. The distance constraint is used to limit the distance between the two bones that are constrained, which can be used between two bone chains to ensure that the motion of the two bone chains does not deviate, such as the distance constraint can be used in a skirt or other flat cloth to prevent it from being significantly stretched, the distance constraint can also be used to move multiple ribbons tied together, and the distance can also be used in the scenario of a closed-loop ribbon, such as Figure 5A and Figure 5B As shown in FIG. 5, a constraint edge 51 is used to establish a constraint between the root bone and the leaf bone of a bone chain to achieve a closed-loop ribbon. Figure 5A As shown in FIG. 6, constraint edges 52 and 53 are used to establish a constraint between the two leaf bones of two bone chains that have the same position and are fixed to the root bone, which can also achieve the scenario of a closed-loop ribbon. Figure 5B The collision body constraint can be implemented by a constraint edge, which can be determined according to the connecting line between the two bones that are constrained, that is, the constraint edge can be understood as the connecting line between the two bones that are constrained. The collision body constraint can be used for collision body detection, that is, the collision body constraint considers the connecting line between the two bones that are constrained to avoid the problem of the collision body pushing away the two bone chains to cause a penetration.
[0111]
[0112] In the present disclosure, a corresponding constraint parameter can be configured for each constraint. In an exemplary embodiment, the constraint parameter can include one or more of a tolerance range, a bone weight, a priority.
[0113] The tolerance range can be measured by a minimum multiple and a maximum multiple. The measurement standard can be the distance between the two bones under the animation state. The multiple can be set by the artist, such as 0.8-1.2, indicating that the distance between the two bones under the animation state is 0.2 times the tolerance range. In addition, it can also be directly set to a certain value, such as 0, indicating that the two bones are completely attracted together, which can be used for the closed loop of the ribbon.
[0114] For example, in the present disclosure, the distance constraint can be set by the tolerance range, such as the distance constraint can be used to limit the maximum distance between the two bones with distance constraint to 1.2 times the distance between the two bones under the animation state, and the minimum distance to 0.8 times the distance between the two bones under the animation state. Of course, the distance constraint can also be directly set by the distance value, such as the above setting the distance between the two bones to 0, etc. The present exemplary embodiment does not make special limitations on this.
[0115] The bone weight is used to indicate the degree of influence of the bone under the constraint. For example, for two bones with constraints, the bone weight value of the first bone is in the range of 0-1, and the bone weight of the second bone is 1 minus the bone weight of the first bone, that is, in an exemplary embodiment, the sum of the bone weights of the two bones under the constraint is 1. If the actual distance of the two bones does not meet the distance constraint, the bone with a larger bone weight moves a larger distance. In addition, the bone with a bone weight of 0 will not be affected by the constraint, and this parameter is also set by the artist.
[0116] In an exemplary embodiment, when the two bones under the constraint have an ancestor relationship, the bone weight of the ancestor bone in the two bones is configured to 0, and the bone weight of the child bone in the two bones is configured to 1.
[0117] For example, if a bone establishes a constraint with its immediate ancestor bone, the bone weight of the bone is 1, and the bone weight of the ancestor bone is 0. This is because when solving the constraint, it is necessary to ensure that both bones have undergone FK calculation, and at this time the immediate ancestor bone cannot modify the position, so its bone weight is 0.
[0118] For the solving of the constraints, when a constraint is solved, the constraint edge is stretched or scaled, so that the bone position is moved, which can cause other constraints to be unsatisfied. Therefore, the constraints can be prioritized as needed, so that the constraints with high priority can be solved last, which will not be affected by other solved constraints, so as to ensure that the constraints with high priority are satisfied first.
[0119] For example, as described above, the preset constraint can include the bone weight described above, which is used to indicate the degree to which the bone is affected by the preset constraint. Based on this, one specific embodiment of step S320 can include: in the case that the current bone exists a constraint and the bone weight is a first preset coefficient, pausing the forward dynamics simulation for the bone chain to be simulated, and updating the current starting bone according to the current bone. The first preset coefficient can include any coefficient greater than 0. The bone weight greater than 0 indicates that the bone will be affected by the constraint, and the greater the first preset coefficient, the greater the degree to which the bone is affected by the constraint.
[0120] For example, as described above, the bone weight of 0 indicates that the bone is not affected by the constraint, and the bone will not be moved during the solving of the constraint, i.e., the bone will not change its position due to the solving of the constraint. Therefore, for a certain bone chain to be simulated, during the forward dynamics simulation, even if the current bone exists a constraint, if the bone weight of the bone is configured to 0, the forward dynamics simulation can continue to be performed on the next bone of the bone, and if the bone exists a constraint and the bone weight is not 0 (i.e., greater than 0), the forward dynamics simulation needs to be paused at the bone, i.e., the forward dynamics simulation is paused for the bones after the bone, and the current starting bone in step S310 is updated according to the bone. In this way, during the next simulation, the forward dynamics simulation continues to be performed from the updated current starting bone.
[0121] For example, another specific embodiment of step S320 can include: in the case that the current bone exists a constraint and the bone weight is a second preset coefficient, determining whether the number of child bones of the current bone is greater than 1; in the case that the number of child bones is greater than 1, pausing the forward dynamics simulation for the bone chain to be simulated, and updating the current starting bone according to each child bone, respectively, otherwise, performing the forward dynamics simulation on the child bones. The second preset coefficient can include 0 or other values representing that the bone is not affected by the constraint, which is not specially limited in the present example embodiment.
[0122] For example, in the case that the current bone exists constraint and the bone weight is 0, it can be determined whether the number of child bones of the current bone is greater than 1, so as to determine whether there is a branch bone chain, and for the branch bone chain, the forward dynamics simulation needs to be performed on the branch bone chain respectively. For example, in the case that the number of child bones of the current bone is 1, it is indicated that there is no branch bone chain at present, and then the forward dynamics simulation can be directly continued on the only child bone of the child current bone, and then it is determined whether the forward dynamics simulation needs to be paused according to whether the child bone exists constraint. In the case that the number of child bones of the current bone is greater than 1, it is indicated that there is a branch bone chain at present, and then the forward dynamics simulation can be paused, and the child bones of the current bone are all updated as the current starting bone, so that the forward dynamics simulation is performed on each branch bone chain corresponding to each child bone respectively next time.
[0123] Of course, it can also be directly determined whether the forward dynamics simulation of the bone chain to be simulated in which the current bone is located is paused according to whether the current bone exists constraint, regardless of whether the bone weight is 0, and the present exemplary embodiment does not specially limit this.
[0124] With reference to the foregoing description, the following steps are performed in the process of the forward dynamics simulation. Figure 3 In step S330, in the case that the simulation of each bone chain to be simulated is paused, a current to-be-solved set is obtained according to the constraint existing in the current stay bone of each bone chain to be simulated, and the constraint in the current to-be-solved set is solved.
[0125] In an exemplary embodiment of the present disclosure, both the distance constraint and the collision body constraint result in direct modification of the position of the bone, and therefore, the state of the ancestor bone needs to be updated by using IK. However, IK must be performed after FK. Because the position of the bone is not updated before FK, it is meaningless to use IK on it. Therefore, if the constraint needs to be solved, it must be ensured that both bones of the constraint have undergone FK calculation. In addition, the constraint solving cannot be performed after the entire FK is completed, because the modification of the state of the bone also causes the descendant nodes thereof to need to be updated, which means that the descendant nodes need to perform FK again, which may cause errors in some statistical parameters (such as speed). That is, the solving of the constraint must be performed in the process of FK, and a strategy is needed to ensure that when each constraint is solved, both bones thereof have undergone FK calculation, and the descendant bones thereof have not undergone FK calculation.
[0126] Based on this, in an example embodiment of the present disclosure, obtaining the current to-be-solved set according to the constraint of the current stay bone of each to-be-simulated bone chain comprises: determining a collection constraint set according to the constraint of the current stay bone of each to-be-simulated bone chain; and determining, from the collection constraint set, a constraint for which the constrained bones have all completed forward dynamics simulation, to obtain the current to-be-solved constraint set.
[0127] For example, in the case that each bone chain of the current to-be-simulated bone chain is paused in simulation, it is indicated that each bone chain cannot proceed with forward dynamics simulation, and the constraint affecting the forward dynamics simulation of each bone chain needs to be solved. Therefore, all constraints of the bones existing in the current simulation pause of each to-be-simulated bone chain can be collected, to obtain the collection constraint set. Since, as described above, the solving of the constraint must be performed in the FK process, and when the constraint is solved, it is required that the two bones limited by the constraint have both passed the FK calculation, and their descendant bones have not passed the FK calculation. Therefore, the constraint for which the two bones have both completed forward dynamics simulation can be found in the collection constraint set, to obtain the current to-be-solved constraint set.
[0128] As described above, the constraint in the present disclosure includes a distance constraint, which is used to limit the distance range between bones, i.e., to limit the maximum distance and the minimum distance between bones. Based on this, in an example embodiment, solving the constraint in the current to-be-solved set comprises: solving the distance constraint in the current to-be-solved set, until the solving result makes the distance between the bones limited by the distance constraint in the current to-be-solved set satisfy the distance range indicated by the distance constraint or a preset solving number of times is reached, and it is determined that the distance constraint solving is completed.
[0129] As described above, in an example embodiment, for the distance constraint limiting the distance between two bones, the distance between the two bones can be limited to a certain multiple range of the distance between the two bones in the current frame bone animation state. If the distance between the two bones bound by a certain constraint does not conform to this range, the positions of the two bones need to be corrected so as to satisfy the distance constraint. However, in general, there are usually many constraints at the same time, and solving one constraint can destroy other constraints. For example, if a skirt has many bone chains, and there are constraints between the corresponding bones of each two adjacent bone chains. When a constraint is solved, the constraint edge is stretched or zoomed to move the bone position, which can cause other constraints not to satisfy the distance range limited by the distance constraint.
[0130] Therefore, in the actual solving of the constraints, multiple iterations can be required, and finally all the constraints can be satisfied within the distance range limited by the distance constraints. That is, after the current iteration is completed, as long as the constraints are not stable, that is, there are still constraints that do not meet the constraint conditions and need to be modified, such as the distance between the bones limited by a certain constraint is still greater than the tolerance range, all the constraints need to be re-solved until the constraints are stable (that is, the distance between the bones limited by all the constraints in the constraint set to be solved meets the distance range limited by the distance constraint) or the maximum number of iterations is reached.
[0131] For example, the maximum number of iterations can be set. When the current number of iterations is less than the maximum number of iterations, if the current iteration result makes all the current constraints to be solved reach a stable state, the solving is stopped, and if the current iteration result makes all the current constraints to be solved not reach a stable state, the next iteration is continued. In the entire iteration process, the difference between the distance between the bones limited by the current constraints to be solved and the tolerance range is minimized.
[0132] If the current number of iterations is equal to the maximum number of iterations, after the current iteration is completed, whether all the previous constraints to be solved reach a stable state or not, the solving is stopped, and the solving result of the maximum number of iterations is taken as the solving result of all the constraints to be solved.
[0133] In an exemplary embodiment, when the constraint parameters include the above-mentioned priority, solving the distance constraints in the current set to be solved includes: solving the distance constraints in the current set to be solved according to the preset priority.
[0134] For example, the distance constraints with low priority can be solved first, and the distance constraints with high priority can be solved later according to the preset priority from low to high. Since the constraints solved later are not affected by the constraints solved earlier, the constraints solved later can be preferentially satisfied. That is, according to the preset priority from low to high, the constraints with high priority can be preferentially satisfied. The preset priority can be customized according to requirements, such as setting the priority of the constraint corresponding to the bone that must satisfy the distance constraint as high priority. In this way, when it is finally solved, it will not be affected by the constraints that have been solved in front.
[0135] In an exemplary embodiment, the solving of the distance constraint in the current set of distance constraints to be solved comprises: in a case that the actual distance between the bones restricted by the distance constraint is greater than the maximum distance indicated by the distance constraint, moving the bones restricted by the distance constraint in a direction of decreasing distance so that the actual distance between the bones restricted by the distance constraint is equal to the maximum distance indicated by the distance constraint; in a case that the actual distance between the bones restricted by the distance constraint is less than the minimum distance indicated by the distance constraint, moving the bones restricted by the distance constraint in a direction of increasing distance so that the actual distance between the bones restricted by the distance constraint is equal to the minimum distance indicated by the distance constraint.
[0136] In an exemplary embodiment, in a case that the distance constraint is a fixed value, such as 0 as described above, the maximum distance and the minimum distance restricted by the distance constraint are equal, i.e. both are 0. In a case that the distance restricted by the distance constraint is a distance range, such as the tolerance range as described above, the maximum distance restricted by the distance constraint is greater than the minimum distance.
[0137] In another exemplary embodiment, the solving of the distance constraint in the current set of distance constraints to be solved comprises: in a case that the actual distance between the bones restricted by the distance constraint is greater than the maximum distance indicated by the distance constraint, moving the bones restricted by the distance constraint in a direction of decreasing distance so that the actual distance between the bones restricted by the distance constraint is less than the maximum distance indicated by the distance constraint and greater than the minimum distance indicated by the distance constraint; in a case that the actual distance between the bones restricted by the distance constraint is less than the minimum distance indicated by the distance constraint, moving the bones restricted by the distance constraint in a direction of increasing distance so that the actual distance between the bones restricted by the distance constraint is greater than the minimum distance indicated by the distance constraint and less than the maximum distance indicated by the distance constraint.
[0138] In an exemplary embodiment, the manner of moving the bones restricted by the distance constraint comprises: moving the bones restricted by the distance constraint according to the bone weights so that the bones with greater bone weights are moved by a distance greater than the bones with smaller bone weights.
[0139] In the following, the solving of the distance constraint is further described with reference to Figure 6 with the tolerance range being 0.8-1.2, i.e. the minimum distance between the bones restricted by the distance constraint being 0.8 times the distance between the two bones in the current frame of the skeletal animation state and the maximum distance between the bones restricted by the distance constraint being 1.2 times the distance between the two bones in the current frame of the skeletal animation state.
[0140] In Figure 6In the middle, a distance constraint is established between two of the bones in the two bone chains. In any animation frame, the distance constraint checks the actual distance x between the two bones and the distance d between the two bones in the current frame of the bone animation. When the actual distance x is less than 0.8d, the two bones are moved outward along the direction vector of their connection by a distance such that their actual distance is 0.8d; when the actual distance is greater than 1.2d, the two bones are moved inward along the direction vector of their connection by a distance such that their actual distance is 1.2d. This ensures that the distance between the bones is always within the tolerance, but produces stretching and scaling in the transition.
[0141] In addition, the push distance of each bone is controlled by its bone weight. When the bone weight is 0, the bone does not move, only the other bone moves; the greater the bone weight, the greater the distance the bone moves. But the total distance of the two bones is constant: for the case of x < 0.8d, the total distance of movement is 0.8d-x; for the case of x > 1.2d, the total distance of movement is x-1.2d. Therefore, the more one bone moves, the less the other bone moves.
[0142] For example, the dynamic bone simulation method in the present disclosure can perform collision detection based on the constraint edge. For collision detection of the constraint edge, if the constraint edge penetrates the collision body, a push vector is calculated, and the two bones limited by the constraint edge are pushed to the appropriate position by the vector, so that the constraint edge moves outside the collision body.
[0143] In an exemplary embodiment, the collision body detection can be configured as a global variable, i.e., collision body detection can be directly set for any two bones.
[0144] In another exemplary embodiment, the collision body detection can also be configured as a local variable. That is, collision body constraints can be configured in some bones, so that collision body detection is only performed on bones configured with collision body detection.
[0145] When the value of the global variable used to represent the collision body detection is 1, collision body detection is performed on any two bones, and when the value of the global variable used to represent the collision body detection is 0, collision body detection is performed on part of the bones according to the configuration of the local variable used to represent the collision body detection.
[0146] As described above, in an example embodiment, the constraint in the present disclosure includes a collision body constraint for limiting the constraint edge outside the collision body, the constraint edge being determined according to the connecting line between the two bones, and in the case where the constraint in the present disclosure includes the distance constraint and the collision body constraint, the solving of the constraint in the current set to be solved includes: after the distance constraint is solved, determining whether the constraint edge is inside the collision body according to the distance between the constraint edge and the axis of the collision body; in the case where the constraint edge is inside the collision body, determining the moving distance of the two bones indicated by the constraint edge, and moving the bones according to the moving distance to move the constraint edge outside the collision body.
[0147] In an example embodiment, determining whether the constraint edge is inside the collision body according to the distance between the constraint edge and the axis of the collision body includes: in the case where the length of the perpendicular line between the constraint edge and the axis of the collision body is less than the radius of the collision body, determining that the constraint edge is inside the collision body.
[0148] For example, a vector perpendicular to the straight line where the constraint edge is located and the straight line where the axis of the collision body is located can be found, and then the constraint edge and the collision body are projected onto the plane represented by the vector, the first intersection point of the constraint edge and the axis of the collision body on the plane is found, a perpendicular line is drawn from the constraint edge at the first intersection point, and the length of the perpendicular line between the constraint edge and the collision body is determined according to the line segment between the second intersection point of the perpendicular line and the axis of the collision body and the first intersection point.
[0149] Of course, the length of the perpendicular line between the constraint edge and the axis of the collision body can also be calculated according to other methods capable of determining the shortest line segment between two straight lines, which are not particularly limited in the present example embodiment.
[0150] In an example embodiment, determining the moving distance of the two bones indicated by the constraint edge includes: determining the moving distance of the two bones indicated by the constraint edge according to the bone weights of the two bones indicated by the constraint edge. In an example embodiment, determining the moving distance of the two bones indicated by the constraint edge according to the bone weights of the two bones indicated by the constraint edge includes: in the case where the bone weights of the two bones indicated by the constraint edge are equal, determining the length of the perpendicular line between the constraint edge and the axis of the collision body; and determining the moving distance of the two bones indicated by the constraint edge according to the difference between the radius of the collision body and the length of the perpendicular line.
[0151] For example, in the case where the bone weights of the two bones are equal, when the collision detection is performed according to the constraint edges of the two bones, if it is determined that the constraint edges of the two bones are inside the collision body, the difference between the radius of the collision body and the length of the perpendicular line is determined, and then the two bones are both pushed outward by a distance corresponding to the difference in the direction away from the axis of the collision body, so that the constraint edges of the two bones are located outside the collision body.
[0152] In an example embodiment, determining the moving distance of the two bones indicated by the constraint edge according to the bone weights of the two bones indicated by the constraint edge comprises: in the case that the bone weights of the two bones indicated by the constraint edge are not equal, determining the length of the perpendicular line between the constraint edge and the axis of the collision body; determining the difference between the radius of the collision body and the length of the perpendicular line; determining the first moving distance of the first bone in the range greater than 0 and less than the difference; and determining the second moving distance of the second bone according to the difference, the first moving distance, the distance from the first bone to the target point, and the distance from the second bone to the target point, the target point being determined according to the nearest point of the constraint edge and the central axis of the collision body; wherein the first bone is the bone with smaller bone weight in the two bones indicated by the constraint edge, and the second bone is the bone with larger bone weight in the two bones indicated by the constraint edge.
[0153] For example, in the case that the bone weights of the two bones are not equal, the first moving distance of the bone with smaller weight can be determined by interpolation in the interval [0, r], where r represents the difference between the radius of the collision body and the length of the perpendicular line. If the interpolation result of the first moving distance is x, x satisfies greater than or equal to 0 and less than or equal to r, then the second moving distance of the bone with larger bone weight in the two bones can be determined according to the following formula (1):
[0154]
[0155] In formula (1), r is the difference between the radius of the collision body and the length of the perpendicular line, the length of the perpendicular line refers to the length of the perpendicular segment between the constraint edge and the axis of the collision body, a is the distance from the first bone to the target point, b is the moving distance of the second bone to the target point, x is the first moving distance of the first bone, and the target point is the nearest point of the constraint edge and the central axis of the collision body, that is, the intersection of the perpendicular segment of the constraint edge and the central axis of the collision body.
[0156] Next, taking the collision between the constraint edge and the capsule body as an example, that is, the collision body is a capsule body, the specific implementation of the collision body constraint calculation when the constraint edge is located inside the collision body is further described in combination with Figure 7A , Figure 7B and Figure 7C .
[0157] For collision detection of the constraint edge, since the calculation amount is large, multiple iterations can not be performed, but can be performed after the entire distance constraint calculation. When the constraint edge and the capsule body are interpenetrated, it can be represented as shown in Figure 7A , Figure 7A where the capsule body is represented by an elliptical shape, Figure 7AThe line segment in the figure is the constraint edge. A vector perpendicular to the line on which the constraint edge lies and the line on which the capsule body axis lies can be found. Then the constraint edge and the capsule body are projected onto the plane represented by the vector. The intersection of the constraint edge and the capsule body axis on the projection plane is found (the black dot in the figure). This intersection is recorded as the first intersection point. In the original view (i.e., the unprojected view), a perpendicular line is drawn at the first intersection point of the constraint edge. The perpendicular line is extended so that it intersects the collision body axis. The intersection is recorded as the second intersection point. The length of the line segment between the first intersection point and the second intersection point is the length of the perpendicular line between the constraint edge and the collision body. Figure 7A
[0158] If the influence weights of the two bones are equal, i.e., both are 0.5, then both bones push out a distance of the capsule body radius minus the length of the perpendicular line. That is, in this case, the movement distances of the two bones are both the capsule body radius minus the length of the perpendicular line. Otherwise, the distances of the two bones to the first intersection point are determined, and then, according to the theorem of similar triangles, the distances by which the bones are pushed out are determined.
[0159] For example, as shown in FIG. 6, AB is the constraint edge, point O is the closest point of the constraint edge to the center axis of the capsule body, i.e., the black dot in the figure, which is the first intersection point described above, and point P is a point on the capsule body, i.e., the intersection of the perpendicular line in the figure and the capsule body, which is the second intersection point described above. Therefore, the line segment OP is perpendicular to the constraint edge AB. r represents the length of the line segment OP, i.e., the radius of the capsule body minus the length of the perpendicular line. a and b are the lengths of the line segments AO and OB, i.e., the distances of the two bones to point O. When the weights of the two bones are both 0.5, A and B are both pushed out by a distance of r, i.e., A is pushed to M and B is pushed to N. If the weights of the two bones are not equal, the movement distances of the bones are calculated according to the theorem of similar triangles. Figure 7C Figure 7A The line segment AE is an extreme case, i.e., the weight of bone A is 0 and the weight of bone B is 1. Only bone B can move in this case. It is necessary to ensure that, after the movement, the original point O is outside the capsule body. In this case, the constraint edge can still be partially inside the capsule body, but it is basically correct and the collision effect can be generated, i.e., point O can be moved to point P. In this case, point A is stationary and point B is moved to point E. Figure 7B
[0160] The line segment AE is an extreme case, i.e., the weight of bone A is 0 and the weight of bone B is 1. Only bone B can move in this case. It is necessary to ensure that, after the movement, the original point O is outside the capsule body. In this case, the constraint edge can still be partially inside the capsule body, but it is basically correct and the collision effect can be generated, i.e., point O can be moved to point P. In this case, point A is stationary and point B is moved to point E.
[0161] The segment CD is the case that the bone weight of A is 0-0.5 intermediate value and the bone weight of B is 0.5-1 intermediate value. At this time, the A point moves to the C point and the B point moves to the D point. It can be easily found that the triangle APC and the triangle EPD are similar triangles. Therefore, AC / DE=AP / PE. Since the triangle AOP and the triangle ABE are also similar triangles, AP / AE=A0 / AB, which can be converted into AP / PE=A0 / OB=a / b. Therefore, AC / DE=a / b. This means that when the state of the segment AE is, the A point moves x distance upward, and the E point moves x*b / a downward. Then, the limit length, i.e. the length of AF, is also calculated by the similar triangle, i.e. OB / AB=OP / AF, and AF=r(a+b) / b is obtained. Similarly, BE=r(a+b) / a can also be calculated. It can be verified that the moving distance of the A point to the F point is in the relationship of a / b with the moving distance of the E point to the B point.
[0162] Therefore, the moving distance can be calculated according to the bone weight of the A point and the B point. Taking the A point as an example, when the bone weight of the A point is 0, the moving distance is 0; when the bone weight of the A point is 1, the moving distance is r(a+b) / b. In addition, an intermediate state needs to be met, i.e. when the weight is 0.5, the moving distance is r, even if AB is in the state of MN. Based on this, taking the A point in the state of MN as an example, when the bone weight corresponding to the bone represented by the A point is less than 0.5, the moving distance of the bone represented by the A point can be determined by interpolation between [0, r]; when the bone weight corresponding to the bone represented by the A point is greater than 0.5, the moving distance of the bone represented by the A point can be determined by interpolation between [r, r(a+b) / b]. Figure 7C
[0163] In an exemplary embodiment, the interpolation of the moving distance of the bone with a large bone weight can be performed first, or the interpolation of the moving distance of the bone with a small bone weight can be performed first. After the interpolation of the moving distance of one of the bones is performed, the moving distance of the other bone can be determined according to the moving distance of the first bone. Taking the interpolation of the moving distance of the A point in the state of MN as an example, no matter whether the bone corresponding to the A point is the bone with a large weight or the bone with a small weight in the two constrained bones, as long as the interpolation result is determined, such as the interpolation result of the moving distance of the bone corresponding to the A point is x, i.e. the moving distance of the A point is x, the moving distance of the B point corresponds to the length of the segment BE minus the length of the segment DE in the state of MN, i.e. the moving distance of the B point can be determined according to the above formula (1). Figure 7C Figure 7C
[0164] In another example embodiment, in the case that the constraints in the present disclosure include collision body constraints but not distance constraints, the collision body constraints can be directly solved without the need to solve the collision body constraints after the distance constraints are solved. In the case that both exist, the distance constraints can be solved first, and then the collision body constraints can be solved according to the descriptions of the above example embodiments and Figure 7A 、 Figure 7B and Figure 7C to make the constraint edges outside the collision body and avoid penetration.
[0165] In an example embodiment, the collision body can include the capsule body described above, and can also include other types of collision bodies such as a sphere, a mesh, etc., and the present example embodiment does not make special limitations on this.
[0166] In an example embodiment, solving the constraints in the current set to be solved includes, after moving the constraint edge outside the collision body, performing inverse dynamics simulation on the ancestor bones of the current resting bone according to the current position of the current resting bone and a preset influence depth.
[0167] For example, after the distance constraints and the collision body constraints are solved, the bone state of the bone currently performing constraint solving, i.e., the current resting bone, has changed, so inverse dynamics simulation can be performed according to the current position of the current resting bone and a preset influence depth to update the state of the ancestor bones of the current resting bone. The preset influence depth indicates how many generations of ancestor bones are affected by the motion of the current bone, and the preset influence depth can be customized by an artist according to requirements, and the present example embodiment does not make special limitations on this.
[0168] The IK algorithm can use FABRIK (Forward and Backward Reaching Inverse Kinematics), can use CCDIK (Cyclic Coordinate Descent), or can use other IK algorithms, and the present example embodiment does not make special limitations on this.
[0169] When performing IK, it can trace up to the multi-branch bone, can trace up to the constrained bone, or can not trace up to the multi-branch bone or the constrained bone, and the present example embodiment does not make special limitations on this.
[0170] That is, in one example embodiment of the present disclosure, when the constraints include distance constraints and collision body constraints, the distance constraints can be solved first, and after the distance constraints are solved, the collision body detection is performed to solve the collision body constraints, and after the collision body constraints are solved, the IK calculation is performed on the bones affected by the current solved constraints, so as to complete a complete solving process.
[0171] Next, with reference to Figure 3 In step S340, when there is no unsolved constraint for the current stay bone of the to-be-simulated bone chain, the steps S310 to S330 described above are repeatedly performed on the to-be-simulated bone chain to continue the forward dynamics simulation on the to-be-simulated bone chain from the updated current start bone until the leaf bone in the to-be-simulated bone chain completes the forward dynamics simulation, and it is determined that the to-be-simulated bone chain simulation is completed. In one example embodiment, the dynamic bone simulation is determined to be completed when each to-be-simulated bone chain simulation is completed.
[0172] In one example embodiment, when there is an unsolved constraint for the current stay bone of each to-be-simulated bone chain, the remaining unsolved constraints are determined to be invalid constraints, and the forward dynamics simulation is performed on the bones not traversed in each to-be-simulated bone chain until the leaf bone in the to-be-simulated bone chain completes the forward dynamics simulation, and it is determined that the to-be-simulated bone chain simulation is completed, wherein the invalid constraints do not pause the forward dynamics simulation of the to-be-simulated bone chain.
[0173] For example, when there is an unsolved constraint for the current stay bone of the to-be-simulated bone chain, the to-be-simulated bone chain cannot continue to proceed with the forward dynamics simulation, and when each to-be-simulated bone chain cannot continue to proceed with the forward dynamics simulation, it is determined that a deadlock occurs. Deadlocks mainly occur in the case of Figure 8A self-dependence as shown in Figure 8B cross-dependence as shown in Figure 8C circular dependence as shown in.
[0174] For self-dependence, a constraint is established between a bone and its direct ancestor bone, and for this case, a preprocessing is performed, that is, the bone weight of the bone is set to 1, and the bone weight of the direct ancestor bone is set to 0. The bone chain does not stay on the bone with a bone influence weight of 0 during the forward dynamics simulation, and therefore, the deadlock caused by self-dependence can be avoided in advance.
[0175] As shown in Figure 8B Cross-dependence includes the case that a constraint exists between a preceding bone of a first root bone chain and a following bone of a second root bone chain, and a constraint exists between a following bone of the first root bone chain and a preceding bone of the second root bone chain, as shown in Figure 8CAs shown, the cyclic dependency includes the case that there exists a constraint between the preceding bone of the first bone chain and the following bone of the second bone chain, there exists a constraint between the preceding bone of the second bone chain and the following bone of the third bone chain, and there exists a constraint between the preceding bone of the third bone chain and the following bone of the first bone chain. For the deadlock caused by the cross dependency and the cyclic dependency, the remaining uncalculated constraints can be discarded, and for each bone chain to be simulated, the remaining bones not subjected to FK are directly subjected to FK calculation, and after FK simulation of all bones in each bone chain to be simulated is completed, it is determined that the dynamic bone simulation is ended.
[0176] In an exemplary embodiment, as described previously, the to-be-calculated set is determined according to the constraints in the constraint collection for which the constrained bones have all completed forward dynamic simulation. Taking the case of three bone chains to be simulated as an example, suppose that the traversal is paused when the first bone chain to be simulated is traversed to the second bone, the second bone chain to be simulated is simulated to the third bone, and the third bone chain to be simulated is simulated to the third bone. The constraints existing for the second bone of the first bone chain to be simulated include constraint 1 and constraint 2, the constraints existing for the third bone of the second bone chain to be simulated include constraint 3 and constraint 4, and the constraints existing for the third bone of the third bone chain to be simulated include constraint 5, constraint 6, and constraint 7. At this time, there are a total of seven constraints in the constraint collection, namely, constraint 1, constraint 2, constraint 3, constraint 4, constraint 5, constraint 6, and constraint 7.
[0177] If among the seven constraints, two of constraint 1, constraint 2, constraint 3, constraint 4, and constraint 5 have both completed forward dynamic simulation, and at least one of the bones constrained by constraint 6 and constraint 7 is a bone after the current paused bone, so at least one of the bones constrained by constraint 6 and constraint 7 has not been subjected to forward dynamic simulation, then the to-be-calculated set includes five constraints, namely, constraint 1, constraint 2, constraint 3, constraint 4, and constraint 5. Since constraint 6 and constraint 7 are not in the to-be-calculated set, they are not calculated. After the current to-be-calculated set is calculated, constraint 6 and constraint 7 are uncalculated constraints.
[0178] Since the constraints 6 and 7 are not solved, that is, the current stay bone of the third to-be-simulated bone chain (i.e., the 3rd bone of the third to-be-simulated bone chain) has an unsolved constraint set of the constraints 6 and 7, and the current stay bone of the first to-be-simulated bone chain (i.e., the 2nd bone of the first to-be-simulated bone chain) has the constraints 1 and 2 that have been solved, and there is no unsolved constraint, and the current stay bone of the second to-be-simulated bone chain (i.e., the 3rd bone of the second to-be-simulated bone chain) has the constraints 3 and 4 that have been solved, and there is also no unsolved constraint. Therefore, the first to-be-simulated bone chain and the second to-be-simulated bone chain can continue to traverse the bones downward to continue the forward dynamics simulation, and the third to-be-simulated bone chain cannot continue to traverse downward and still needs to be paused at the 3rd bone, and waits for the next collection of constraints and the solving of the to-be-solved set to be completed, and then determines whether the current stay bone of each to-be-simulated bone chain has an unsolved constraint to determine which to-be-simulated bone chain can continue to perform the forward dynamics simulation downward.
[0179] In an exemplary embodiment of the present disclosure, the unsolved constraint can include a constraint that is not determined into the to-be-solved set. This is because the constraint determined into the to-be-solved set will definitely be solved, and even if all the constraints in the to-be-solved set cannot be satisfied at the same time, the solving result of the constraint in the to-be-solved set will be determined when the constraint solving times are reached. In other words, the unsolved constraint includes the constraint that belongs to the collected constraint set but does not belong to the to-be-solved set and the constraint that is not collected. The constraint that is not collected can be understood as a constraint that exists between two bones that are both located after the current stay bone in the process of performing the forward dynamics simulation.
[0180] An exemplary embodiment of the present disclosure is shown in a flowchart of a method for solving a constraint. Referring to FIG. 10, Figure 9 An exemplary embodiment of the present disclosure is shown in a flowchart of a method for solving a constraint. Referring to FIG. 10, Figure 9 The method can include steps S910 to S950. Wherein:
[0181] In step S910, the constraints are collected.
[0182] In an exemplary embodiment of the present disclosure, based on the traversal strategy, not all constraints are solved each time, but part of the constraints are collected and solved.
[0183] For example, as described above, in this disclosure, each constraint needs to be solved by ensuring that both of its bones have been calculated using the Free-Kestrel (FK) method, and that none of its descendant bones have been calculated using the FK method. The traversal strategy of this disclosure may include the following: (1) Each bone chain starts the FK simulation from the root node and stops when it encounters a constrained bone with an influence weight greater than 0. Since bones with an influence weight of 0 will not move and will not affect their descendant bones, there is no need to stop, reducing the possibility of deadlock. If a bifurcated bone is encountered, it becomes multiple child bone chains to be simulated separately. (2) After all bone chains stop at the constrained bone, all constraints are traversed, and constraints that have been calculated using the FK method for both bones are collected. Then, these collected constraints are solved. The solution process is steps S920 to S940 below. (3) After solving the collected constraints, all bone chains (including bifurcated child bone chains) are traversed. If the bone currently stopped by a bone chain is no longer affected by any constraints, then it can continue to perform the FK simulation downwards until it encounters a constrained bone again and then pauses the FK simulation. (4) If a skeletal chain has simulated all bones during the FK process, then the simulation of that skeletal chain is complete. (5) If all bones have been simulated, then the entire physics simulation ends. (6) If all skeletal chains remain stationary and no skeletal chain can continue simulating, then the deadlock situation described above has occurred. For deadlock, the remaining unsolved constraints can only be discarded, the remaining bones can be calculated using FK, and then the simulation can be completed.
[0184] In step S920, the collected distance constraints are solved by distance limitation calculation.
[0185] In step S930, it is determined whether all collected constraints have reached a stable state or whether the maximum number of iterations has been reached. If not, it is necessary to return to step S920 to recalculate the currently collected constraints; if so, proceed to step S940.
[0186] In step S940, collision detection calculations are performed on all constrained edges.
[0187] In step S950, IK calculations are performed on the bones affected by the collected constraints.
[0188] Based on the traversal strategy in step S910 above, the complete dynamic simulation process is as follows: Figure 10 As shown, Figure 10 A flowchart illustrating another method for dynamic skeletal simulation according to an exemplary embodiment of this disclosure is shown. (Reference) Figure 10 The method may include steps S101 to S108, wherein:
[0189] In step S101, the root nodes of all the skeleton chains to be simulated are recorded in the starting node array as starting nodes.
[0190] For example, the start node represents the start position of a bone chain, and also represents the stay position of the current bone chain after the last traversal. In the first FK simulation traversal, the start node is the root node.
[0191] In step S102, all bone chains where the start nodes are located are traversed by the traversal strategy, and the start node array is updated.
[0192] For example, the updated start node array records the current stay position of each bone chain, or the start position of the multiple bone chains differentiated after the bifurcation, such as multiple sub-bones.
[0193] A specific embodiment of step S102 is shown in Figure 11 . Figure 11 A flowchart showing the implementation method of the traversal strategy of a bone chain in an exemplary embodiment of the present disclosure is shown. Referring to Figure 11 , the method can include steps S1101 to S1110. Among them:
[0194] In step S1101, the bone traversal is performed along the bone chain where the start node is located.
[0195] In step S1102, the forward dynamics calculation of the current bone is performed.
[0196] For example, the forward dynamics calculation is a conventional physical calculation, such as updating the position according to the speed, calculating inertia, wind force, gravity, collision detection, etc., and then pulling it back to the correct position according to the position relationship between the bones, preventing bone deformation, etc.
[0197] In step S1103, it is judged whether it is a leaf node. If yes, it means that the current bone chain has been completely simulated, and step S1110 is entered. If not, step S1104 is entered.
[0198] In step S1104, it is judged whether the current bone is a constrained bone and the influence weight is greater than 0. If yes, step S1107 is entered, which means that the current bone needs to stay and cannot be further FK. This is because for a constraint, it needs to satisfy that both of its associated bones have FK, but the descendant bones do not have FK. If not, step S1105 is entered.
[0199] In step S1105, it is judged whether the number of sub-bones of the current bone is greater than 1. If yes, step S1108 is entered, which means that the bone chain is divided into several sub-bone chains, and the FK of these sub-bone chains needs to be simulated respectively, so the FK cannot be continued. If no, i.e. there is only one sub-bone, the FK can be continued, i.e. step S1106 is entered.
[0200] In step S1106, the current bone is changed to the only sub-bone. Then step S1102 is entered to perform FK calculation on the bone.
[0201] In step S1107, the current bone is recorded in the new start node array.
[0202] For example, after the current bone is recorded in the new start node array, the start node array is updated according to the current bone, so that in the next iteration, the bone chain is iterated from the bone, and then step S1109 is entered.
[0203] In step S1108, all sub-bones are recorded in the new start node array.
[0204] For example, after all sub-bones are recorded in the new start node array, the start node array is updated according to all sub-bones, so that in the next iteration, each sub-bone chain is iterated separately.
[0205] In step S1109, the forward dynamics simulation is temporarily stopped.
[0206] For example, after step S109 is entered, the forward dynamics simulation is temporarily stopped.
[0207] In step S1110, the current bone chain simulation is ended.
[0208] Through the above steps S1101 to S1110, the physical simulation of any bone chain can be realized.
[0209] Continuing to refer to Figure 10 In step S103, it is judged whether there is a bone chain that has been subjected to forward dynamics calculation. If no bone chain has been subjected to FK calculation, it means that they cannot continue to be simulated, and the above deadlock occurs, so step S107 is entered. If there is no deadlock, step S104 is entered.
[0210] In step S104, it is judged whether all bone chains have been simulated. If yes, step S108 is entered. If no, step S105 is entered.
[0211] For example, it can be judged whether the new start node array is empty. If it is empty, it means that all bone chains have been simulated.
[0212] In step S105, all constraints are traversed, and constraints in which both bones have been FKed are collected, and then these collected constraints are solved.
[0213] For example, step S105 is the entire process of collecting constraints, and repeatedly iterating distance limit solving, collision detection calculation, and IK calculation of affected bones, as described above. Figure 9
[0214] In step S106, the new starting node array replaces the original starting node array.
[0215] Step S106 is to allow the subsequent traversal strategy to start from the position at which each bone chain stops or the starting position of the differentiated bone chain. Then, step S102 is entered again.
[0216] In step S107, a deadlock occurs, the remaining constraints are discarded, and forward dynamics calculation is performed on the remaining bone chains.
[0217] Step S107 is a finishing work performed after all constraints cannot be solved, to ensure that all bones will participate in FK calculation.
[0218] In step S108, the simulation is completed.
[0219] The results of the entire traversal strategy described above can be referred to the example of Figure 12 In Figure 12 , the black points represent bones that have not been FKed, the gray points represent the stopping bones (which have been FKed), the white hollow points represent bones that have been FKed, the black lines represent constraints that have not been solved, and the gray lines represent constraints that have been solved. As can be seen from the figure, only when neither end of the constraint is a black point can the constraint be solved; and the gray stopping point can continue to FK downward after all associated constraints have been solved.
[0220] An example of Figure 13 shows a flowchart of another dynamic bone simulation method in an example embodiment of the present disclosure. Referring to Figure 13 , the method can include steps S1310 to S1350. Among them:
[0221] In step S1310, in response to a bone constraint addition operation, the bones in the target bone chain in which the added constraint is located are traversed from the current starting bone of the target bone chain.
[0222] In step S1320, if there is a constraint on the current skeleton being traversed, the traversal of the target skeleton chain is paused, and the current start skeleton is updated according to the current pause skeleton, which is determined according to the skeleton at which the traversal is paused;
[0223] In step S1330, if the traversal of each target skeleton chain is paused, constraints existing on the current pause skeleton are marked, if the bones restricted by the constraints have all been traversed.
[0224] In step S1340, if there is no unmarked constraint on the current pause skeleton, the traversal of the target skeleton chain corresponding to the current pause skeleton is continued to repeat the above process.
[0225] In step S1350, the addition result of the bone constraint is determined according to the marking of the constraints, and the dynamic bone simulation is performed according to the addition result.
[0226] According to the dynamic bone simulation method in the present disclosure, the added bone constraint can be checked to avoid the occurrence of subsequent deadlocks as much as possible.
[0227] In an exemplary embodiment, in response to the bone constraint addition operation, the bones in the target skeleton chain in which the bone constrained by the added constraint is located are traversed from the current start skeleton of the target skeleton chain, including: in response to the bone constraint addition operation, checking whether the to-be-added bone constraint is legal; if the to-be-added bone constraint is legal, the bones in the target skeleton chain in which the bone constrained by the added constraint is located are traversed from the current start skeleton of the target skeleton chain.
[0228] In an exemplary embodiment, checking whether the to-be-added bone constraint is legal includes: checking whether the bones restricted by the to-be-added bone constraint are the same bone; and / or checking whether the bones restricted by the to-be-added bone constraint have a parent-child relationship.
[0229] In an exemplary embodiment, if the to-be-added bone constraint is legal, the bones in the target skeleton chain in which the bone constrained by the added constraint is located are traversed from the current start skeleton of the target skeleton chain, including: if the to-be-added bone constraint is legal, checking whether the bones restricted by the to-be-added bone constraint belong to the same skeleton chain; if the bones restricted by the to-be-added bone constraint do not belong to the same skeleton chain, the bones in the target skeleton chain in which the bone constrained by the added constraint is located are traversed from the current start skeleton of the target skeleton chain.
[0230] In an exemplary embodiment, Figure 13The dynamic bone simulation method further comprises:
[0231] In the case where the bones to be added with the bone constraint belong to the same bone chain, the bone weight of the ancestor bone in the restricted bones is configured as 1, and the bone weight of the child bone in the restricted bones is configured as 0, the bone weight being used to indicate the degree of influence of the bone constraint.
[0232] In an exemplary embodiment, the addition result of the bone constraint is determined according to the marking of the constraint, and the dynamic bone simulation is performed according to the addition result, which comprises: adding the marked constraint as a valid bone constraint, and adding the unmarked constraint as an invalid bone constraint, and performing the dynamic bone simulation according to the valid bone constraint.
[0233] For example, after marking the state of the bone constraint to be added as valid or invalid, the dynamic bone simulation is performed according to the state of the bone constraint based on the above-mentioned Figure 3 The dynamic bone simulation method performs actual dynamic bone simulation. That is, for the valid bone constraint, the forward dynamics simulation needs to be paused, and for the invalid bone constraint, it is directly considered that the constraint does not exist.
[0234] In an exemplary embodiment, Figure 13 The dynamic bone simulation method further comprises: generating prompt information of the invalid bone constraint, and displaying the prompt information of the invalid bone constraint on the bone constraint adding interface.
[0235] In an exemplary embodiment, Figure 14 A flowchart of a method for adding a bone constraint in an exemplary embodiment of the present disclosure is shown. Referring to Figure 14 The method can comprise steps S1401 to S1408. Wherein:
[0236] In step S1401, two bones are selected to add a constraint.
[0237] In step S1402, the legality of the constraint is checked.
[0238] For example, if the two bones bound by the constraint are the same bone or the two bones bound by the constraint are in a parent-child relationship, the constraint is considered to be illegal. Because in these two cases, the constraint has no practical significance, because they are directly driven and maintain a fixed distance from each other. If it is legal, go to step S1404; if it is not legal, go to step S1403.
[0239] In step S1403, the constraint is discarded.
[0240] For example, for the illegal constraint, it is directly discarded, and feedback is given to the user that the constraint is illegal. Thus the flow ends.
[0241] In step S1404, it is checked whether the two bones bound by the constraint are in the same bone chain. If yes, step S1405 is entered, otherwise step S1406 is entered.
[0242] Step S1404 is to find the self-dependent case, i.e. the case that a bone is bound to its ancestor bone.
[0243] In step S1405, the bone weight close to the root node is set to 0, and the bone weight far from the root node is set to 1.
[0244] In step S1406, it is checked whether there is a deadlock case.
[0245] For example, for the check of the deadlock case, the aforementioned traversal strategy is actually used, except that FK, IK, collision detection, etc. are not really calculated, but only traversed once to check whether all bone chains can be traversed, e.g. by the aforementioned marking method to determine whether the constraint is traversed, the marked constraint is the traversed constraint, and if there is an unmarked constraint after the traversal ends, it means that there is a deadlock. If there is a deadlock, step S1407 is entered, otherwise step S1408 is entered.
[0246] In step S1407, the following constraints of the deadlock are set to invalid constraints, and are identified to the user.
[0247] All the constraints following the deadlock are the remaining constraints that are not traversed, which cannot be solved and cannot continue FK. At this time, they must be set to invalid, for example, in a game, the invalid constraint is directly skipped in the game running process to prevent the deadlock case. In addition, these invalid constraints are fed back to the user, such as using a red line to alert the user that the constraint has a deadlock and needs to be checked and modified.
[0248] In step S1408, the constraint is added.
[0249] For example, the added constraint can be valid or invalid. The invalid constraint is reserved to allow the user to adjust in time.
[0250] The dynamic bone simulation method in the present disclosure can be applied to more complex situations. Taking cloth simulation as an example, the dynamic bone based on tree structure simulation in the related art can only have a good simulation on the strip-shaped ribbon, and the simulation effect on the surface cloth is poor. In addition, in actual application, more complex cloth models may appear, such as a ring-shaped ribbon, or the two sides of a garment need to be fixed with a button, and the like, which cannot be solved by the tree structure simulation. The dynamic bone simulation method in the present disclosure can add constraints between any bones, so it can simulate more complex situations and improve the richness and authenticity of dynamic bone simulation.
[0251] At the same time, the dynamic bone simulation method in the present disclosure can achieve more accurate collision. For the bone chains of the tree structure, there is no edge between them in the transverse direction, so the two bone chains can completely slide from the two sides of a collision body, making the collision body very easy to penetrate the model. If a constraint is added between the bones of the two bone chains, the constraint edge can be used as an actual edge for collision detection. In this case, even if the two bones pass from the two sides of the collision body, the constraint edge will be corrected when passing through the collision body, pushing it out of the collision body, so that the two bones will also correct the position with the movement of the constraint edge, thereby preventing penetration.
[0252] In addition, in the present disclosure, when an artist adds a constraint between bones, the constraint can be drawn in the form of Debug, so that the dynamic bone simulation method based on the mesh structure in the present disclosure can be better embodied, so that the user can actually edit a mesh structure, and can also view the stretching of the constraint edge and the collision response in real time, so as to decide whether to adjust the related parameters. Figure 15 As shown in the figure, the leg is a capsule collision body, the constraint edge is 151, and the bone is 152. It can be seen that the constraint edge collides with the capsule, and the existence of the constraint can obviously keep the distance between the bone chains within a stable interval.
[0253] In addition, it should be noted that the above figures are only schematic illustrations of the processes included in the method according to the exemplary embodiments of the present disclosure, and are not for limiting purposes. It is easy to understand that the processes shown in the above figures do not indicate or limit the time sequence of the processes. In addition, it is also easy to understand that these processes can be executed synchronously or asynchronously in multiple modules, for example.
[0254] Further, the exemplary embodiments of the present disclosure also provide a dynamic bone simulation device. Referring to Figure 16As shown, the dynamic bone simulation device 1600 comprises the following program modules: a forward dynamics simulation module 1610 configured to perform forward dynamics simulation on bones in a bone chain to be simulated, starting from a current starting bone of the bone chain to be simulated, wherein there are preset constraints between at least two bones in the bone chain to be simulated; a first updating module 1620 configured to pause forward dynamics simulation on the bone chain to be simulated if a current bone has constraints, and update the current starting bone according to the current staying bone; a to-be-solved set determination module 1630 configured to, when each bone chain to be simulated is paused, obtain a current to-be-solved set according to constraints existing in all current staying bones of each bone chain to be simulated, and solve the constraints in the current to-be-solved set; and a first repeating module 1640 configured to, when the current staying bone of the bone chain to be simulated has no unsolved constraints, repeat the operations in the above modules starting from the updated current starting bone of the bone chain to be simulated until a leaf bone in the bone chain to be simulated completes forward dynamics simulation, and determine that simulation of the bone chain to be simulated is completed; wherein, when performing forward dynamics simulation on the bone chain to be simulated for the first time, the current starting bone comprises a root bone of the bone chain to be simulated.
[0255] In an exemplary embodiment, based on the foregoing embodiment, the obtaining of the current to-be-solved set according to the constraints existing in the current staying bones of each bone chain to be simulated comprises: determining a collection constraint set according to the constraints existing in the current staying bones of each bone chain to be simulated; and determining constraints in which all constrained bones have completed forward dynamics simulation from the collection constraint set to obtain a current to-be-solved constraint set.
[0256] In an exemplary embodiment, based on the foregoing embodiment, the constraints comprise distance constraints for limiting a distance range between bones; and the solving of the constraints in the current to-be-solved set comprises:
[0257] solving the distance constraints in the current to-be-solved set until the solving result causes distances between bones limited by the distance constraints in the current to-be-solved set to all satisfy distance ranges indicated by the distance constraints or a preset solving number of times is reached, and determining that the distance constraint solving is completed.
[0258] In an exemplary embodiment, based on the foregoing embodiment, the solving of the distance constraints in the current to-be-solved set comprises: solving the distance constraints in the current to-be-solved set according to a preset priority.
[0259] In an example implementation, based on the foregoing embodiment, the solving the distance constraint in the current set to be solved includes: in a case where an actual distance between the bones limited by the distance constraint is greater than a maximum distance indicated by the distance constraint, moving the bones limited by the distance constraint in a direction of decreasing distance so that the actual distance between the bones limited by the distance constraint is equal to the maximum distance indicated by the distance constraint; in a case where the actual distance between the bones limited by the distance constraint is less than a minimum distance indicated by the distance constraint, moving the bones limited by the distance constraint in a direction of increasing distance so that the actual distance between the bones limited by the distance constraint is equal to the minimum distance indicated by the distance constraint.
[0260] In an example implementation, based on the foregoing embodiment, the manner of moving the bones limited by the distance constraint includes: moving the bones limited by the distance constraint according to bone weights so that a moving distance of a bone with a large bone weight is greater than a moving distance of a bone with a small bone weight.
[0261] In an example implementation, based on the foregoing embodiment, the constraint includes a collision body constraint for limiting a constraint edge to be located outside a collision body, the constraint edge being determined according to a connecting line between two bones, and the solving the constraint in the current set to be solved includes: after the distance constraint is solved, determining whether the constraint edge is located inside the collision body according to a length of a perpendicular line between the constraint edge and an axis of the collision body; in a case where the constraint edge is located inside the collision body, determining a moving distance of the two bones indicated by the constraint edge, and moving the bones according to the moving distance to move the constraint edge to the outside of the collision body.
[0262] In an example implementation, based on the foregoing embodiment, the determining whether the constraint edge is located inside the collision body according to a distance between the constraint edge and the axis of the collision body includes: in a case where the length of the perpendicular line between the constraint edge and the axis of the collision body is less than a radius of the collision body, determining that the constraint edge is located inside the collision body.
[0263] In an example implementation, based on the foregoing embodiment, the determining the moving distance of the two bones indicated by the constraint edge includes: determining the moving distance of the two bones indicated by the constraint edge according to bone weights of the two bones indicated by the constraint edge.
[0264] In an example embodiment, based on the foregoing embodiment, the determining the moving distance of the two bones indicated by the constraint edge according to the bone weights of the two bones indicated by the constraint edge comprises: in the case that the bone weights of the two bones indicated by the constraint edge are equal, determining the length of the perpendicular line between the constraint edge and the axis of the collision body; and determining the moving distance of the two bones indicated by the constraint edge according to the difference between the radius of the collision body and the length of the perpendicular line.
[0265] In an example embodiment, based on the foregoing embodiment, the determining the moving distance of the two bones indicated by the constraint edge according to the bone weights of the two bones indicated by the constraint edge comprises: in the case that the bone weights of the two bones indicated by the constraint edge are not equal, determining the length of the perpendicular line between the constraint edge and the axis of the collision body; determining the difference between the radius of the collision body and the length of the perpendicular line; determining the first moving distance of the first bone in the range greater than or equal to 0 and less than or equal to r of the difference; and determining the second moving distance of the second bone according to the difference, the first moving distance, the distance from the first bone to the target point, and the distance from the second bone to the target point, the target point being determined according to the nearest point between the constraint edge and the axis of the center of the collision body; wherein the first bone is the bone with smaller bone weight in the two bones indicated by the constraint edge, and the second bone is the bone with larger bone weight in the two bones indicated by the constraint edge.
[0266] In an example embodiment, based on the foregoing embodiment, the pausing the forward dynamics simulation of the to-be-simulated bone chain in the case that the current bone has a constraint, and updating the current starting bone according to the current bone at rest comprises: in the case that the current bone has a constraint and the bone weight is a first preset coefficient, pausing the forward dynamics simulation of the to-be-simulated bone chain, and updating the current starting bone according to the current bone at rest.
[0267] In an example embodiment, based on the foregoing embodiment, the pausing the forward dynamics simulation of the to-be-simulated bone chain in the case that the current bone has a constraint, and updating the current starting bone according to the current bone at rest comprises: in the case that the current bone has a constraint and the bone weight is a second preset coefficient, determining whether the number of child bones of the current bone is greater than 1; in the case that the number of child bones is greater than 1, pausing the forward dynamics simulation of the to-be-simulated bone chain, and updating the current starting bone according to the child bones, otherwise, performing the forward dynamics simulation on the child bones.
[0268] In an example embodiment, based on the foregoing embodiment, the device 1700 further comprises a deadlock resolution module, which can be configured to determine that the remaining unsolved constraints are invalid constraints in the case that each of the current resting bones of each bone chain to be simulated has unsolved constraints, and perform forward dynamics simulation on the bones that have not been traversed in each bone chain to be simulated until the leaf bones in the bone chain to be simulated complete the forward dynamics simulation, and determine that the simulation of the bone chain to be simulated ends, wherein the invalid constraints do not pause the forward dynamics simulation of the bone chain to be simulated; and determine that the dynamic bone simulation ends in the case that each bone chain to be simulated ends.
[0269] In an example embodiment, based on the foregoing embodiment, the constraints comprise bone weights, and in the case that the two bones limited by the constraint have an ancestor-descendant relationship, the bone weight of the ancestor bone in the two bones is configured to be 0, and the bone weight of the descendant bone in the two bones is configured to be 1, wherein the bone weights are used to indicate the degree of influence of the constraint on the bones.
[0270] In an example embodiment, the dynamic bone simulation device comprises the following program modules: Figure 17 FIG. 2 shows a structural schematic diagram of another dynamic bone simulation device in an example embodiment of the present disclosure; and Figure 17 As shown, the dynamic bone simulation device 1700 comprises the following program modules: a traversal module 1710 configured to, in response to a bone constraint addition operation, traverse the bones in a target bone chain in which the bones added with the constraint are located, starting from a current starting bone of the target bone chain; a second update module 1720 configured to, in the case that the current traversed bone has a constraint, pause the traversal of the target bone chain and update the current starting bone according to the current pause bone, wherein the current pause bone is determined according to the bone at the time of pausing the traversal; a marking module 1730 configured to, in the case that each of the target bone chains is paused, mark the constraints that limit the bones that have been traversed for the constraints existing in the current pause bone; a second repetition module 1740 configured to, in the case that the current pause bone does not have an unmarked constraint, continue to traverse the target bone chain corresponding to the current pause bone to repeatedly perform the operations in the above modules; and a constraint addition module 1750 configured to determine the addition result of the bone constraint according to the marking of the constraint, and perform dynamic bone simulation according to the addition result.
[0271] In an example implementation, based on the foregoing embodiment, the traversing module 1710 can be specifically configured to, in response to the bone constraint adding operation, check whether the to-be-added bone constraint is legal; and in the case that the to-be-added bone constraint is legal, traverse the bones in the target bone chain in which the bone to which the constraint is added is located, starting from the current starting bone of the target bone chain.
[0272] In an example implementation, based on the foregoing embodiment, the checking whether the to-be-added bone constraint is legal comprises: checking whether the bones restricted by the to-be-added bone constraint are the same bone; and / or checking whether the bones restricted by the to-be-added bone constraint have a parent-child relationship.
[0273] In an example implementation, based on the foregoing embodiment, in the case that the to-be-added bone constraint is legal, the traversing the bones in the target bone chain in which the bone to which the constraint is added is located, starting from the current starting bone of the target bone chain comprises: in the case that the to-be-added bone constraint is legal, checking whether the bones restricted by the to-be-added bone constraint belong to the same bone chain; and in the case that the bones restricted by the to-be-added bone constraint do not belong to the same bone chain, traversing the bones in the target bone chain in which the bone to which the constraint is added is located, starting from the current starting bone of the target bone chain.
[0274] In an example implementation, based on the foregoing embodiment, the device 1700 further comprises a bone weight adding simulation module, which can be specifically configured to, in the case that the bones restricted by the to-be-added bone constraint belong to the same bone chain, configure the bone weight of the ancestor bone among the restricted bones to be 1 and the bone weight of the child bone among the restricted bones to be 0, the bone weight being used to indicate the degree of influence of the bone being constrained.
[0275] In an example implementation, based on the foregoing embodiment, the constraint adding module 1750 can be specifically configured to add the marked constraint as a valid bone constraint and add the unmarked constraint as an invalid bone constraint, so as to perform dynamic bone simulation according to the valid bone constraint.
[0276] In an example implementation, based on the foregoing embodiment, the device 1700 further comprises a prompt information display module, which can be configured to generate prompt information of the invalid bone constraint and display the prompt information of the invalid bone constraint on the bone constraint adding interface.
[0277] The specific details of the parts in the device have been described in detail in the method part implementation, and the undisclosed details can be referred to the implementation content of the method part, and thus will not be described again.
[0278] It should be noted that, although several modules or units of the devices for action execution are mentioned in the above detailed description, such division is not mandatory. Indeed, according to exemplary embodiments of the present disclosure, features and functionalities of two or more modules or units described above can be embodied in one module or unit. Conversely, features and functionalities of one module or unit described above can be further divided into embodied by multiple modules or units.
[0279] Further, although the various steps of the methods in the present disclosure are described in a particular order in the accompanying drawings, this does not require or imply that the steps must be performed in that particular order, or that all of the illustrated steps must be performed to achieve the desired results. Additionally or alternatively, certain steps can be omitted, multiple steps can be combined into one step, one step can be split into multiple steps, etc.
[0280] Exemplary embodiments of the present disclosure also provide a computer program product. The computer program product includes a computer program which, when executed by a processor, implements the dynamic bone simulation method described above.
[0281] In an embodiment, the computer program product can be a tangible product containing the computer program, such as a computer-readable storage medium storing the computer program. The readable storage medium can be a storage medium based on electrical, magnetic, optical, electromagnetic, infrared, etc. signals, including but not limited to: random access memory (RAM), read-only memory (ROM), magnetic tape, floppy disk, flash memory (Flash), mechanical hard disk (HDD), solid state disk (SSD), etc. Exemplarily, the computer program product can be implemented as a non-volatile storage medium storing the computer program, such as read-only memory, Nand flash memory, etc.
[0282] In an embodiment, the computer program product can be an intangible product containing the computer program. Exemplarily, the computer program product can be implemented as a virtual digital product, such as an executable file, installation package, etc. digital file storing the computer program.
[0283] The code of the computer program can be written in one or more programming languages. Programming languages such as C, Java, C++, Python, etc. The program code can be executed entirely on the user computing device, or partially on the user computing device, or as a separate software package, or partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In the case involving a remote computing device, the remote computing device can be connected to the user computing device through any kind of network, such as a local area network (LAN), a wide area network (WAN), etc., or can be connected to an external computing device (for example, through an Internet connection provided by an operator).
[0284] The computer program can be carried or transmitted by electrical, magnetic, optical, electromagnetic, infrared, etc. signals. The electronic device can convert the signal carrying the computer program into a digital signal, and then run the computer program. When the computer program is running on the electronic device, its code is used to make the electronic device execute (more specifically, can make the processor of the electronic device execute) the method steps of various exemplary embodiments of the present disclosure, such as the dynamic bone simulation method described above, which includes the following steps: starting from the current starting bone of the bone chain to be simulated, performing forward dynamics simulation on the bones in the bone chain to be simulated, wherein there is a preset constraint between at least two bones in the bone chain to be simulated; in the case where the current bone exists a constraint, pause the forward dynamics simulation of the bone chain to be simulated, and update the current starting bone according to the current stay bone; in the case where each bone chain to be simulated is paused, obtain a current to-be-solved set according to the constraints existing in the current stay bone of each bone chain to be simulated, and solve the constraints in the current to-be-solved set; in the case where the current stay bone of the bone chain to be simulated does not exist an unsolved constraint, repeat the above process for the bone chain to be simulated until the leaf bone in the bone chain to be simulated completes the forward dynamics simulation, and determine that the bone chain to be simulated is simulated.
[0285] By executing the above method steps through the computer program, on the one hand, constraints can be added between any bones, enriching the scenarios of dynamic bone simulation, such as allowing the root bone and the leaf bone of the same bone chain to exist a constraint to bind them together to realize a ring structure; on the other hand, since constraints can be added between any bones, when constraints exist between the bones of different bone chains, the problem of obvious stretching between bone chains due to being too close or too far apart can be avoided, the display effect of the animation is improved, and the animation display is more realistic.
[0286] Exemplary embodiments of the present disclosure also provide an electronic device, which can be the terminal device 210 or the server 220 described above. The electronic device can include a processor and a memory. The memory stores executable instructions of the processor, which can be a computer program. The processor performs the method steps of various exemplary embodiments of the present disclosure by executing the executable instructions. In addition, the electronic device can further include a display for displaying a graphical user interface.
[0287] The following description will be made with reference to Figure 18 The electronic device is exemplarily illustrated in the form of a general computing device. It should be understood that Figure 18 The electronic device 1800 shown is merely an example and should not limit the functions and use ranges of the embodiments of the present disclosure.
[0288] As Figure 18 The electronic device 1800 can include a processor 1810, a memory 1820, a bus 1830, an I / O (Input / Output) interface 1840, a network adapter 1850, and a display 1860, as shown.
[0289] The memory 1820 can include a volatile memory, such as a RAM 1821, a cache unit 1822, and a non-volatile memory, such as a ROM 1823. The memory 1820 can further include one or more program modules 1824, which include, but are not limited to, an operating system, one or more application programs, other program modules, and program data, each of which or some combination of which can include implementation of a network environment. For example, the program modules 1824 can include the modules in the apparatus described above.
[0290] The processor 1810 can include one or more processing units, such as: an AP (Application Processor), a modem processor, a GPU (Graphics Processing Unit), an ISP (Image Signal Processor), a controller, an encoder, a decoder, a DSP (Digital Signal Processor), a baseband processor, and / or a NPU (Neural-Network Processing Unit), etc.
[0291] The processor 1810 can be configured to execute executable instructions stored in the memory 1820, such as to perform the dynamic bone simulation method described above, which includes the following steps: starting from a current starting bone of a bone chain to be simulated, performing forward dynamics simulation on bones in the bone chain to be simulated, wherein there is a preset constraint between at least two bones in the bone chain to be simulated; in the case that the current bone has a constraint, pausing the forward dynamics simulation of the bone chain to be simulated, and updating the current starting bone according to the current paused bone; in the case that each bone chain to be simulated is paused, obtaining a current to-be-solved set according to the constraint existing in the current paused bone of each bone chain to be simulated, solving the constraint in the current to-be-solved set; in the case that the current paused bone of the bone chain to be simulated does not have an unsolved constraint, repeating the above process until the leaf bone in the bone chain to be simulated completes the forward dynamics simulation, and determining that the bone chain to be simulated ends.
[0292] By implementing the above method through executable instructions, on the one hand, constraints can be added between any bones, which enriches the scenarios of dynamic bone simulation, such as binding the root bone and the leaf bone of the same bone chain together to achieve a ring structure; on the other hand, since constraints can be added between any bones, when constraints exist between bones of different bone chains, the problem of obvious stretching between bone chains due to being too close or too far apart can be avoided, the display effect of the animation is improved, and the animation display is more realistic.
[0293] The bus 1830 is configured to realize the connection between different components of the electronic device 1800, and can include a data bus, an address bus, and a control bus.
[0294] The electronic device 1800 can communicate with one or more external devices 1900 (such as a keyboard, a mouse, an external controller, etc.) through the I / O interface 1840.
[0295] The electronic device 1800 can communicate with one or more networks through the network adapter 1850, such as a network adapter 1850 that can provide a 3G / 4G / 5G mobile communication solution, or provide a wireless communication solution such as a wireless local area network, Bluetooth, near field communication, etc. The network adapter 1850 can communicate with other modules of the electronic device 1800 through the bus 1830.
[0296] The electronic device 1800 can display a graphical user interface through the display 1860, such as displaying a game interface, displaying an animation interface after physically simulating an object according to the dynamic bone simulation method in the present disclosure, etc.
[0297] Although Figure 18Other hardware and / or software modules can also be included in electronic device 1800, including but not limited to microcode, device drivers, redundant processors, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, etc., which are not shown.
[0298] Furthermore, the above-described diagrams are merely schematic illustrations of the processes included in the method according to the exemplary embodiments of the present disclosure, and are not intended for limiting purposes. It is readily understood that the processes shown in the above-described diagrams do not indicate or limit the time sequence of the processes. In addition, it is readily understood that the processes can be executed synchronously or asynchronously, for example, in a plurality of modules.
[0299] As can be seen, the technical solutions of the present disclosure can be implemented as a method, an apparatus, a system, a computer program product, a storage medium, an electronic device, and the like. Those skilled in the art can understand that various aspects of the present disclosure can be implemented in the following forms: a complete hardware implementation, a complete software implementation (including firmware, microcode, etc.), or a combination of hardware and software aspects, such as can be referred to as "circuitry", "module", or "system", respectively.
[0300] It should be understood that the present disclosure is not limited to the specific process steps or structural aspects already described above and shown in the drawings, and various modifications and changes can be made without departing from the scope of the present disclosure. Those skilled in the art, based on the specific embodiments provided by the present disclosure, will readily conceive of other embodiments. Therefore, the specific embodiments provided by the present disclosure are merely exemplary, and the scope and spirit of the present disclosure are indicated by the claims, and should encompass any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure, and include common knowledge or conventional technical means in the technical field of the present disclosure that are not disclosed by the present disclosure.
Claims
1. A dynamic skeleton simulation method, characterized in that, include: Starting from the current starting bone of the skeleton chain to be simulated, a forward dynamics simulation is performed on the bones in the skeleton chain to be simulated; wherein, at least two bones in the skeleton chain to be simulated have preset constraints. With constraints in place for the current skeleton, the forward dynamics simulation of the skeleton chain to be simulated is paused, and the current starting skeleton is updated based on the currently stationary skeleton. When the simulation of each skeleton chain to be simulated is paused, the current set to be solved is obtained based on the constraints of all currently stationary bones in each skeleton chain to be simulated, and the constraints in the current set to be solved are solved. If there are no unsolved constraints in the currently stationary bone of the skeleton chain to be simulated, the above-mentioned forward dynamics simulation process is repeated for the skeleton chain to be simulated starting from the updated current starting bone until the leaf bones in the skeleton chain to be simulated complete the forward dynamics simulation, and the simulation of the skeleton chain to be simulated is determined to be over. In the first positive dynamic simulation of the skeletal chain to be simulated, the current starting bone includes the root bone of the skeletal chain to be simulated.
2. The dynamic skeleton simulation method according to claim 1, characterized in that, The process of obtaining the current set to be solved based on the constraints of the currently existing skeleton in each skeleton chain to be simulated includes: Based on the constraints of the currently present skeleton in each skeleton chain to be simulated, a set of collection constraints is determined; From the collected constraint set, constraints for which all constrained bones have completed positive dynamic simulation are determined, thus obtaining the current constraint set to be solved.
3. The dynamic skeleton simulation method according to claim 1, characterized in that, The constraints include distance constraints, which limit the distance range between bones; solving the constraints in the current set to be solved includes: The distance constraints in the current set to be solved are solved until the solution results make the distances between bones restricted by the distance constraints in the current set to be solved all meet the distance range indicated by the distance constraints or the preset number of solutions is reached, and then the distance constraint solution is determined to be completed.
4. The dynamic skeleton simulation method according to claim 3, characterized in that, The process of solving the distance constraints in the current set to be solved includes: The distance constraints in the current set to be solved are solved according to the preset priority.
5. The dynamic skeleton simulation method according to claim 3, characterized in that, The process of solving the distance constraints in the current set to be solved includes: If the actual distance between the bones restricted by the distance constraint is greater than the maximum distance indicated by the distance constraint, the bones restricted by the distance constraint are moved in the direction of decreasing distance, so that the actual distance between the bones restricted by the distance constraint is equal to the maximum distance indicated by the distance constraint. If the actual distance between the bones restricted by the distance constraint is less than the minimum distance indicated by the distance constraint, the bones restricted by the distance constraint are moved in the direction of increasing distance, so that the actual distance between the bones restricted by the distance constraint is equal to the minimum distance indicated by the distance constraint.
6. The dynamic skeleton simulation method according to claim 5, characterized in that, The ways to move the bones restricted by the distance constraint include: The bones are moved according to the distance constraint based on their bone weights, such that the bones with larger bone weights move a greater distance than the bones with smaller bone weights.
7. The dynamic skeleton simulation method according to claim 3, characterized in that, The constraints include collider constraints, which restrict constraint edges from being located outside the collider. The constraint edges are determined based on the line connecting two bones with constraints. Solving the constraints in the current set to be solved includes: After the distance constraint is solved, the length of the perpendicular line between the constraint edge and the axis of the colliding body is used to determine whether the constraint edge is located inside the colliding body. When the constraint edge is located inside the collider, the movement distance of the two bones indicated by the constraint edge is determined, and the two bones are moved according to the movement distance to move the constraint edge outside the collider.
8. The dynamic skeleton simulation method according to claim 7, characterized in that, The process of solving the constraints in the current set to be solved includes: After moving the constraint edge outside the collider, the ancestral bones of the currently stationary bone are subjected to inverse dynamics simulation based on the current position of the currently stationary bone and the preset influence depth.
9. The dynamic skeleton simulation method according to claim 7, characterized in that, The step of determining whether the constraint edge is located inside the collider based on the distance between the constraint edge and the axis of the collider includes: If the length of the perpendicular line between the constraint edge and the axis of the collider is less than the radius of the collider, then the constraint edge is determined to be located inside the collider.
10. The dynamic skeleton simulation method according to claim 7, characterized in that, The determination of the movement distance of the two bones indicated by the constraint edge includes: The movement distance of the two bones indicated by the constraint edge is determined based on the bone weights of the two bones indicated by the constraint edge.
11. The dynamic skeleton simulation method according to claim 10, characterized in that, Determining the movement distance of the two bones indicated by the constraint edge based on their bone weights includes: When the bone weights of the two bones indicated by the constraint edge are equal, the length of the perpendicular line between the constraint edge and the axis of the collider is determined. The movement distance of the two bones indicated by the constraint edge is determined based on the difference between the radius of the collider and the length of the vertical line.
12. The dynamic skeleton simulation method according to claim 10, characterized in that, Determining the movement distance of the two bones indicated by the constraint edge based on their bone weights includes: When the bone weights of the two bones indicated by the constraint edge are not equal, the length of the perpendicular line between the constraint edge and the axis of the collider is determined. Determine the difference between the radius of the collider and the length of the perpendicular; The first movement distance of the first bone is determined within the range of being greater than or equal to 0 and less than or equal to the difference; Based on the difference, the first moving distance, the distance from the first bone to the target point, and the distance from the second bone to the target point, the second moving distance of the second bone is determined, and the target point is determined based on the closest point between the constraint edge and the central axis of the collider; Wherein, the first bone is the bone with the smaller weight among the two bones indicated by the constraint edge, and the second bone is the bone with the larger weight among the two bones indicated by the constraint edge.
13. The dynamic skeleton simulation method according to claim 1, characterized in that, The constraints include bone weights, which indicate the degree to which the bones are affected by the constraints; the step of pausing the forward dynamics simulation of the skeleton chain to be simulated and updating the current starting bone based on the currently stationary bone when constraints exist on the current bone includes: When the current skeleton is constrained and the skeleton weight is a first preset coefficient, the forward dynamics simulation of the skeleton chain to be simulated is paused, and the current starting skeleton is updated according to the currently stationary skeleton.
14. The dynamic skeleton simulation method according to claim 1, characterized in that, The step of pausing the forward dynamics simulation of the skeleton chain to be simulated under constraints, and updating the current starting skeleton based on the currently stationary skeleton, includes: Given that the current skeleton is constrained and the skeleton weight is a second preset coefficient, determine whether the number of sub-bones of the current skeleton is greater than 1; If the number of sub-bones is greater than 1, the forward dynamics simulation of the skeleton chain to be simulated is paused, and the current starting bone is updated according to each of the sub-bones.
15. The dynamic skeleton simulation method according to claim 1, characterized in that, The method further includes: If there are unsolved constraints in the current stationary bones of each skeleton chain to be simulated, the remaining unsolved constraints are determined to be invalid constraints. Forward dynamics simulation is performed on the bones that have not been traversed in each skeleton chain to be simulated until the leaf bones in the skeleton chain to be simulated complete the forward dynamics simulation. The simulation of the skeleton chain to be simulated is then determined to be over. The invalid constraints do not pause the forward dynamics simulation of the skeleton chain to be simulated. The dynamic skeletal simulation ends when each skeletal chain simulation is completed.
16. The dynamic skeleton simulation method according to claim 1, characterized in that, The constraint includes bone weights. When the two bones constrained by the constraint have an ancestor relationship, the bone weight of the ancestor bone in the two bones is configured to 0, and the bone weight of the child bone in the two bones is configured to 1. The bone weights are used to indicate the degree of influence of the constraint on the bone.
17. A dynamic skeleton simulation method, characterized in that, include: In response to the bone constraint addition operation, for the target bone chain where the bone to which the constraint is added is located, start from the current starting bone of the target bone chain and traverse the bones in the target bone chain; If there are constraints on the currently traversed bones, the traversal of the target bone chain is paused, and the current starting bone is updated according to the currently paused bone. The currently paused bone is determined based on the bones at the time of the pause. When traversal of each target bone chain is paused, constraints that have been traversed for the currently paused bones are marked. If there are no unmarked constraints on the currently paused bone, the target bone chain corresponding to the currently paused bone continues to be traversed to repeat the above process; Based on the marking of the constraints, the result of adding skeletal constraints is determined, and dynamic skeletal simulation is performed based on the result of adding constraints.
18. The dynamic skeleton simulation method according to claim 17, characterized in that, The response to the bone constraint addition operation, for the target bone chain containing the bone to which the constraint is added, involves traversing the bones in the target bone chain, starting from the current starting bone of the target bone chain, including: In response to the bone constraint addition operation, check whether the bone constraint to be added is valid; If the constraint to be added to the bone is valid, for the target bone chain containing the bone to which the constraint is to be added, start from the current starting bone of the target bone chain and traverse the bones in the target bone chain.
19. The dynamic skeleton simulation method according to claim 18, characterized in that, The check to determine whether the skeleton constraints to be added are valid includes: Check whether the bones constrained by the bone constraints to be added are the same bone; and / or Check if there is a parent-child relationship between the bones restricted by the skeleton constraints to be added.
20. The dynamic skeleton simulation method according to claim 18, characterized in that, When the bone constraint to be added is valid, for the target bone chain containing the bone to which the constraint is to be added, traversing the bones in the target bone chain starting from the current starting bone includes: If the bone constraint to be added is valid, check whether the bones restricted by the bone constraint to be added belong to the same bone chain; If the bones to be constrained by the added bone constraint do not belong to the same bone chain, for the target bone chain where the bone to be constrained is located, start from the current starting bone of the target bone chain and traverse the bones in the target bone chain.
21. The dynamic skeleton simulation method according to claim 20, characterized in that, The method further includes: When the bones to be constrained by the added bone constraint belong to the same bone chain, the bone weight of the ancestral bone in the constrained bone is configured to 1, and the bone weight of the child bone in the constrained bone is configured to 0. The bone weight is used to indicate the degree of influence of the constraint on the bone.
22. The dynamic skeleton simulation method according to claim 17, characterized in that, The step of determining the addition result of skeletal constraints based on the constraint markings, and performing dynamic skeletal simulation based on the addition result, includes: The tagged constraints are added as valid bone constraints, and the untagged constraints are added as invalid bone constraints, so as to perform dynamic bone simulation based on the valid bone constraints.
23. The dynamic skeleton simulation method according to claim 22, characterized in that, The method further includes: Generate a prompt message for the invalid bone constraint so that the prompt message for the invalid bone constraint is displayed in the bone constraint addition interface.
24. A dynamic skeletal simulation device, characterized in that, include: The forward dynamics simulation module is configured to perform forward dynamics simulation on the bones in the bone chain to be simulated, starting from the current starting bone of the bone chain to be simulated, wherein there are preset constraints between at least two bones in the bone chain to be simulated. The first update module is configured to pause the forward dynamics simulation of the skeleton chain to be simulated when there are constraints on the current skeleton, and update the current starting skeleton according to the currently stationary skeleton; The module for determining the set to be solved is configured to, when the simulation of each skeleton chain to be simulated is paused, obtain the current set to be solved based on the constraints of the currently stationary skeleton of each skeleton chain to be simulated, and solve the constraints in the current set to be solved. The first repeating module is configured to repeatedly execute the operations in the above module on the skeleton chain to be simulated, starting from the updated current starting bone, when there are no unsolved constraints in the currently stationary bone of the skeleton chain to be simulated, until the leaf bones in the skeleton chain to be simulated complete the forward dynamics simulation, and determine that the simulation of the skeleton chain to be simulated has ended. In the first positive dynamic simulation of the skeletal chain to be simulated, the current starting bone includes the root bone of the skeletal chain to be simulated.
25. A dynamic skeletal simulation device, characterized in that, include: The traversal module is configured to respond to the bone constraint addition operation and, for the target bone chain where the bone to which the constraint is added is located, traverse the bones in the target bone chain starting from the current starting bone of the target bone chain; The second update module is configured to pause the traversal of the target bone chain when there are constraints on the currently traversed bones, and update the current starting bone according to the currently paused bone, wherein the currently paused bone is determined according to the bones at the time of pausing the traversal. The marking module is configured to mark constraints that have been traversed for the currently paused bones, provided that traversal of each target bone chain is paused. The second repeating module is configured to continue traversing the target bone chain corresponding to the currently paused bone to repeat the operations in the above module if there are no unmarked constraints in the currently paused bone. The constraint addition module is configured to determine the addition result of the skeletal constraints based on the constraint marking, so as to perform dynamic skeletal simulation based on the addition result.
26. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the dynamic skeleton simulation method as described in any one of claims 1 to 23.
27. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the dynamic skeleton simulation method as described in any one of claims 1 to 23.
28. An electronic device, characterized in that, include: One or more processors; A storage device for storing one or more programs, which, when executed by one or more processors, cause the one or more processors to implement the dynamic skeleton simulation method as described in any one of claims 1 to 23.
Citation Information
Patent Citations
Bone model processing method and device, electronic equipment and storage medium
CN116196628A
Animation generation method and device
CN117371177A