Object model morphing control method, apparatus and electronic device
Patent Information
- Application Number
- CN202211043100.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-29
- Publication Date
- 2026-10-30
- Estimated Expiration
- 2042-08-29
AI Technical Summary
[0002]目前大部分的游戏中,虚拟角色大多为刚体,当与外界物体发生碰撞时,无法产生对应的软体形变,例如虚拟角色的手臂肌肉受到外界碰撞后,没有任何的形变或物理效果
[0009]本发明提供了一种对象模型的形变控制方法、装置和电子设备,获取预先构建的对象模型;其中的对象模型绑定有根骨骼和子骨骼,子骨骼与对象模型中的模型顶点连接,子骨骼用于控制模型顶点进行移动;响应于预设碰撞模型与子骨骼发生碰撞,确定子骨骼的移动距离和移动方向;基于移动距离和移动方向,控制对象模型中与子骨骼连接的目标模型顶点移动,以使对象模型的模型表面产生形变。该方式中,通过绑定子骨骼的方式,使对象模型在游戏运行中,与游戏场景中虚拟对象发生碰撞时,在对象模型表面能够产生正确的,且在现实中一致的形变效果,避免了通过渲染的方式消耗大量的计算资源和计算时间,提高了游戏中对象模型的真实感。
Smart Images

Figure CN115527012B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and in particular to a method, apparatus, and electronic device for controlling the deformation of an object model. Background Technology
[0002] Currently, in most games, virtual characters are mostly rigid bodies. When they collide with external objects, they cannot produce corresponding soft deformations. For example, when a virtual character's arm muscles are hit by an external object, there is no deformation or physical effect. Related technologies typically use offline rendering to generate soft models with deformation effects. However, this offline rendering method is only suitable for industrial or simulation fields, and rendering requires a large amount of computing resources and time. It cannot render soft deformation effects in real time in games, resulting in poor realism of virtual characters and an inability to produce correct soft deformation effects in real time with objects in the 3D scene. Summary of the Invention
[0003] In view of this, the purpose of the present invention is to provide a deformation control method, device and electronic device for object models. By binding sub-skeletons, when the object model collides with virtual objects in the game scene during game operation, the object model surface can produce a correct deformation effect that is consistent with reality, so as to avoid consuming a lot of computing resources and computing time through rendering and improve the realism of the object model in the game.
[0004] In a first aspect, embodiments of the present invention provide a deformation control method for an object model. The method includes: acquiring a pre-constructed object model; wherein the object model is bound to a root bone and sub-bones, the root bone being used to control the pose of the object model; the sub-bones are associated with the root bone and are also connected to model vertices in the object model, the sub-bones being used to control the movement of the model vertices; in response to a collision between a preset collision model and the object model, determining the movement distance and movement direction of the sub-bones; based on the movement distance and movement direction, controlling the movement of the sub-bones, and controlling the movement of target model vertices connected to the sub-bones in the object model, so as to deform the surface of the object model.
[0005] Secondly, embodiments of the present invention provide a deformation control device for an object model. The device includes: an acquisition module for acquiring a pre-constructed object model; wherein the object model is bound to a root bone and sub-bones, the root bone being used to control the pose of the object model; the sub-bones are associated with the root bone and are also connected to model vertices in the object model, the sub-bones being used to control the movement of the model vertices; a determination module for determining the movement distance and movement direction of the sub-bones in response to a collision between a preset collision model and the sub-bones; wherein the movement direction is consistent with the movement direction of the preset collision model; and a control module for controlling the movement of the sub-bones based on the movement distance and movement direction, and controlling the movement of target model vertices connected to the sub-bones in the object model, so as to deform the surface of the object model.
[0006] Thirdly, embodiments of the present invention provide an electronic device, including a processor and a memory, wherein the memory stores computer-executable instructions that can be executed by the processor, and the processor executes the computer-executable instructions to implement the deformation control method of the object model of any one of claims 1-7.
[0007] Fourthly, embodiments of the present invention provide a computer-readable storage medium storing computer-executable instructions, which, when invoked and executed by a processor, cause the processor to implement the deformation control method of the object model according to any one of claims 1-7.
[0008] The embodiments of the present invention bring the following beneficial effects:
[0009] This invention provides a method, apparatus, and electronic device for deforming an object model. The method involves acquiring a pre-constructed object model, wherein the object model is bound to a root skeleton and sub-skeletons. The sub-skeletons are connected to model vertices in the object model and are used to control the movement of these vertices. In response to a collision between a preset collision model and a sub-skeleton, the movement distance and direction of the sub-skeleton are determined. Based on the movement distance and direction, the movement of target model vertices connected to the sub-skeletons in the object model is controlled, causing deformation on the surface of the object model. This method, by binding sub-skeletons, ensures that when the object model collides with virtual objects in the game scene during gameplay, it produces a correct and realistic deformation effect on the object model surface. This avoids the significant computational resources and time consumed by rendering, thus improving the realism of the object model in the game.
[0010] Other features and advantages of the invention will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the invention. The objects and other advantages of the invention are realized and obtained in accordance with the structures particularly pointed out in the description, claims and drawings.
[0011] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description
[0012] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0013] Figure 1 A flowchart of a deformation control method for an object model provided in an embodiment of the present invention;
[0014] Figure 2 A schematic diagram of an object model provided in an embodiment of the present invention;
[0015] Figure 3 A schematic diagram of another object model provided in an embodiment of the present invention;
[0016] Figure 4 A schematic diagram of another object model provided in an embodiment of the present invention.
[0017] Figure 5 A schematic diagram of the structure of a deformation control device for an object model provided in an embodiment of the present invention;
[0018] Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0019] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0020] Currently, in most games, virtual characters are mostly rigid bodies. When they collide with external objects, they cannot produce corresponding soft deformations. For example, when a virtual character's arm muscles are hit by an external object, there is no deformation or physical effect. Related technologies typically use offline rendering to generate soft models with deformation effects. However, this offline rendering method is only suitable for industrial or simulation fields, and rendering requires a large amount of computing resources and time. It cannot render soft deformation effects in real time in games, resulting in poor realism of virtual characters and an inability to produce correct soft deformation effects in real time with objects in a 3D scene. Therefore, this invention provides a method, device, and electronic device for controlling the deformation of object models. This technology can be applied to devices such as computers and laptops, and especially to devices with game engines.
[0021] To facilitate understanding of this embodiment, a deformation control method for an object model disclosed in this embodiment will first be described in detail, such as... Figure 1 As shown, the method includes the following steps:
[0022] Step S102: Obtain a pre-built object model; wherein, the object model is bound to a root bone and sub-bones, the root bone is used to control the pose of the object model; the sub-bones are associated with the root bone and are also connected to the model vertices in the object model, and the sub-bones are used to control the movement of the model vertices;
[0023] The aforementioned object model typically refers to a virtual model in a game scene, such as a virtual character, a virtual balloon, or a virtual tire—a soft model with an elastic surface. The root skeleton is typically used to control the pose and movement of the object model. There can be one or more root skeletons, depending on the size and type of the object model. Each root skeleton is usually associated with (e.g., connected to) multiple sub-bones, and these sub-bones are bound to the soft-effect surfaces of the object model. A root skeleton can typically be associated with one or more sub-bones, each connected to a vertex in the object model to control the movement of those vertices. For example, a sub-bone might be connected to a portion of the object model's vertices; when the sub-bone moves, the connected vertices will also move accordingly.
[0024] The root skeleton governs all its associated sub-skeletons. When the root skeleton moves, each sub-skeleton moves accordingly. Since the vertices of the object model are bound to its sub-skeletons, the movement of the root skeleton drives the movement of the object model. To enable deformation effects on soft-effect model surfaces within the object model, sub-skeletons are typically connected to these surfaces; that is, all vertices of the model surface are connected to sub-skeletons. In practice, a pre-built object model can be imported into the game engine, as described above for obtaining a pre-built object model.
[0025] For example, such as Figure 2 As shown, taking the leg model as an example, the thigh of the leg model is the part with a soft body effect. A root bone is bound to the calf, and multiple sub-bones are bound sequentially to the thigh. Each sub-bone is connected to the root bone and to the model vertices of the thigh model. When the root bone bound to the calf moves, it causes the calf to move, which in turn causes the connected sub-bones to move. The movement of the sub-bones also causes the thigh to move. In other words, the sub-bones are used to control the movement of the model vertices under the guidance of the root bone. Furthermore, these sub-bones can move independently of the root bone.
[0026] Step S104: In response to a collision between a preset collision model and an object model, determine the movement distance and direction of the sub-bone.
[0027] The aforementioned preset collision model can be a model of a specified shape, such as a sphere. Specifically, developers need to create animation blueprints in the game engine beforehand and write the driving logic for the sub-bones bound to the object model. The animation blueprint is used to control the movement of the bones. Each sub-bone has a corresponding driving function. Once the movement distance and direction of the sub-bone are determined, these values are passed to the corresponding driving function to drive the sub-bone's movement. Simultaneously, a collision logic script must be created beforehand, primarily used to detect collisions between the preset collision model and the sub-bones bound to the object model. A blueprint typically refers to a place in UE4 (Unreal Engine 4, a game engine) where functional scripts are written, similar to a code editor.
[0028] In addition, after creating the animation blueprint and collision logic script, it's necessary to create the bone model of the sub-bones within the collision logic script. This allows the animation blueprint to be assigned to this bone model, enabling control of all bones within the model in the collision logic script. Furthermore, upon detecting a collision with a sub-bone, the animation blueprint for that bone model can be determined based on its bone model, ensuring that the determined movement distance and direction align with the correct blueprint. Creating the bone model of a sub-bone simply involves creating a bone model variable to hold the imported sub-bones. Similar to pointers or variables in C++, this variable allows for the manipulation of each sub-bone within the object model.
[0029] In actual implementation, using collision logic scripts and the engine's built-in basic raycasting function, with a specified length (e.g., the radius of a sphere model) as the detection range, all objects around the preset collision model can be detected in real time. When a sub-bone of the object model is detected, it indicates that a collision has occurred between the preset collision model and the sub-bone. Then, based on the overlap distance between the preset collision model and the sub-bone, the movement distance of the sub-bone can be determined, and the movement direction of the preset collision model can be determined as the aforementioned movement direction. Alternatively, the movement distance and direction of the sub-bone can be determined based on the magnitude and direction of the collision force exerted on the sub-bone by the preset collision model. The movement direction of the sub-bone may be the same as or different from the movement direction of the preset collision model. For example, when the preset collision model is a ball, the movement direction of the sub-bone will be the same as the movement direction of the ball after colliding with the object model, causing the surface of the object model to produce a concave deformation effect. However, when the preset collision model is a torch or boiling water, the movement direction of the sub-bone will be inconsistent with the movement direction of the fire or boiling water after contact with the object model. In this case, the sub-bone may move in the opposite direction to the movement direction of the preset collision model, causing the surface of the object model to produce a bubble deformation effect. Alternatively, the movement direction of the sub-bone can also be random.
[0030] Step 106: Based on the movement distance and direction, control the movement of the sub-bone and control the movement of the target model vertices connected to the sub-bone in the object model so as to deform the model surface of the object model.
[0031] Finally, the movement distance and direction are passed to the driving function corresponding to the sub-bone to control the sub-bone to move the aforementioned distance according to the movement direction. Since the sub-bone is connected to the target model vertices, the movement of the sub-bone will cause the target model vertices to move as well. For example, such as... Figure 3As shown, taking the leg model as the object model and the sphere model as the preset collision model as an example, when the sphere model collides with the leg model, the surface of the leg model will produce a correct and realistic deformation. Additionally, the collision property of the aforementioned preset collision model is that collisions occur between the goldfish skeletons.
[0032] For example, when the object model is a human or animal model, the aforementioned deformation usually refers to soft deformation. That is, when the preset collision model collides with the human model, it will produce a depression deformation on the surface of the human model's skin, just like actual skin.
[0033] This invention provides a deformation control method for an object model. The method involves obtaining a pre-constructed object model, which is bound to a root bone and sub-bones. The sub-bones are connected to model vertices within the object model and are used to control the movement of these vertices. In response to a collision between a preset collision model and a sub-bones, the movement distance and direction of the sub-bones are determined. Based on these distances and directions, the movement of target model vertices connected to the sub-bones within the object model is controlled, causing deformation on the object model's surface. This method, by binding sub-bones, ensures that when the object model collides with virtual objects in the game scene, it produces a correct and realistic deformation effect on its surface. This avoids the significant computational resources and time required for rendering, thus improving the realism of the object model in the game.
[0034] Step S104 above, which is the step of determining the movement distance and direction of the object model in response to a collision between a preset collision model and a sub-bone, can be implemented in the following possible way:
[0035] (1) In response to a collision between a preset collision model and an object model, calculate the movement distance based on the detection distance of the ray detection of the preset collision model and the collision point of the sub-bone bound to the object model.
[0036] The aforementioned ray detection can be spherical ray detection. The detection distance of the ray detection is usually related to the shape of the preset collision model. For example, if the preset collision model is a sphere, the detection distance of the ray detection is the radius of the sphere. If the preset collision model is another irregular model, the detection distance of the ray detection can be the distance from the center of the preset collision model to the surface of the model. In the actual collision process, the collision between the sub-bone and the preset collision model may be a contact collision, that is, only the sub-bone and the preset collision model make contact, or it may be an intrusion collision, that is, the preset collision model intrudes into the object model, or the preset collision model intrudes into the sub-bone. Therefore, based on the detection distance and the collision point, the distance by which the preset collision model intrudes into the object model is determined, and the aforementioned movement distance is obtained.
[0037] (2) Determine the collision surface between the preset collision model and the sub-bone, and determine the normal direction of the collision surface as the movement direction.
[0038] The above-mentioned ray detection can detect the approximate normal orientation when the preset collision model collides with the sub-bone. Specifically, the direction of the specified object model in the normal of the collision surface between the preset collision model and the sub-bone can be determined as the above-mentioned movement direction.
[0039] Alternatively, the movement direction can be determined by the direction of the line connecting the collision point of the preset collision model and the center of the preset collision model, and this movement direction always points towards the object model. The normal direction typically specifies the object model or the preset collision model.
[0040] In the above method, the spherical ray detection function built into the engine is used to detect the distance and collision direction from the center of the object model to the collision surface of the sub-bone in real time, thereby determining the direction of the distance the sub-bone needs to move, which improves the accuracy of deformation.
[0041] In step (1) above, the step of calculating the movement distance based on the detection distance of ray detection using a preset collision model and the collision point of the sub-skeleton, one possible implementation is as follows:
[0042] The collision point between the sub-bone and the preset collision model is determined, and the first distance between the collision point and the center of the preset collision model is determined; the difference between the detection distance and the first distance is determined as the movement distance.
[0043] Specifically, ray detection can determine the collision point between a sub-bone and a preset collision model. After the collision, the preset collision model may intrude into the object model. In this case, the first distance between the collision point and the center of the preset collision model is determined. Finally, the movement distance is obtained by subtracting the first distance from the detected distance. For example, if the preset collision model is a sphere, and the radius of the sphere is used as the detection distance (e.g., 10cm), if the distance from the collision point of the sub-bone to the center of the sphere is 8cm, it means that the sphere has intruded into the object model by 2cm, i.e., the movement distance is 2cm.
[0044] In practice, the aforementioned movement distance can be represented by the `offset` variable. Once the value of `offset` is obtained, it is passed to the animation blueprint corresponding to the sub-bone, allowing the animation blueprint to drive the sub-bone's movement based on the movement distance and direction. This method determines the movement distance using the raycasting detection distance and the collision point of the sub-bone, further improving the accuracy of deformation.
[0045] Before the steps described above, which involve determining the movement distance and direction of a sub-bone in response to a collision between a preset collision model and an object model, the method further includes:
[0046] The ray detection starts at the center of the preset collision model and the detection range is the distance from the center of the preset collision model to the model surface of the preset collision model. The collision between the preset collision model and the object model is detected. In response to the detection of a sub-bone bound to the object model within the detection range, it is confirmed that the preset collision model and the sub-bone have collided.
[0047] Taking a sphere as the preset collision model as an example, the starting point of the spherical ray is set at the center of the sphere, and the detection range is set at the radius of the sphere. Sub-bones around the sphere are detected. When a sub-bones (e.g., its name is Bone009) is detected, it can be determined that the preset collision model has collided with the sub-bones. In this method, the preset collision model sets the starting point and monitoring range of the ray detection, further improving the accuracy of collision detection.
[0048] In step S106 above, the step of controlling the movement of sub-bones based on the movement distance and direction, and controlling the movement of target model vertices connected to the sub-bones in the object model to cause deformation of the object model surface, can be implemented in one possible way:
[0049] The sub-bone is controlled to offset the movement distance in the movement direction, and the target model vertices connected to the sub-bone in the object model are controlled to move according to the pre-configured weight values of the model vertices, so as to cause deformation of the model surface of the object model; where the weight values are used to indicate the extent to which the model vertices are affected by the sub-bone.
[0050] The weight values of the aforementioned model vertices specifically indicate the offset distance of the vertex during sub-bone movement. For example, if a model vertex has a weight value of 1, then if the sub-bone moves a distance of 2cm, the vertex will move a distance of 2cm. Conversely, if a model vertex has a weight value of 0.1, then if the sub-bone moves a distance of 2cm, the vertex will move a distance less than 2cm (e.g., 0.2cm). Furthermore, the movement direction of the target model vertex is usually consistent with the previously obtained movement direction.
[0051] In actual implementation, when the TransformBone function in the animation blueprint reads the offset value (i.e., after the TransformBone function reads the movement distance and direction), it offsets the sub-bone along the movement direction of the preset collision model by the offset distance. Simultaneously, the vertices of the target model connected to the sub-bone also shift with the movement of the sub-bone. This simulates the soft-body effect where the vertices of the target model shift and become concave when the preset collision model collides with the target model. Figure 3As shown. Additionally, to simulate soft-body effects in parts of the object model, where a soft indentation occurs upon collision with a preset collision model at any location, corresponding TransformBone functions can be set for each sub-bone. In this method, moving the sub-bone also moves the corresponding target model vertices connected to it. By controlling the movement distance of the target model vertices through pre-configured weight values, the soft indentation effect is produced.
[0052] The above steps, which control the movement of target model vertices connected to sub-bones in the object model based on pre-configured model vertex weight values, can be implemented in one possible way:
[0053] For each target model vertex, perform the following steps: calculate the product of the movement distance and the weight value of the target model vertex to obtain the target movement distance of the target model vertex, and control the target model vertex to move the target movement distance; wherein, the weight value of the target model vertex at the first distance from the sub-bone is greater than the weight value of the target model vertex at the second distance from the sub-bone, and the first distance is less than the second distance.
[0054] Specifically, the target movement distance of a vertex can be calculated by multiplying the movement distance with the weight value of the target model vertex. Then, as the sub-bone moves, the target model vertex is simultaneously controlled to offset according to this target movement distance. To create the effect of a concave surface on the model, the target model vertex closer to the sub-bone has a larger weight value, and the target model vertex farther from the sub-bone has a smaller weight value.
[0055] For example, there are 10 target model vertices connected to the sub-bone. The target model vertex 0.1cm away from the sub-bone has a weight of 1, the target model vertex 0.5cm away has a weight of 0.9, the target model vertex 1cm away has a weight of 0.7, the target model vertex 1.5cm away has a weight of 0.5, the target model vertex 2cm away has a weight of 0.2, and so on. When the sub-bone moves 2cm, the target model vertex 0.1cm away moves 2cm, the target model vertex 0.5cm away moves 1.8cm, the target model vertex 1cm away moves 1.4cm, the target model vertex 1.5cm away moves 1cm, and the target model vertex 2cm away moves 0.4cm.
[0056] In the above method, the target movement distance of the target model vertex is determined by multiplying the weight value by the movement distance, thereby simulating a more realistic concavity effect.
[0057] The above object model is constructed in the following way:
[0058] Obtain the initial object model, bind the root skeleton to the initial object model, create the corresponding sub-skeletons based on the root skeleton to obtain the intermediate object model; wherein, the root skeleton and the sub-skeletons are connected; add skinning to the sub-skeletons, so that the sub-skeletons are connected to the model vertices in the intermediate object model to obtain the object model; wherein, each model vertex in the object model is connected to a sub-skeleton.
[0059] Specifically, skeleton rigging can be performed in 3ds Max software, such as... Figure 2 As shown, taking the leg model as an example, assuming the thigh portion above the knee has a soft-body effect, first, a root bone for the leg is created. Then, several sub-bones are created sequentially under the root bone, with each sub-bone positioned upwards towards the thigh root. Since each sub-bone controls several model vertices, multiple sub-bones need to be created so that each vertex of the leg model can be controlled by a sub-bone. Generally, the fewer vertices a sub-bone is bound to, the more precise the control over model deformation. Therefore, a large number of sub-bones are usually needed. This ensures that in the game, when a sub-bone is moved, the connected model vertices can be moved, causing the surface of that part of the model to deform.
[0060] Then as Figure 4 As shown, skinning is added to sub-bones to bind them to their corresponding model vertices. Additionally, in 3ds Max, the influence range of a sub-bone can be viewed; the closer a vertex is to the bone, the greater its influence on that vertex; conversely, the further out the bone, the less its influence. This method specifically describes the process of creating an object model, demonstrating how binding sub-bones and connecting model vertices can achieve model deformation effects.
[0061] In one specific implementation, an interactive real-time software simulation scheme with low consumption and relatively simple production process is proposed. The first step, taking the character's thigh as an example, involves binding several small sub-bones to the thigh muscles based on the human muscle structure. These bones are used solely to drive the thigh's deformation for soft body simulation. The second step involves writing collision logic and creating a new collision component (the aforementioned preset collision model). This collision component's collision attribute is: it only collides with sub-bones. The third step involves the collision component emitting spherical rays to detect collisions with the bones in real time, storing the coordinates of the collision point and the names of the sub-bones near the collision point for use in the next step of force calculation. The fourth step involves calculating the direction of the force on the bone based on the orientation of the sub-bones and the direction of movement of the collision component. Based on the magnitude of the set force, the direction the sub-bones should offset (the aforementioned movement direction) is then calculated. The fifth step, similarly, involves obtaining the affected sub-bones based on the radius of the collision component, and then determining the final offset of the sub-bones (the aforementioned movement distance) based on the distance of the sub-bones from the collision point. The sixth step involves sending this offset back to the control parameters of the corresponding sub-bones to control the movement of the sub-bones, causing the model's vertices to offset, thus producing the soft body effect. This avoids consuming a lot of computing resources and time through rendering, and improves the realism of object models in the game.
[0062] Corresponding to the above method embodiments, the present invention provides a deformation control device for an object model, such as... Figure 5 As shown, the device includes:
[0063] The acquisition module 51 is used to acquire a pre-built object model; wherein, the object model is bound to a root bone and sub-bones, the root bone is used to control the pose of the object model; the sub-bones are associated with the root bone and are also connected to the model vertices in the object model, and the sub-bones are used to control the movement of the model vertices;
[0064] The determination module 52 is used to determine the movement distance and direction of the sub-bone in response to a collision between the preset collision model and the object model.
[0065] The control module 53 is used to control the movement of the sub-bone based on the movement distance and direction, and to control the movement of the target model vertices connected to the sub-bone in the object model, so as to cause deformation of the model surface of the object model.
[0066] This invention provides a deformation control device for an object model. The device acquires a pre-constructed object model, which is bound to a root bone and sub-bones. The sub-bones are connected to model vertices in the object model and are used to control the movement of these vertices. In response to a collision between a preset collision model and the object model, the device determines the movement distance and direction of the sub-bones. Based on the movement distance and direction, it controls the movement of target model vertices connected to the sub-bones in the object model, causing deformation on the object model's surface. This method, by binding sub-bones, ensures that when the object model collides with virtual objects in the game scene, it produces a correct and realistic deformation effect on its surface, avoiding the consumption of significant computational resources and time through rendering and improving the realism of the object model in the game.
[0067] Furthermore, the aforementioned determining module is also used to: in response to a collision between a preset collision model and an object model, calculate the movement distance based on the detection distance of the ray detection of the preset collision model and the collision point of the sub-bone bound to the object model; determine the collision surface between the preset collision model and the sub-bone, and determine the normal direction of the collision surface as the movement direction.
[0068] Furthermore, the aforementioned determining module is also used to: determine the collision point with the preset collision model from the sub-skeleton, determine the first distance between the collision point and the center of the preset collision model; and determine the difference between the detection distance and the first distance as the movement distance.
[0069] Furthermore, the aforementioned device also includes a detection module, used to: use the center of the preset collision model as the starting point of ray detection, and the distance from the center of the preset collision model to the model surface of the preset collision model as the detection range of ray detection, to detect the collision between the preset collision model and the object model; and in response to the detection of a sub-bone bound to the object model within the detection range, to confirm that the preset collision model and the sub-bone have collided.
[0070] Furthermore, the aforementioned control module is also used to: control the sub-bone to offset the movement distance in the movement direction, and control the target model vertex connected to the sub-bone in the object model to move according to the pre-configured weight values of the model vertices, so as to cause deformation of the model surface of the object model; wherein, the weight values are used to indicate the extent to which the model vertex is affected by the sub-bone.
[0071] Furthermore, the aforementioned control module is also used to perform the following steps for each target model vertex: calculate the product of the movement distance and the weight value of the target model vertex to obtain the target movement distance of the target model vertex, and control the target model vertex to move the target movement distance; wherein, the weight value of the target model vertex at the first distance from the sub-bone is greater than the weight value of the target model vertex at the second distance from the sub-bone, and the first distance is less than the second distance.
[0072] Furthermore, the above object model is constructed in the following way: an initial object model is obtained, a root skeleton is bound to the initial object model, and corresponding sub-skeletons are created based on the root skeleton to obtain an intermediate object model; wherein the root skeleton and the sub-skeletons are connected; skinning is added to the sub-skeletons so that the sub-skeletons are connected to the model vertices in the intermediate object model to obtain the object model; wherein each model vertex in the object model is connected to a sub-skeleton.
[0073] The deformation control device for the object model provided in this embodiment of the invention has the same technical features as the deformation control method for the object model provided in the above embodiments, so it can also solve the same technical problems and achieve the same technical effects.
[0074] This embodiment also provides an electronic device, including a processor and a memory. The memory stores machine-executable instructions that can be executed by the processor. The processor executes the machine-executable instructions to implement the deformation control method of the object model described above. This electronic device can be a server or a terminal device.
[0075] See Figure 6 As shown, the electronic device includes a processor 100 and a memory 101. The memory 101 stores machine-executable instructions that can be executed by the processor 100. The processor 100 executes the machine-executable instructions to implement the deformation control method of the object model described above.
[0076] Furthermore, Figure 6 The electronic device shown also includes a bus 102 and a communication interface 103, with the processor 100, the communication interface 103 and the memory 101 connected via the bus 102.
[0077] The memory 101 may include high-speed random access memory (RAM) or non-volatile memory, such as at least one disk storage device. Communication between this system network element and at least one other network element is achieved through at least one communication interface 103 (which can be wired or wireless), such as the Internet, wide area network, local area network, or metropolitan area network. The bus 102 may be an ISA bus, PCI bus, or EISA bus, etc. The bus can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 6 The symbol is represented by a single double-headed arrow, but this does not mean that there is only one bus or one type of bus.
[0078] Processor 100 may be an integrated circuit chip with signal processing capabilities. In implementation, each step of the above method can be completed by the integrated logic circuitry in the hardware of processor 100 or by instructions in software form. Processor 100 may be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this invention. The general-purpose processor may be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this invention can be directly manifested as execution by a hardware decoding processor, or execution by a combination of hardware and software modules in the decoding processor. The software module can reside in a mature storage medium in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, or registers. This storage medium is located in memory 101. The processor 100 reads information from memory 101 and, in conjunction with its hardware, completes the steps of the method described in the foregoing embodiment. This method specifically includes:
[0079] A pre-built object model is obtained; this object model is bound to a root bone and sub-bones. The root bone controls the pose of the object model. The sub-bones are associated with the root bone and also connected to the model vertices in the object model, controlling their movement. In response to a collision between a preset collision model and the object model, the movement distance and direction of the sub-bones are determined. Based on these distances and directions, the movement of the sub-bones is controlled, along with the movement of the target model vertices connected to them, causing deformation on the object model's surface. This method, by binding sub-bones, ensures that when the object model collides with virtual objects in the game scene, it produces accurate and realistic deformation effects on its surface, avoiding the significant computational resources and time consumed by rendering and improving the realism of the object models in the game.
[0080] The steps described above for determining the movement distance and direction of a sub-bone in response to a collision between a preset collision model and an object model include: calculating the movement distance based on the detection distance of the ray detection of the preset collision model and the collision point of the sub-bone bound to the object model; determining the collision surface between the preset collision model and the sub-bone, and determining the normal direction of the collision surface as the movement direction. In this method, the engine's built-in spherical ray detection function detects the distance and collision direction from the center of the object model to the collision surface of the sub-bone in real time, thereby determining the direction of the distance the sub-bone needs to move, improving the accuracy of deformation.
[0081] The steps described above, which calculate the movement distance based on the detection distance of ray detection and the collision point of the sub-bone using a preset collision model, include: determining the collision point between the sub-bone and the preset collision model; determining a first distance between the collision point and the center of the preset collision model; and determining the movement distance as the difference between the detection distance and the first distance. This method, by determining the movement distance using the detection distance of ray detection and the collision point of the sub-bone, further improves the accuracy of deformation.
[0082] Before the steps described above, which determine the movement distance and direction of the sub-bone in response to a collision between the preset collision model and the object model, the method further includes: using the center of the preset collision model as the starting point of ray detection and the distance from the center of the preset collision model to its model surface as the detection range of ray detection, detecting the collision between the preset collision model and the object model; and confirming a collision between the preset collision model and the sub-bone if a sub-bone bound to the object model is detected within the detection range. In this method, the preset collision model serves as the basis for setting the starting point and monitoring range of ray detection, further improving the accuracy of collision detection.
[0083] The steps described above, which control the movement of sub-bones based on movement distance and direction, and control the movement of target model vertices connected to the sub-bones in the object model to deform the surface of the object model, include: controlling the sub-bones to offset the movement distance in the movement direction, and controlling the movement of target model vertices connected to the sub-bones in the object model according to pre-configured weight values of the model vertices, so as to deform the surface of the object model; wherein, the weight values are used to indicate the extent to which the model vertices are affected by the sub-bones. In this method, while moving the sub-bones, the target model vertices connected to the sub-bones are also moved accordingly. By controlling the movement distance of the target model vertices through pre-configured weight values of the model vertices, a soft-body indentation effect is produced.
[0084] The steps described above, which control the movement of target model vertices connected to sub-bones in the object model based on pre-configured weight values of model vertices, include: for each target model vertex, performing the following steps: calculating the product of the movement distance and the weight value of the target model vertex to obtain the target movement distance of the target model vertex, and controlling the target model vertex to move by the target movement distance; wherein, the weight value of the target model vertex at a first distance from the sub-bones is greater than that of the target model vertex at a second distance from the sub-bones, and the first distance is less than the second distance. In this method, the target movement distance of the target model vertex is determined by multiplying the weight value and the movement distance, thereby simulating a more realistic concavity effect.
[0085] The object model described above is constructed as follows: An initial object model is obtained; a root skeleton is bound to the initial object model; corresponding sub-skeletons are created based on the root skeleton to obtain an intermediate object model; the root skeleton and sub-skeletons are connected; skinning is added to the sub-skeletons, connecting them to the model vertices in the intermediate object model to obtain the object model; each model vertex in the object model is connected to a sub-skeleton. This method specifically describes the process of creating the object model, and by binding sub-skeletons and connecting model vertices, the effect of model deformation can be achieved.
[0086] This embodiment also provides a computer-readable storage medium storing machine-executable instructions. When the machine-executable instructions are called and executed by a processor, the machine-executable instructions cause the processor to implement the deformation control method of the above-mentioned object model.
[0087] The computer program product of the deformation control method, apparatus, electronic device, and system for object models provided in the embodiments of the present invention includes a computer-readable storage medium storing program code. The instructions included in the program code can be used to execute the methods described in the preceding method embodiments, specifically including:
[0088] A pre-built object model is obtained; this object model is bound to a root bone and sub-bones. The root bone controls the pose of the object model. The sub-bones are associated with the root bone and also connected to the model vertices in the object model, controlling their movement. In response to a collision between a preset collision model and the object model, the movement distance and direction of the sub-bones are determined. Based on these distances and directions, the movement of the sub-bones is controlled, along with the movement of the target model vertices connected to them, causing deformation on the object model's surface. This method, by binding sub-bones, ensures that when the object model collides with virtual objects in the game scene, it produces accurate and realistic deformation effects on its surface, avoiding the significant computational resources and time consumed by rendering and improving the realism of the object models in the game.
[0089] The steps described above for determining the movement distance and direction of a sub-bone in response to a collision between a preset collision model and an object model include: calculating the movement distance based on the detection distance of the ray detection of the preset collision model and the collision point of the sub-bone bound to the object model; determining the collision surface between the preset collision model and the sub-bone, and determining the normal direction of the collision surface as the movement direction. In this method, the engine's built-in spherical ray detection function detects the distance and collision direction from the center of the object model to the collision surface of the sub-bone in real time, thereby determining the direction of the distance the sub-bone needs to move, improving the accuracy of deformation.
[0090] The steps described above, which calculate the movement distance based on the detection distance of ray detection and the collision point of the sub-bone using a preset collision model, include: determining the collision point between the sub-bone and the preset collision model; determining a first distance between the collision point and the center of the preset collision model; and determining the movement distance as the difference between the detection distance and the first distance. This method, by determining the movement distance using the detection distance of ray detection and the collision point of the sub-bone, further improves the accuracy of deformation.
[0091] Before the steps described above, which determine the movement distance and direction of the sub-bone in response to a collision between the preset collision model and the sub-bone, the method further includes: using the center of the preset collision model as the starting point of ray detection and the distance from the center of the preset collision model to its model surface as the detection range of ray detection, detecting the collision between the preset collision model and the object model; and confirming a collision between the preset collision model and the sub-bone if a sub-bone bound to the object model is detected within the detection range. In this method, the preset collision model serves as the basis for setting the starting point and monitoring range of ray detection, further improving the accuracy of collision detection.
[0092] The steps described above, which control the movement of sub-bones based on movement distance and direction, and control the movement of target model vertices connected to the sub-bones in the object model to deform the surface of the object model, include: controlling the sub-bones to offset the movement distance in the movement direction, and controlling the movement of target model vertices connected to the sub-bones in the object model according to pre-configured weight values of the model vertices, so as to deform the surface of the object model; wherein, the weight values are used to indicate the extent to which the model vertices are affected by the sub-bones. In this method, while moving the sub-bones, the target model vertices connected to the sub-bones are also moved accordingly. By controlling the movement distance of the target model vertices through pre-configured weight values of the model vertices, a soft-body indentation effect is produced.
[0093] The steps described above, which control the movement of target model vertices connected to sub-bones in the object model based on pre-configured weight values of model vertices, include: for each target model vertex, performing the following steps: calculating the product of the movement distance and the weight value of the target model vertex to obtain the target movement distance of the target model vertex, and controlling the target model vertex to move by the target movement distance; wherein, the weight value of the target model vertex at a first distance from the sub-bones is greater than that of the target model vertex at a second distance from the sub-bones, and the first distance is less than the second distance. In this method, the target movement distance of the target model vertex is determined by multiplying the weight value and the movement distance, thereby simulating a more realistic concavity effect.
[0094] The object model described above is constructed as follows: An initial object model is obtained; a root skeleton is bound to the initial object model; corresponding sub-skeletons are created based on the root skeleton to obtain an intermediate object model; the root skeleton and sub-skeletons are connected; skinning is added to the sub-skeletons, connecting them to the model vertices in the intermediate object model to obtain the object model; each model vertex in the object model is connected to a sub-skeleton. This method specifically describes the process of creating the object model, and by binding sub-skeletons and connecting model vertices, the effect of model deformation can be achieved.
[0095] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the system and apparatus described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0096] Furthermore, in the description of the embodiments of the present invention, unless otherwise explicitly specified and limited, the terms "installation," "connection," and "linking" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal connection of two components. Those skilled in the art can understand the specific meaning of the above terms in the present invention based on the specific circumstances.
[0097] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, essentially, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0098] In the description of this invention, it should be noted that the terms "center," "upper," "lower," "left," "right," "vertical," "horizontal," "inner," and "outer," etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are used only for the convenience of describing the invention and for simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on the invention. Furthermore, the terms "first," "second," and "third" are used for descriptive purposes only and should not be construed as indicating or implying relative importance.
[0099] Finally, it should be noted that the above embodiments are merely specific implementations of the present invention, used to illustrate the technical solutions of the present invention, and not to limit it. The scope of protection of the present invention is not limited thereto. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments within the technical scope disclosed in the present invention, or make equivalent substitutions for some of the technical features; and these modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be covered within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A deformation control method for an object model, characterized in that, The method includes: Obtain a pre-built object model; wherein the object model is bound to a root bone and sub-bones, the root bone is used to control the pose of the object model; the sub-bones are associated with the root bone, and the sub-bones are also connected to the model vertices in the object model, the sub-bones are used to control the movement of the model vertices; In response to a collision between a preset collision model and the object model, the movement distance and direction of the sub-bone are determined; wherein, each sub-bone is provided with a corresponding driving function; Based on the movement distance and the movement direction, the sub-bone is controlled to move, and the target model vertices connected to the sub-bone in the object model are controlled to move, so that the model surface of the object model is deformed; The step of controlling the movement of the sub-skeletal based on the movement distance and the movement direction includes: The movement distance and direction of the sub-bone are passed to the corresponding driving function of the sub-bone to control the movement of the sub-bone.
2. The method according to claim 1, characterized in that, The step of determining the movement distance and direction of the sub-bone in response to a collision between a preset collision model and the object model includes: In response to a collision between a preset collision model and the object model, the movement distance is calculated based on the detection distance of the ray detection of the preset collision model and the collision point of the sub-bone bound to the object model; Determine the collision surface between the preset collision model and the sub-bone, and determine the normal direction of the collision surface as the movement direction.
3. The method according to claim 2, characterized in that, The step of calculating the movement distance based on the ray detection distance of the preset collision model and the collision point of the sub-bone includes: Determine the collision point with the preset collision model from the sub-skeleton, and calculate the first distance between the collision point and the center of the preset collision model; The difference between the detection distance and the first distance is determined as the movement distance.
4. The method according to claim 1, characterized in that, Before the step of determining the movement distance and direction of the sub-bone in response to a collision between a preset collision model and the object model, the method further includes: Using the center of the preset collision model as the starting point of ray detection and the distance from the center of the preset collision model to the model surface of the preset collision model as the detection distance of ray detection, the collision between the preset collision model and the object model is detected. In response to the detection of a sub-bone bound to the object model within the detection distance, it is confirmed that the preset collision model collides with the sub-bone.
5. The method according to claim 1, characterized in that, The steps of controlling the movement of the sub-bone based on the movement distance and the movement direction, and controlling the movement of target model vertices connected to the sub-bone in the object model to cause deformation of the model surface of the object model, include: The sub-bone is controlled to offset the movement distance in the movement direction, and the target model vertex connected to the sub-bone in the object model is controlled to move according to the pre-configured weight value of the model vertex, so as to deform the model surface of the object model; wherein, the weight value is used to indicate the extent to which the model vertex is affected by the sub-bone.
6. The method according to claim 5, characterized in that, The step of controlling the movement of target model vertices connected to the sub-skeleton in the object model according to the pre-configured weight values of the model vertices includes: For each vertex of the target model, perform the following steps: Calculate the product of the movement distance and the weight value of the target model vertex to obtain the target movement distance of the target model vertex, and control the target model vertex to move by the target movement distance; wherein, the weight value of the target model vertex at the first distance from the sub-bone is greater than the weight value of the target model vertex at the second distance from the sub-bone, and the first distance is less than the second distance.
7. The method according to claim 1, characterized in that, The object model is constructed in the following manner: Obtain an initial object model, bind the root bone to the initial object model, create corresponding sub-bones based on the root bone, and obtain an intermediate object model; wherein the root bone is connected to the sub-bones. Skinning is added to the sub-bone, connecting the sub-bone to the model vertices in the intermediate object model to obtain the object model; wherein each model vertex in the object model is connected to the sub-bone.
8. A deformation control device for an object model, characterized in that, The device includes: An acquisition module is used to acquire a pre-built object model; wherein the object model is bound to a root bone and sub-bones, the root bone is used to control the pose of the object model; the sub-bones are associated with the root bone, and the sub-bones are also connected to the model vertices in the object model, the sub-bones are used to control the movement of the model vertices under the guidance of the root bone; The determination module is used to determine the movement distance and direction of the sub-bone in response to a collision between a preset collision model and the object model; wherein each sub-bone is provided with a corresponding driving function; The control module is used to control the movement of the sub-bone based on the movement distance and the movement direction, and to control the movement of the target model vertices connected to the sub-bone in the object model, so as to cause deformation of the model surface of the object model; The control module is also used to: pass the movement distance and movement direction of the sub-bone into the driving function corresponding to the sub-bone, so as to control the movement of the sub-bone.
9. An electronic device, characterized in that, It includes a processor and a memory, the memory storing computer-executable instructions that can be executed by the processor, the processor executing the computer-executable instructions to implement the deformation control method of the object model according to any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when invoked and executed by a processor, cause the processor to implement the deformation control method for the object model according to any one of claims 1-7.
Citation Information
Patent Citations
Virtual object control method and device and electronic equipment
CN112184862A
Animation generation method and device
CN114882153A
