Virtual model deformation control method, device, and electronic device
The mass point model with virtual springs efficiently simulates virtual model deformations, addressing computational inefficiencies in existing methods to enable realistic and timely rendering of virtual models.
Patent Information
- Authority / Receiving Office
- JP · JP
- Patent Type
- Patents
- Current Assignee / Owner
- Filing Date
- 2023-03-21
- Publication Date
- 2026-03-10
AI Technical Summary
Existing virtual model deformation simulation methods, such as using rigid colliders or finite elements, are computationally intensive and difficult to apply to real-time rendering due to high calculation requirements, leading to low realism and inefficiency in simulating deformations like depression and breakage.
A method involving a mass point model with interconnected virtual springs is used to simulate virtual model deformation, where a smaller number of mass points than mesh vertices are employed, with a predetermined mapping relationship, allowing for efficient calculation of deformation parameters based on collision events and spring thresholds.
This approach reduces computational burden while achieving realistic deformation effects, enabling real-time rendering of virtual models with detailed deformation simulations.
Smart Images

Figure 0007827936000001 
Figure 0007827936000002 
Figure 0007827936000003
Abstract
Description
Cross-Citation of Related Applications
[0001] This disclosure claims priority to a Chinese patent application bearing application number 202211222119.4, filed on October 8, 2022, and entitled "Method, device and electronic device for controlling deformation of virtual model," the entire contents of which are incorporated herein by reference. [Technical Field]
[0002] The present disclosure relates to the field of model rendering technology, and in particular to a method, device, and electronic device for controlling deformation of a virtual model. [Background technology]
[0003] In a virtual scene, after a model collides, a rigid collider is usually used to simulate the state of the model after the collision. When simulating the state of a model after the collision using a rigid collider, changes in position and orientation, such as roll and rotation, occur after the model collides, but it is difficult to simulate deformations of the model after the collision, such as depression, protrusion, and breakage of the model, resulting in low realism of this simulation method. In related art, a model can be divided into finite elements to obtain a large number of voxel sets, and when the model collides, the position of each voxel in the model can be calculated based on parameters such as collision strength and direction to obtain a deformed model. However, this method requires a huge amount of calculation, requiring a lot of calculation time and calculation resources, making it difficult to apply to real-time rendering of virtual scenes. Summary of the Invention
[0004] According to one aspect of the present disclosure, an embodiment of the present disclosure provides a method for controlling deformation of a virtual model, the method including: generating a target model located in a virtual scene and a mass point model corresponding to the target model, wherein the mass point model and the target model are set to be superimposed on the virtual scene, the mass point model includes a plurality of mass points, the plurality of mass points are connected by virtual springs, the shape consisting of the plurality of mass points matches the shape of the target model, the number of mass points in the mass point model is smaller than the number of mesh vertices in the target model, and there is a predetermined mapping relationship between the mass points and the mesh vertices; in response to the mass point model detecting a collision event, determining a first position of the mass point in the mass point model after the occurrence of the collision event based on a collision parameter of the collision event and a deformation threshold of the virtual spring; and determining a first rendering parameter of the mesh vertex in the target model based on the first position of the mass point in the mass point model and the mapping relationship between the mass point and the mesh vertex, and rendering the mesh vertex in the target model using the first rendering parameter, thereby obtaining a deformed target model.
[0005] Optionally, after the step of generating a target model located in the virtual scene and a mass point model corresponding to the target model, the method for controlling deformation of the virtual model further includes the step of detecting whether a mass point in the mass point model collides with a mass point in response to the target model being located in the virtual scene, and determining that a collision event is detected when at least one mass point in the mass point model collides.
[0006] Optionally, the step of determining a first position of a mass point in the mass point model after the occurrence of a collision event based on collision parameters of the collision event and a deformation threshold of the virtual spring in response to the mass point model detecting a collision event includes the steps of: acquiring collision parameters of the collision event in response to the mass point model detecting a collision event, the collision parameters including multiple types of a target mass point where the collision occurred, a collision direction, and a collision strength; controlling each mass point in the mass point model to be displaced based on the collision parameters, and monitoring the deformation amount of the virtual spring connecting the mass points during the process of the mass point displacement; and determining a first position of the mass point based on the deformation amount and the deformation threshold.
[0007] Optionally, the step of determining the first position of the mass point based on the deformation amount and the deformation threshold includes the steps of: controlling the rebound of the virtual spring and determining the first position of the mass point based on the length of the rebounded virtual spring when the deformation amount does not exceed the deformation threshold of the virtual spring; and determining the length of the virtual spring after deformation when the deformation amount exceeds the deformation threshold of the virtual spring, and determining the first position of the mass point based on the length of the virtual spring after deformation.
[0008] Optionally, the method for controlling deformation of a virtual model further includes a step of removing the virtual spring and controlling the mass points at both ends of the virtual spring to move away from each other when the deformation amount exceeds a breaking threshold of the virtual spring, thereby obtaining a first position of the mass points.
[0009] Optionally, the mapping relationship between the mass points and the mesh vertices is obtained in the following manner: superimpose the target model and the mass point model on a predetermined world coordinate system; determine a predetermined number of target mass points from the mass point model for the mesh vertices in the target model; construct a local coordinate system based on the predetermined number of target mass points; determine a first transformation relationship between the local coordinate system and the world coordinate system; transform the initial rendering parameters of the mesh vertices in the world coordinate system into the local coordinate system based on the first transformation relationship; obtain partial rendering parameters, where the initial rendering parameters include multiple types of position parameters, normal parameters, and tangent parameters of the mesh vertices; and determine the mesh vertices, the target mass points, and the partial rendering parameters as the mapping relationship between the mass points and the mesh vertices.
[0010] Optionally, the step of determining a predetermined number of target mass points from the mass point model for mesh vertices in the target model includes the steps of: calculating, for mesh vertices in the target model, the Euclidean distances between the mesh vertices and at least some of the mass points in the mass point model; sorting at least some of the mass points in order of smallest Euclidean distance to obtain a mass point sequence; and determining the first three mass points in the mass point sequence as target mass points.
[0011] Optionally, the step of constructing a local coordinate system based on the predetermined number of target mass points includes the steps of: setting a first mass point among the target mass points as the origin of the local coordinate system; setting a direction of a connecting line between the first mass point and a second mass point among the target mass points as the first axis direction of the local coordinate system; setting a direction corresponding to the vector product of the direction of a connecting line between a third mass point among the target mass points and the first mass point and the first axis direction as the second axis direction of the local coordinate system; and obtaining a local coordinate system by setting a direction perpendicular to both the first axis direction and the second axis direction of the local coordinate system.
[0012] Optionally, the step of determining first rendering parameters of mesh vertices in the target model based on first positions of the mass points in the mass point model and the mapping relationship between the mass points and the mesh vertices includes the steps of: obtaining a predetermined number of target mass points corresponding to the mesh vertices from the mapping relationship; constructing a deformed coordinate system based on the first positions of the predetermined number of target mass points and determining a second transformation relationship between the deformed coordinate system and a predetermined world coordinate system, wherein the world coordinate system is constructed in a virtual scene in which the target model and the mass point model are located; obtaining partial rendering parameters corresponding to the mesh vertices from the mapping relationship; and determining the first rendering parameters of the mesh vertices in the world coordinate system based on the second transformation relationship and the partial rendering parameters.
[0013] According to one aspect of the present disclosure, the present disclosure provides a virtual model deformation control device, the virtual model deformation control device comprising: a model generation module, a position determination module, and a parameter determination module; the model generation module is configured to generate a target model located in a virtual scene and a mass point model corresponding to the target model; the mass point model and the target model are set to be superimposed on the virtual scene; the mass point model includes a plurality of mass points, the plurality of mass points are connected by virtual springs; a shape consisting of the plurality of mass points matches a shape of the target model; the number of mass points in the mass point model is smaller than the number of mesh vertices in the target model; The position determination module is configured to determine, in response to the mass point model detecting a collision event, a first position of the mass point in the mass point model after the occurrence of the collision event based on the collision parameters of the collision event and the deformation threshold of the virtual spring, and the parameter determination module is configured to determine first rendering parameters of the mesh vertices in the target model based on the first position of the mass point in the mass point model and the mapping relationship between the mass point and the mesh vertices, and render the mesh vertices in the target model using the first rendering parameters to obtain a deformed target model.
[0014] According to one aspect of the present disclosure, the present disclosure further includes an electronic device including a processor and a memory, wherein the memory stores machine-executable instructions executable by the processor, and the processor executes the machine-executable instructions to realize the above-mentioned virtual model deformation control method.
[0015] According to one aspect of the present disclosure, the present disclosure further includes a machine-readable storage medium having machine-executable instructions stored thereon, the machine-executable instructions, when invoked and executed by a processor, causing the processor to implement the above-mentioned virtual model deformation control method.
[0016] A virtual model deformation control method, device, and electronic device according to an embodiment of the present disclosure generate a target model located in a virtual scene and a mass point model corresponding to the target model, wherein the mass point model and the target model are set to be superimposed on the virtual scene, the mass point model includes a plurality of mass points connected by virtual springs, the shape consisting of the plurality of mass points matches the shape of the target model, the number of mass points in the mass point model is smaller than the number of mesh vertices in the target model, and there is a predetermined mapping relationship between the mass points and the mesh vertices, and in response to the mass point model detecting a collision event, determine a first position of the mass point in the mass point model after the occurrence of the collision event based on collision parameters of the collision event and a deformation threshold of the virtual springs, determine first rendering parameters of the mesh vertices in the target model based on the first position of the mass point in the mass point model and the mapping relationship between the mass points and the mesh vertices, and render the mesh vertices in the target model using the first rendering parameters to obtain a deformed target model. In this method, a mass point model is set on the target model, and the mass point model contains a small number of mass points, which are connected by virtual springs. A collision event is detected using the mass point model. When a collision occurs, the displacement between the mass points is calculated, and the rendering parameters of the target model after deformation are determined by deforming the virtual springs, and the deformed target model is then rendered and obtained. This method requires little calculation for deformation, is efficient, and has realistic deformation effects, making it suitable for real-time rendering of virtual scenes. [Brief explanation of the drawings]
[0017] [Figure 1] 1 is a flowchart of a method for controlling deformation of a virtual model according to an embodiment of the present disclosure. [Figure 2] FIG. 2 is a schematic diagram of a mass point model of a vehicle model according to an embodiment of the present disclosure. [Figure 3] FIG. 2 is a schematic diagram of a vehicle model according to an embodiment of the present disclosure. [Figure 4]1 is a structural schematic diagram of a virtual model deformation control device according to an embodiment of the present disclosure. [Figure 5] FIG. 1 is a schematic diagram of an electronic device according to an embodiment of the present disclosure. DETAILED DESCRIPTION OF THE INVENTION
[0018] In order to clarify the objectives, technical solutions and advantages of the embodiments of the present disclosure, the technical solutions of the present disclosure will be described below clearly and completely with reference to the drawings, and it is obvious that the described embodiments are only some embodiments of the present disclosure, and not all embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by those skilled in the art without creative labor also fall within the scope of protection of the present disclosure.
[0019] In game scenes or other virtual scenes, deformation simulation of a virtual model can enrich the visual effect of the virtual model and improve the user's interaction experience. However, in current virtual scenes, most virtual models are rigid bodies that cannot be deformed, and although the virtual model may be occluded by obstacles in the virtual scene, the virtual model itself does not deform.
[0020] Taking a vehicle model in a game scene as an example, a rigid collision object is placed on the vehicle model during the scene creation stage. When the vehicle collides during game execution, the vehicle model undergoes a physical simulation. The vehicle model only participates in the rigid body simulation flow, obtaining the position and rotation of the rigid body and rendering and controlling the position and rotation of the vehicle model. The vehicle model cannot render the deformation effect caused by the collision.
[0021] In related art, a finite element approach can be used to simulate the deformation of a virtual model. In this approach, the virtual model is divided into finite elements to obtain a set of tetrahedral or hexahedral voxels. When the virtual model collides, an elastic matrix is assembled for each voxel in the model to obtain an elastic equation. The elastic equation is then solved to obtain the position of each voxel and to obtain deformation data for the virtual model. However, a single virtual model is usually divided into many voxels, and calculations are performed for each voxel, which requires a large amount of computational resources and time, making it difficult to apply to real-time rendering scenes such as games.
[0022] Based on the above, embodiments of the present disclosure provide a method, device, and electronic device for controlling deformation of a virtual model, which can be applied to game scenes or various other types of virtual scenes, and can be applied to controlling deformation of a virtual model, and in particular, can be applied to real-time deformation rendering of a virtual model.
[0023] To facilitate understanding of the present embodiment, the virtual model deformation control method disclosed in the embodiment of the present disclosure will be first described in detail. As shown in Fig. 1, the virtual model deformation control method may be applied to a server, a terminal device, or a cloud server. The method includes the following steps:
[0024] In step S102, a target model located in the virtual scene and a mass point model corresponding to the target model are generated, where the mass point model and the target model are set to be superimposed on the virtual scene, the mass point model includes a plurality of mass points, the plurality of mass points are connected by virtual springs, the shape consisting of the plurality of mass points matches the shape of the target model, the number of mass points in the mass point model is smaller than the number of mesh vertices in the target model, and there is a pre-set mapping relationship between the mass points and the mesh vertices.
[0025] The target model may be a model with various deformable attributes, such as a human model, a vehicle model, a stationary object model, or an animal model. In the process of creating the target model, in addition to creating the target model itself, a mass point model matching the target model must also be created. The priority of creating the mass point model and the target model is not limited. In the mass point model, mass points are connected by virtual springs, and one mass point is usually connected to one or more surrounding mass points. The mass points and the virtual springs must form a relatively strong structure. A triangle is a relatively stable shape, and a triangle is usually formed between a mass point and a virtual spring, so the mass point model includes multiple triangles.
[0026] In actual implementation, the placement of a virtual spring between a given mass point and the mass point is usually determined based on the shape of the mass point model or the shape of the target model. When a virtual spring is connected between two mass points, the two mass points maintain a certain elastic distance. The virtual spring may be realized by a plastic spring, and a deformation threshold and a rupture threshold may be set for the virtual spring. When a mass point model collides, all or some of the mass points in the mass point model are displaced. For a certain virtual spring, when two mass points connected by the spring are displaced or when one of the mass points is displaced, the virtual spring is deformed, and the deformation may be tension or compression.
[0027] If the deformation amount does not reach the deformation threshold, the virtual spring will rebound, for example, when the virtual spring is neither tensioned nor compressed, in which case the positions of the two mass points will not change; if the deformation amount reaches the deformation threshold, the virtual spring will not rebound, in which case the positions of the two mass points will change, thereby simulating deformation of the model; further, if the deformation amount reaches the breaking threshold, the virtual spring can be considered to have broken, in which case the two mass points will move away from each other, simulating breaking of the model.
[0028] Because the number of mesh vertices in the target model is large, directly calculating the positions of the mesh vertices when a collision occurs results in enormous computational costs, causing stuttering on the scene screen and making it difficult to apply to real-time rendering of scenes. To reduce the amount of computation, the number of mass points in the mass point model is smaller than the number of mesh vertices in the target model. It can be seen that the more mass points in the mass point model, the more detailed and realistic the deformation of the target model will be when a collision occurs, but this requires large computational resources and computation time, and only then can the position of each mass point and the rendering parameters of each mesh vertex in the target model be calculated.
[0029] This embodiment aims to realize real-time rendering that simulates deformation, and based on this, the number of mass points in the mass point model is smaller than the number of mesh vertices in the target model, and when a collision event occurs, the rendering parameters of each mesh vertex in the target model can be determined by calculating the positions of a small number of mass points, thereby reducing the amount of calculation and calculation time.
[0030] Figures 2 and 3 are examples, with Figure 2 showing a mass point model of a vehicle model and Figure 3 showing an example where the target model is a vehicle model. The mass point model includes multiple mass points, and virtual springs are used to connect the mass points based on the shape of the vehicle model, resulting in a mass point model of a vehicle shape with a relatively stable structure. The size and shape of the mass point model and the target model match each other, and in the virtual scene, the mass point model and the target model are placed superimposed on each other, but only the target model is displayed, and it can be seen that the mass point model is configured to detect a collision event. Typically, a vehicle model has approximately 20,000 mesh vertices, and the mass point model has approximately 900 mass points.
[0031] In addition, to associate the mass point model with the target model, a mapping relationship between the mass points and the mesh vertices is pre-established. In the virtual scene, the rendering parameters of the mesh vertices in the target model are set based on the world coordinate system in the virtual scene, and the rendering parameters for the mass points of the mesh vertices can be obtained based on the mapping relationship. After a collision occurs, the position of the mass point changes, but the mapping relationship does not change, i.e., the rendering parameters for the mass points of the mesh vertices do not change. Based on this, the rendering parameters of the mesh vertices can be obtained after the position of the mass point changes, and a deformed target model can be rendered.
[0032] In the virtual scene, the target model is positioned in the virtual scene, and the mass model is also placed in the virtual scene superimposed on the target model, but the mass model is not displayed. When the target model moves in the virtual scene, the mass model also moves simultaneously, that is, the mass model and the target model are superimposed in real time.
[0033] The mass model is configured to detect a collision event, for example, the target model and the mass model may collide with obstacles or other models in the virtual scene, the size of the mass model may be the same as that of the target model, or the mass model may be slightly larger than the target model, in which case the detection of the collision event is relatively sensitive, or the mass model may be slightly smaller than the target model, in which case the detection of the collision event is relatively insensitive.
[0034] In step S104, in response to the mass point model detecting a collision event, a first position of a mass point in the mass point model after the occurrence of the collision event is determined based on the collision parameters of the collision event and the deformation threshold of the virtual spring.
[0035] The collision parameters of the collision event may include the position where the target model collides, the collision direction, the collision strength, the relative velocity between the models where the collision occurred, etc. These collision parameters allow the displacement of each mass point to be calculated using an algorithm based on Extended Position-Based Dynamics (XPBD) or other dynamics principles.
[0036] In addition, virtual springs are connected between the mass points, and displacement of the mass points causes deformation of the virtual springs. Therefore, if the displacement is small, the deformation amount of the virtual springs does not exceed the deformation threshold, in which case the virtual springs rebound, and the first position of the mass points remains the same as the initial position before the collision or changes slightly; if the deformation amount of the virtual springs exceeds the deformation threshold, the virtual springs do not rebound, and the first position of the mass points differs significantly from the initial position before the collision.
[0037] In step S106, based on the first position of the mass point in the mass point model and the mapping relationship between the mass point and the mesh vertex, a first rendering parameter of the mesh vertex in the target model is determined, and the mesh vertex in the target model is rendered according to the first rendering parameter to obtain a deformed target model.
[0038] After a collision occurs, the mass point reaches a first position, and there is a relatively fixed mapping relationship between the mass point and the mesh vertex, so that first rendering parameters of the mesh vertex after the collision can be obtained based on the first position of the mass point, which can include position parameters, normal parameters, tangent parameters, etc. of the mesh vertex after the collision occurs. Then, by rendering the mesh vertex of the target model using the first rendering parameters, the target model after the deformation due to the collision can be obtained.
[0039] The above-mentioned virtual model deformation control method generates a target model located in a virtual scene and a mass point model corresponding to the target model, where the mass point model and the target model are set to be superimposed on the virtual scene, the mass point model includes a plurality of mass points connected by virtual springs, the shape consisting of the plurality of mass points matches the shape of the target model, the number of mass points in the mass point model is smaller than the number of mesh vertices in the target model, and there is a predetermined mapping relationship between the mass points and the mesh vertices, and in response to the mass point model detecting a collision event, determines a first position of the mass point in the mass point model after the occurrence of the collision event based on collision parameters of the collision event and a deformation threshold of the virtual spring, determines first rendering parameters of the mesh vertices in the target model based on the first position of the mass point in the mass point model and the mapping relationship between the mass point and the mesh vertices, and renders the mesh vertices in the target model using the first rendering parameters to obtain a deformed target model. In this method, a mass point model is set on the target model, and the mass point model contains a small number of mass points, which are connected by virtual springs. A collision event is detected using the mass point model. When a collision occurs, the displacement between the mass points is calculated, and the rendering parameters of the target model after deformation are determined by deforming the virtual springs, and the deformed target model is then rendered and obtained. This method requires little calculation for deformation, is efficient, and has realistic deformation effects, making it suitable for real-time rendering of virtual scenes.
[0040] Next, a method for detecting a collision event will be described.
[0041] Specifically, in response to the target model being positioned in the virtual scene, mass points in the mass point model are used to detect whether or not mass points collide, and when at least one mass point in the mass point model collides, it is determined that a collision event has been detected.
[0042] In this method, collision events are detected by mass points in a mass point model. All or some of the mass points in the mass point model have collision detection capabilities. For example, detection rays can be installed on these mass points, and the rays can be used to detect whether the mass points themselves come into contact with or collide with other models in the scene. When a target model is located in the virtual scene, these mass points detect whether they will collide with other models in real time or in a timely manner. If the collision model in the virtual scene is small, it may collide with only one mass point in the mass point model, in which case the mass point will detect a collision event. If the collision model is large, it may collide with multiple mass points in the mass point model, in which case the multiple mass points will jointly detect and obtain a collision event.
[0043] A method for determining the position of each mass point in the mass point model after a collision event occurs will be described below.
[0044] Specifically, in response to the mass point model detecting a collision event, collision parameters of the collision event are acquired, where the collision parameters include multiple types of target mass point where the collision occurred, the collision direction, and the collision strength, and each mass point in the mass point model is controlled to be displaced based on the collision parameters.In the process of the mass point displacement, the deformation amount of the virtual spring connecting the mass points is monitored, and a first position of the mass point is determined based on the deformation amount and a deformation threshold.
[0045] The target mass point where the collision occurs usually has a large displacement. Because the target mass point and the surrounding mass points are connected by virtual springs, the surrounding mass points are also displaced under the action of the virtual springs, and it can be understood that other mass points connected to the surrounding mass points may also be displaced. In actual implementation, the displacement of each mass point can be calculated using XPBD or other dynamics algorithms. The collision direction may affect the range of displaced mass points in the mass point model, and mass points away from the collision direction will not be displaced or will only be slightly displaced. The collision strength affects the magnitude of the mass point displacement and the number of displaced mass points. The greater the collision strength, the greater the mass point displacement and the greater the number of displaced mass points.
[0046] The system uses dynamics principles to calculate the displacement of each mass point based on the collision parameters, and controls the movement of the mass point. The movement of the mass point drives the virtual spring connected to it to deform. According to the properties of the spring, if the deformation of the spring does not exceed the deformation threshold, the virtual spring can rebound fully or partially; if the deformation exceeds the deformation threshold, the virtual spring will not rebound. Therefore, after a collision occurs, the first position of the mass point is related to the deformation and the deformation threshold.
[0047] After a collision occurs, the displacement of the mass point and the deformation of the virtual spring affect each other. For example, the greater the displacement of the mass point, the greater the deformation of the virtual spring. If the deformation exceeds a deformation threshold, the mass point will not return to its initial position. Normally, the closer a mass point is to the target mass point where a collision occurred, the greater the displacement, and the greater the deformation of the virtual spring connected to the target mass point where a collision occurred and the virtual spring closer to the target mass point.
[0048] In a specific embodiment, if the deformation amount does not exceed the deformation threshold of the virtual spring, the rebound of the virtual spring is controlled and the first position of the mass point is determined based on the length of the virtual spring after rebound. If the deformation amount exceeds the deformation threshold of the virtual spring, the length of the virtual spring after deformation is determined and the first position of the mass point is determined based on the length of the virtual spring after deformation. The virtual spring here is also called a plastic spring, which is a spring that sags when compressed or pulled, causing permanent deformation. The deformation threshold is also called a plastic threshold. If the deformation amount of the virtual spring exceeds the deformation threshold, the static length of the virtual spring changes, and the position of the mass point also changes permanently. The static length can be understood as the length of the virtual spring when no external force is applied.
[0049] When the deformation amount exceeds the deformation threshold, the position of the mass point is changed permanently, and at this time, the mass point is controlled to change the position of the model vertex in the target model, thereby deforming the target model.
[0050] Furthermore, if the collision is relatively severe, the target model may be partially broken or crushed. To simulate this effect, in one embodiment, when the deformation exceeds the virtual spring's breaking threshold, the virtual spring is removed and the mass points at both ends of the virtual spring are controlled to move away from each other to obtain a first position of the mass point. The breaking threshold is usually greater than the deformation threshold. Taking tension as an example, the virtual spring is pulled by the displacement of the mass point, causing a deformation. As the pulling process continues, the deformation reaches the deformation threshold. As the pulling process continues, the deformation reaches the breaking threshold, at which point the virtual spring breaks. When the virtual spring is compressed, it similarly has a deformation threshold and a breaking threshold. As the virtual spring is compressed, the deformation first reaches the deformation threshold, and as the compression continues, the deformation reaches the breaking threshold.
[0051] When the virtual spring reaches its breaking threshold, in order to simulate the effect of the mass point when the spring breaks, at this time, when the virtual spring is removed, the mass point is no longer connected to the virtual spring, so the movement of the mass point is no longer affected by the virtual spring. In this case, the related algorithm of the dynamics principle can also be used to calculate the first position of the mass point when it is not constrained by the virtual spring.
[0052] This method can simulate the effect of fractures occurring in the target model during a severe collision, for example, the effect of a door falling off in a vehicle model.
[0053] After obtaining the first positions of the mass points, the first positions of each mass point can be stored in a map, and since the number of mass points is small, the amount of data in the map is also small.
[0054] Since the purpose of this embodiment is to control the deformation of the target model using a mass point model, it is necessary to set a mapping relationship between the mass points and the mesh vertices during the process of creating the target model. The following provides a specific method for setting the mapping relationship, which includes the following steps 21 to 24.
[0055] In step 21, the target model and the mass point model are superimposed on a preset world coordinate system.
[0056] At this time, the mesh vertices in the target model and the mass points in the mass point model each have their own world coordinates.
[0057] In step 22, for the mesh vertices in the target model, a predetermined number of target mass points are determined from the mass point model, a local coordinate system is constructed based on the predetermined number of target mass points, and a first transformation relationship between the local coordinate system and the world coordinate system is determined.
[0058] To associate mesh vertices with mass points, step 22 can be performed for each mesh vertex in the target model. Specifically, a predetermined number of target mass points can be determined around the mesh vertices. The target mass points are used to construct a local coordinate system, which determines the relative relationship between the mesh vertices and the target mass points. The predetermined number of target mass points can be determined according to needs, for example, two, three, or other numbers.
[0059] In a specific implementation, for mesh vertices in the target model, the Euclidean distance between the mesh vertices and at least some of the mass points in the mass point model is calculated, and at least some of the mass points are sorted in order of smallest Euclidean distance to obtain a mass point sequence, and the first three mass points in the mass point sequence are determined as target mass points.
[0060] In practice, for each mesh vertex, the Euclidean distance between the mesh vertex and each mass point can be calculated, and the smaller the Euclidean distance, the closer the mass point is to the mesh vertex. If the local coordinate system is a three-dimensional coordinate system, three target mass points need to be determined, and the three mass points with the smallest Euclidean distances are selected as the target mass points of the current mesh vertex.
[0061] It can be understood that a local coordinate system typically includes a coordinate origin and multiple axis directions, and the coordinate origin is typically a coordinate point in the world coordinate system, based on which the transformation relationship of the origin between the local coordinate system and the world coordinate system can be obtained, and the axis directions of the local coordinate system are determined based on the relative positional relationship between multiple target mass points, and the relative positional relationship between the target mass points may be determined by the difference vector between the coordinate points of the target mass points in the world coordinate system, therefore the above first transformation relationship may include the transformation relationship of the origin and the transformation relationship of the axis directions between the local coordinate system and the world coordinate system.
[0062] In a specific implementation, the local coordinate system may be constructed by setting the first mass point at the target mass point as the origin of the local coordinate system, the direction of the connecting line between the first mass point and the second mass point at the target mass point as the first axis direction of the local coordinate system, the direction corresponding to the vector product of the direction of the connecting line between the third mass point at the target mass point and the first axis direction as the second axis direction of the local coordinate system, and the direction perpendicular to both the first axis direction and the second axis direction as the third axis direction of the local coordinate system.
[0063] For example, the three target mass points are represented as mass point n0, mass point n1, and mass point n2, respectively. Here, mass point n0 is the origin of the local coordinate system, and the first axis direction, the second axis direction, and the third axis direction are the X axis direction, the Y axis direction, and the Z axis direction, respectively. Here, the X axis direction is normalize(n1-n0), that is, the coordinate value of mass point n0 in the world coordinate system is subtracted from the coordinate value of mass point n1 in the world coordinate system to obtain a vector from n0 to n1, and the vector is normalized by the normalize function to obtain a unit vector indicating only the direction, which represents the X axis direction.
[0064] Similarly, the Y-axis direction is expressed as normalize(cross(n2-n0,x)). That is, n2-n0 obtains the vector going from n0 to n2, the cross function calculates the vector product of this vector and the X-axis direction, and the normalize function further normalizes this vector product to obtain the Y-axis direction. The Z-axis direction must be perpendicular to the plane formed by the X-axis and Y-axis directions, and the Z-axis direction is determined.
[0065] In step 23, based on the first transformation relationship, the initial rendering parameters in the world coordinate system of the mesh vertices are transformed into the local coordinate system to obtain partial rendering parameters, where the initial rendering parameters include multiple types of position parameters, normal parameters and tangent parameters of the mesh vertices.
[0066] The initial rendering parameters here are configured to determine the rendering method of the mesh vertices, where the position parameters are configured to determine the position at which the mesh vertices are rendered in the world coordinate system, and the normal parameters and tangent parameters affect the lighting effect or other rendering effect of the mesh vertices by rendering the orientation of the mesh vertices. The initial rendering parameters are defined in the world coordinate system, and in this step, these rendering parameters need to be converted to the local coordinate system. After the mass point is displaced, the rendering parameters of the mesh vertices change according to the position of the mass point, thereby controlling the deformation effect of the target model.
[0067] The first transformation relationship can be expressed in the form of a matrix or an inverse matrix. The partial rendering parameters in the local coordinate system can be obtained by multiplying the initial rendering parameters by the first transformation relationship.
[0068] In step 24, the mesh vertices, the target mass points and the partial rendering parameters are determined as the mapping relationship between the mass points and the mesh vertices.
[0069] For each mesh vertex in the target model, a target mass point corresponding to the mesh vertex, a local coordinate system constructed by the target mass point, and a first transformation relationship between the local coordinate system and the world coordinate system can be obtained, and the initial rendering parameters in the world coordinate system can be transformed into partial rendering parameters in the local coordinate system based on the first transformation relationship. Thus, each mesh vertex has a target mass point and partial rendering parameters, which form a mapping relationship corresponding to the mesh vertex.
[0070] After the target model is executed in the virtual scene and a collision event occurs, a first position of the mass point in the mass point model is determined, and the mapping relationship between the mass point and the mesh vertex is also determined in advance. In this case, after the collision occurs, a first rendering parameter in the world coordinate system of the mesh vertex is obtained, which is specifically realized by the following steps 31 to 34.
[0071] In step 31, a predetermined number of target mass points corresponding to the mesh vertices are obtained from the mapping relationship.
[0072] Since a mapping relationship is preset for each mesh vertex in the target model, for each mesh vertex, the target mass point can be obtained from the mapping relationship, and the target mass points corresponding to adjacent mesh vertices may be the same or partially the same.
[0073] In step 32, a deformed coordinate system is constructed based on the first positions of a predetermined number of target mass points, and a second transformation relationship between the deformed coordinate system and a predetermined world coordinate system is determined, where the world coordinate system is constructed in a virtual scene in which the target model and the mass point model are located.
[0074] After a collision event occurs, the position of the target mass point may change, and the above-mentioned first position is the first position of the target mass point after the occurrence of a collision event. If the target mass point is displaced during the collision process, the first position is different from the initial position of the target mass point before the occurrence of the collision event. If the target mass point is not displaced during the collision process, the first position is the same as the initial position of the target mass point before the occurrence of the collision event.
[0075] A deformed coordinate system is constructed using the target mass points using the same construction method as the local coordinate system. Since the target mass points may be displaced, the relative positions between the target mass points also change. Based on this, the axial direction of the deformed coordinate system may be different from the axial direction of the local coordinate system. The origin of the deformed coordinate system and the origin of the local coordinate system can be the same mass point, for example, the mass point n0 can be the origin.
[0076] The second transformation relationship includes a transformation relationship between the origins of the deformed coordinate system and the world coordinate system, and the second transformation relationship further includes an axial transformation relationship. Since the relative positions between the target mass points change after the collision, the axial transformation relationship and the transformation relationship corresponding to the local coordinate system may be different.
[0077] In step 33, the partial rendering parameters corresponding to the mesh vertices are obtained from the mapping relationship.
[0078] The partial rendering parameters here indicate the rendering parameters of the mesh vertices for the mass point, and are calculated using a first transformation relationship corresponding to the local coordinate system, and the partial rendering parameters do not change regardless of how the position of the target mass point changes.
[0079] In step 34, first rendering parameters in the world coordinate system of the mesh vertices are determined based on the second transformation relationship and the partial rendering parameters.
[0080] Because the relative position of the target mass point in the world coordinate system has changed, the partial rendering parameters for the target mass point at the mesh vertex need to be retransformed into the world coordinate system based on the second transformation relationship to obtain the rendering parameters of the mesh vertex in the world coordinate system after the collision event occurs. In actual implementation, the partial rendering parameters can be multiplied by the second transformation relationship or by the inverse matrix of the second transformation relationship to obtain the first rendering parameters. The deformation effect of the target model can be rendered in the virtual scene using the first rendering parameters.
[0081] When the target model is a vehicle model, the above embodiment can realize that the vehicle model deforms after colliding with an obstacle, and the deformed vehicle model can be efficiently rendered in real time in the game scene.
[0082] In the above embodiment, the mass module uses a plastic spring mass model to simulate the deformation of the vehicle model, thereby efficiently updating the rendering parameters of the model vertices and updating the shape of the rendering model in the VertexShader. In actual implementation, the positions of mass points after collision deformation can be calculated in real time using XPBD technology, and the positions of the rendering vertices after deformation can be interpolated in parallel on the GPU using the VertexShader stage in the rendering pipeline.
[0083] Corresponding to the embodiment of the above method, refer to the structural schematic diagram of the virtual model deformation control device shown in Figure 4, which includes a model generation module 40, a position determination module 42, and a parameter determination module 44.
[0084] The model generation module 40 is configured to generate a target model located in a virtual scene and a mass point model corresponding to the target model, where the mass point model and the target model are set to be superimposed on the virtual scene, the mass point model includes a plurality of mass points, the plurality of mass points are connected by virtual springs, the shape consisting of the plurality of mass points matches the shape of the target model, the number of mass points in the mass point model is smaller than the number of mesh vertices in the target model, and there is a pre-set mapping relationship between the mass points and the mesh vertices.
[0085] The position determination module 42 is configured to, in response to the mass point model detecting a collision event, determine a first position of a mass point in the mass point model after the occurrence of the collision event based on the collision parameters of the collision event and the deformation threshold of the virtual spring.
[0086] The parameter determination module 44 is configured to determine first rendering parameters of the mesh vertices in the target model based on the first positions of the mass points in the mass point model and the mapping relationship between the mass points and the mesh vertices, and render the mesh vertices in the target model using the first rendering parameters to obtain a deformed target model.
[0087] The above-mentioned virtual model deformation control device generates a target model located in a virtual scene and a mass point model corresponding to the target model, where the mass point model and the target model are set to be superimposed on the virtual scene, the mass point model includes a plurality of mass points connected by virtual springs, the shape consisting of the plurality of mass points matches the shape of the target model, the number of mass points in the mass point model is smaller than the number of mesh vertices in the target model, and there is a predetermined mapping relationship between the mass points and the mesh vertices, and in response to the mass point model detecting a collision event, determines a first position of the mass point in the mass point model after the occurrence of the collision event based on the collision parameters of the collision event and the deformation threshold of the virtual springs, determines first rendering parameters of the mesh vertices in the target model based on the first position of the mass point in the mass point model and the mapping relationship between the mass points and the mesh vertices, and renders the mesh vertices in the target model using the first rendering parameters to obtain a deformed target model. In this method, a mass point model is set on a target model, and the mass point model contains a small number of mass points, which are connected by virtual springs. A collision event is detected using the mass point model. When a collision occurs, the displacement between the mass points is calculated, and the rendering parameters of the target model after deformation are determined by deforming the virtual springs, and the deformed target model is then rendered and obtained. This method requires a small amount of calculation for deformation, has a realistic deformation effect, and is applicable to real-time rendering virtual scenes.
[0088] Optionally, the virtual model deformation control device further includes a collision detection module configured to detect whether a mass point collides with a mass point in the mass point model in response to the target model being positioned in the virtual scene, and to determine that a collision event is detected when at least one mass point in the mass point model collides.
[0089] Optionally, the position determination module is further configured to, in response to the mass point model detecting a collision event, obtain collision parameters of the collision event, the collision parameters including multiple types of target mass point where the collision occurred, the collision direction, and the collision strength, control to displace each mass point in the mass point model based on the collision parameters, monitor the deformation amount of a virtual spring connecting the mass points during the process of the mass point displacement, and determine a first position of the mass point based on the deformation amount and a deformation threshold.
[0090] Optionally, the position determination module is further configured to: control a rebound of the virtual spring and determine a first position of the mass point based on a length of the rebounded virtual spring when the deformation amount does not exceed a deformation threshold of the virtual spring; and to determine a deformed length of the virtual spring and determine a first position of the mass point based on the deformed length of the virtual spring when the deformation amount exceeds a deformation threshold of the virtual spring.
[0091] Optionally, the virtual model deformation control device further includes a removal module configured to remove the virtual spring and control the mass points at both ends of the virtual spring to move away from each other when the deformation amount exceeds a breaking threshold of the virtual spring, thereby obtaining a first position of the mass point.
[0092] Optionally, the virtual model deformation control device further includes a mapping relationship determination module, which is configured to superimpose the target model and the mass point model on a predetermined world coordinate system, determine a predetermined number of target mass points from the mass point model for mesh vertices in the target model, construct a local coordinate system based on the predetermined number of target mass points, determine a first transformation relationship between the local coordinate system and the world coordinate system, and transform initial rendering parameters in the world coordinate system of the mesh vertices into the local coordinate system based on the first transformation relationship, and obtain partial rendering parameters, where the initial rendering parameters include multiple types of position parameters, normal parameters, and tangent parameters of the mesh vertices, and determine the mesh vertices, target mass points, and partial rendering parameters as mapping relationships between the mass points and the mesh vertices.
[0093] Optionally, the mapping relationship determination module is further configured to calculate, for mesh vertices in the target model, Euclidean distances between the mesh vertices and at least some of the mass points in the mass point model, sort the at least some of the mass points in order of decreasing Euclidean distance to obtain a mass point sequence, and determine the first three mass points in the mass point sequence as target mass points.
[0094] Optionally, the mapping relationship determination module is configured to obtain a local coordinate system by setting a first mass point in the target mass point as the origin of the local coordinate system, a direction of a connecting line between the first mass point and the second mass point in the target mass point as the first axis direction of the local coordinate system, a direction corresponding to the vector product of the direction of a connecting line between a third mass point in the target mass point and the first axis direction as the second axis direction of the local coordinate system, and a direction perpendicular to both the first axis direction and the second axis direction as the third axis direction of the local coordinate system.
[0095] Optionally, the parameter determination module is further configured to obtain a predetermined number of target mass points corresponding to the mesh vertices from the mapping relationship, construct a deformed coordinate system based on first positions of the predetermined number of target mass points, and determine a second transformation relationship between the deformed coordinate system and a predetermined world coordinate system, where the world coordinate system is constructed in a virtual scene in which the target model and the mass point model are located, obtain partial rendering parameters corresponding to the mesh vertices from the mapping relationship, and determine first rendering parameters of the mesh vertices in the world coordinate system based on the second transformation relationship and the partial rendering parameters.
[0096] The present embodiment further provides an electronic device including a processor and a memory, the memory storing machine-executable instructions executable by the processor, and the processor executing the machine-executable instructions to realize the method for controlling deformation of a virtual model. The electronic device may be a server or a touch terminal device.
[0097] As shown in FIG. 5, the electronic device includes a processor 100 and a memory 101, the memory 101 storing machine-executable instructions executable by the processor 100, and the processor 100 executing the machine-executable instructions to realize the above-mentioned virtual model deformation control method.
[0098] Furthermore, the electronic device shown in FIG. 5 further includes a bus 102 and a communication interface 103, and the processor 100, the communication interface 103 and the memory 101 are connected by the bus 102.
[0099] Here, the memory 101 may be composed of a high-speed random access memory (RAM) or a non-volatile memory such as at least one disk memory. Communication connections between this system element and at least one other element are realized via at least one communication interface 103 (which may be wired or wireless), and may use the Internet, a wide area network, a local network, a metropolitan area network, or the like. The bus 102 may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, or the like. For simplicity of illustration, only one bidirectional arrow is used in FIG. 5, but this does not mean that there is only one bus or only one type of bus.
[0100] The processor 100 may be an integrated circuit chip capable of processing signals. In implementation, the steps of the above-described method may be achieved by integrated logic circuits in the hardware of the processor 100 or by instructions in the form of software. The processor 100 may be a general-purpose processor such as a CPU (Central Processing Unit) or an NP (Network Processor), or may be a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), another programmable logic device such as an FPGA (Field-Programmable Gate Array), a discrete gate or transistor logic device, or a discrete hardware component. The methods, steps, and logic block diagrams disclosed in the embodiments of the present disclosure may be implemented or performed. The general-purpose processor may be a microprocessor, or any conventional processor. The steps of the methods disclosed in the embodiments of the present disclosure may be directly implemented in a hardware decoding processing device or may be executed by a combination of hardware and software modules of the decoding processing device. The software modules can be located in random memory, flash memory, read-only memory, programmable read-only memory, or electrically erasable programmable memory, registers, and other storage media well established in the art. The storage media is located in memory 101, and processor 100 reads information in memory 101 and completes the steps of the method in the above embodiment in combination with its hardware.
[0101] The processor of the electronic device executes machine-executable instructions to realize the following operations of the virtual model deformation control method.
[0102] a target model located in a virtual scene and a mass point model corresponding to the target model, wherein the mass point model and the target model are set to be superimposed on the virtual scene, the mass point model includes a plurality of mass points connected by virtual springs, the shape consisting of the plurality of mass points matches the shape of the target model, the number of mass points in the mass point model is smaller than the number of mesh vertices in the target model, and there is a predetermined mapping relationship between the mass points and the mesh vertices; in response to the mass point model detecting a collision event, a first position of the mass point in the mass point model after the occurrence of the collision event is determined based on collision parameters of the collision event and a deformation threshold of the virtual springs; first rendering parameters of the mesh vertices in the target model are determined based on the first position of the mass point in the mass point model and the mapping relationship between the mass points and the mesh vertices; and the mesh vertices in the target model are rendered using the first rendering parameters to obtain a deformed target model.
[0103] Optionally, in response to the target model being positioned in the virtual scene, mass points in the mass point model are used to detect whether mass points collide, and when at least one mass point in the mass point model collides, it is determined that a collision event is detected.
[0104] Optionally, in response to the mass point model detecting a collision event, collision parameters of the collision event are obtained, where the collision parameters include multiple types of target mass point where the collision occurred, the collision direction, and the collision strength, and each mass point in the mass point model is controlled to be displaced based on the collision parameters, and in the process of the mass point displacement, the deformation amount of a virtual spring connecting the mass points is monitored, and a first position of the mass point is determined based on the deformation amount and a deformation threshold.
[0105] Optionally, if the deformation amount does not exceed the deformation threshold of the virtual spring, the rebound of the virtual spring is controlled, and a first position of the mass point is determined based on the length of the rebounded virtual spring; if the deformation amount exceeds the deformation threshold of the virtual spring, the length of the virtual spring after deformation is determined, and a first position of the mass point is determined based on the length of the virtual spring after deformation.
[0106] Optionally, when the deformation amount exceeds a breaking threshold of the virtual spring, the virtual spring is removed and the mass points at both ends of the virtual spring are controlled to move away from each other, thereby obtaining a first position of the mass point.
[0107] Optionally, the mapping relationship between the mass points and the mesh vertices is obtained in the following manner: superimpose the target model and the mass point model on a predetermined world coordinate system; determine a predetermined number of target mass points from the mass point model for the mesh vertices in the target model; construct a local coordinate system based on the predetermined number of target mass points; determine a first transformation relationship between the local coordinate system and the world coordinate system; transform initial rendering parameters in the world coordinate system of the mesh vertices into the local coordinate system based on the first transformation relationship; obtain partial rendering parameters, where the initial rendering parameters include multiple types of position parameters, normal parameters, and tangent parameters of the mesh vertices; and determine the mesh vertices, target mass points, and partial rendering parameters as the mapping relationship between the mass points and the mesh vertices.
[0108] Optionally, for mesh vertices in the target model, calculate the Euclidean distance between the mesh vertices and at least some of the mass points in the mass point model, sort at least some of the mass points in order of smallest Euclidean distance to obtain a mass point sequence, and determine the first three mass points in the mass point sequence as target mass points.
[0109] Optionally, a local coordinate system is obtained by setting the first mass point at the target mass point as the origin of the local coordinate system, the direction of the connecting line between the first mass point and the second mass point at the target mass point as the first axis direction of the local coordinate system, the direction corresponding to the vector product of the direction of the connecting line between the third mass point at the target mass point and the first axis direction as the second axis direction of the local coordinate system, and the direction perpendicular to both the first axis direction and the second axis direction as the third axis direction of the local coordinate system.
[0110] Optionally, obtain a predetermined number of target mass points corresponding to the mesh vertices from the mapping relationship, construct a deformed coordinate system based on first positions of the predetermined number of target mass points, and determine a second transformation relationship between the deformed coordinate system and a predetermined world coordinate system, where the world coordinate system is constructed in a virtual scene in which the target model and the mass point model are located, obtain partial rendering parameters corresponding to the mesh vertices from the mapping relationship, and determine first rendering parameters of the mesh vertices in the world coordinate system based on the second transformation relationship and the partial rendering parameters.
[0111] In this method, a mass point model is placed relative to a target model, and the mass point model contains a small number of mass points that are connected by virtual springs. A collision event is detected using the mass point model, and when a collision occurs, the displacement between the mass points is calculated. The rendering parameters of the target model after deformation are determined by deforming the virtual springs, and the deformed target model is then rendered and obtained. This method requires little computational effort for calculating the deformation, and the deformation effect is realistic, making it applicable to real-time rendering virtual scenes.
[0112] This embodiment further includes a machine-readable storage medium on which machine-executable instructions are stored, which, when called and executed by the processor, cause the above-mentioned virtual model deformation control method to be realized.
[0113] The machine-executable instructions in the machine-readable storage medium are executed to realize the following operations in the virtual model deformation control method.
[0114] a target model located in a virtual scene and a mass point model corresponding to the target model, wherein the mass point model and the target model are set to be superimposed on the virtual scene, the mass point model includes a plurality of mass points connected by virtual springs, the shape consisting of the plurality of mass points matches the shape of the target model, the number of mass points in the mass point model is smaller than the number of mesh vertices in the target model, and there is a predetermined mapping relationship between the mass points and the mesh vertices; in response to the mass point model detecting a collision event, a first position of the mass point in the mass point model after the occurrence of the collision event is determined based on collision parameters of the collision event and a deformation threshold of the virtual springs; first rendering parameters of the mesh vertices in the target model are determined based on the first position of the mass point in the mass point model and the mapping relationship between the mass points and the mesh vertices; and the mesh vertices in the target model are rendered using the first rendering parameters to obtain a deformed target model.
[0115] Optionally, in response to the target model being positioned in the virtual scene, mass points in the mass point model are used to detect whether mass points collide, and when at least one mass point in the mass point model collides, it is determined that a collision event is detected.
[0116] Optionally, in response to the mass point model detecting a collision event, collision parameters of the collision event are obtained, where the collision parameters include multiple types of target mass point where the collision occurred, the collision direction, and the collision strength, and each mass point in the mass point model is controlled to be displaced based on the collision parameters, and in the process of the mass point displacement, the deformation amount of a virtual spring connecting the mass points is monitored, and a first position of the mass point is determined based on the deformation amount and a deformation threshold.
[0117] Optionally, if the deformation amount does not exceed the deformation threshold of the virtual spring, the rebound of the virtual spring is controlled, and a first position of the mass point is determined based on the length of the rebounded virtual spring; if the deformation amount exceeds the deformation threshold of the virtual spring, the length of the virtual spring after deformation is determined, and a first position of the mass point is determined based on the length of the virtual spring after deformation.
[0118] Optionally, when the deformation amount exceeds a breaking threshold of the virtual spring, the virtual spring is removed and the mass points at both ends of the virtual spring are controlled to move away from each other, thereby obtaining a first position of the mass point.
[0119] Optionally, the mapping relationship between the mass points and the mesh vertices is obtained in the following manner: superimpose the target model and the mass point model on a predetermined world coordinate system; determine a predetermined number of target mass points from the mass point model for the mesh vertices in the target model; construct a local coordinate system based on the predetermined number of target mass points; determine a first transformation relationship between the local coordinate system and the world coordinate system; transform initial rendering parameters in the world coordinate system of the mesh vertices into the local coordinate system based on the first transformation relationship; obtain partial rendering parameters, where the initial rendering parameters include multiple types of position parameters, normal parameters, and tangent parameters of the mesh vertices; and determine the mesh vertices, target mass points, and partial rendering parameters as the mapping relationship between the mass points and the mesh vertices.
[0120] Optionally, for mesh vertices in the target model, calculate the Euclidean distance between the mesh vertices and at least some of the mass points in the mass point model, sort at least some of the mass points in order of smallest Euclidean distance to obtain a mass point sequence, and determine the first three mass points in the mass point sequence as target mass points.
[0121] Optionally, a local coordinate system is obtained by setting the first mass point at the target mass point as the origin of the local coordinate system, the direction of the connecting line between the first mass point and the second mass point at the target mass point as the first axis direction of the local coordinate system, the direction corresponding to the vector product of the direction of the connecting line between the third mass point at the target mass point and the first axis direction as the second axis direction of the local coordinate system, and the direction perpendicular to both the first axis direction and the second axis direction as the third axis direction of the local coordinate system.
[0122] Optionally, obtain a predetermined number of target mass points corresponding to the mesh vertices from the mapping relationship, construct a deformed coordinate system based on first positions of the predetermined number of target mass points, and determine a second transformation relationship between the deformed coordinate system and a predetermined world coordinate system, where the world coordinate system is constructed in a virtual scene in which the target model and the mass point model are located, obtain partial rendering parameters corresponding to the mesh vertices from the mapping relationship, and determine first rendering parameters of the mesh vertices in the world coordinate system based on the second transformation relationship and the partial rendering parameters.
[0123] In this method, a mass point model is placed relative to a target model, and the mass point model contains a small number of mass points that are connected by virtual springs. A collision event is detected using the mass point model, and when a collision occurs, the displacement between the mass points is calculated. The rendering parameters of the target model after deformation are determined by deforming the virtual springs, and the deformed target model is then rendered and obtained. This method requires little computational effort for calculating the deformation, and the deformation effect is realistic, making it applicable to real-time rendering virtual scenes.
[0124] A computer program product for a virtual model deformation control method, device, and electronic device according to an embodiment of the present disclosure includes a computer-readable storage medium having program code stored thereon, the program code including instructions that can be used to execute the method described in the previous method embodiment, and the specific implementation method thereof is described in the method embodiment, and will not be described here.
[0125] As will be apparent to those skilled in the art, for convenience and conciseness of description, the specific work processes of the above-described systems and apparatuses can refer to the corresponding processes in the preceding method embodiments, and the description thereof will be omitted here.
[0126] Furthermore, in describing the embodiments of the present application, unless otherwise expressly specified and limited, the terms "mounted," "connected," and "coupled" are to be understood in broad senses, such as fixed connection, detachable connection, or integral connection, mechanical connection or electrical connection, direct connection or indirect connection through an intermediate medium, or internal connection between two components. Those skilled in the art will be able to understand the specific meaning of the above terms in the context of the present disclosure in specific cases.
[0127] The described functions may be implemented in the form of a software functional unit and stored in a computer-readable storage medium when sold or used as a separate product. It is understood that the technical solution of the present disclosure, or that part of the technical solution that essentially or contributes to the prior art, may be embodied in the form of a software product stored in a storage medium containing a number of instructions for enabling a computer device (which may be a personal computer, a server, a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present disclosure. The aforementioned storage medium may be various media capable of storing program code, such as a USB memory, a removable hard disk, a ROM (Read-Only Memory), a RAM (Random Access Memory), a diskette, or a CD-ROM.
[0128] In the description of this application, orientations or positional relationships indicated as "center," "top," "bottom," "left," "right," "vertical," "horizontal," "inside," "outside," etc., are based on orientations or positional relationships shown in the accompanying drawings and are intended solely to facilitate and simplify the description of this disclosure and do not imply or indicate that the referenced devices or elements must have a particular orientation or be constructed or operate in a particular orientation, and therefore should not be construed as limiting this application. Furthermore, the terms "first," "second," and "third" are used for descriptive purposes only and do not imply or denote relative importance.
[0129] Finally, it should be noted that the above examples are merely specific examples of the present disclosure, intended to illustrate the technical solutions of the present disclosure but not to limit them, and the scope of protection of the present disclosure is not limited thereto. Although the present disclosure has been described in detail with reference to the above examples, those skilled in the art should understand that the following is possible within the technical scope disclosed in the present disclosure: The technical solutions recorded in the above examples can be modified or easily considered as modifications of some of their technical features or equivalent replacements, and such modifications, variations, or replacements do not deviate from the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the examples of the present disclosure and are to be included in the scope of protection of the present disclosure. Therefore, the scope of protection of the present disclosure is subject to the scope of protection of the claims.
Claims
1. a step of generating a target model located in a virtual scene and a mass point model corresponding to the target model, wherein the mass point model and the target model are set to be superimposed on the virtual scene, the mass point model includes a plurality of mass points, the plurality of mass points are connected by virtual springs, a shape formed by the plurality of mass points matches a shape of the target model, the number of mass points in the mass point model is smaller than the number of mesh vertices in the target model, and a preset mapping relationship exists between the mass points and the mesh vertices; In response to the mass point model detecting a collision event, determining a first position of a mass point in the mass point model after the occurrence of the collision event based on a collision parameter of the collision event and a deformation threshold of the virtual spring; determining first rendering parameters for mesh vertices in the target model based on first positions of mass points in the mass point model and mapping relationships between the mass points and the mesh vertices; and rendering the mesh vertices in the target model using the first rendering parameters to obtain a deformed target model. A method for controlling deformation of a virtual model.
2. After generating a target model located in a virtual scene and a mass point model corresponding to the target model, the method for controlling deformation of the virtual model includes: In response to the target model being positioned in the virtual scene, detecting whether the mass point collides with the mass point in the mass point model; determining that a collision event is detected when at least one mass point in the mass point model collides. The method for controlling deformation of a virtual model according to claim 1 .
3. determining, in response to the mass point model detecting a collision event, a first position of a mass point in the mass point model after the occurrence of the collision event based on a collision parameter of the collision event and a deformation threshold value of the virtual spring, acquiring collision parameters of the collision event in response to the mass point model detecting the collision event, the collision parameters including a target mass point with which the collision occurred, a collision direction, and a collision strength; a step of controlling the displacement of each mass point in the mass point model based on the collision parameters, and monitoring the deformation amount of a virtual spring connecting the mass points during the displacement of the mass points; determining a first position of the mass point based on the deformation amount and the deformation threshold. The method for controlling deformation of a virtual model according to claim 1 .
4. The step of determining a first position of the mass point based on the deformation amount and the deformation threshold value includes: If the deformation amount does not exceed a deformation threshold of the virtual spring, controlling a rebound of the virtual spring and determining a first position of the mass point based on a length of the rebounded virtual spring; if the deformation amount exceeds a deformation threshold value of the virtual spring, determining a length of the virtual spring after deformation, and determining a first position of the mass point based on the length of the virtual spring after deformation.
4. The method for controlling deformation of a virtual model according to claim 3.
5. and if the deformation amount exceeds a breaking threshold of the virtual spring, removing the virtual spring and controlling mass points at both ends of the virtual spring to move away from each other, thereby obtaining a first position of the mass point.
4. The method for controlling deformation of a virtual model according to claim 3.
6. The mapping relationship between the mass points and the mesh vertices is obtained in the following manner: The target model and the mass point model are superimposed on a preset world coordinate system; determining a predetermined number of target mass points from the mass point model for mesh vertices in the target model, constructing a local coordinate system based on the predetermined number of target mass points, and determining a first transformation relationship between the local coordinate system and the world coordinate system; Transforming initial rendering parameters of the mesh vertices in the world coordinate system into the local coordinate system based on the first transformation relationship to obtain partial rendering parameters, the initial rendering parameters including multiple types of position parameters, normal parameters, and tangent parameters of the mesh vertices; determining the mesh vertices, the target mass points and the partial rendering parameters as a mapping relationship between the mass points and the mesh vertices; The method for controlling deformation of a virtual model according to claim 1 .
7. The step of determining a predetermined number of target mass points from the mass point model for mesh vertices in the target model includes: For mesh vertices in the target model, calculating Euclidean distances between the mesh vertices and at least some of the mass points in the mass point model; sorting the at least some of the mass points in order of decreasing Euclidean distance to obtain a mass point sequence, and determining first three mass points of the mass point sequence as the target mass point; 7. The method for controlling deformation of a virtual model according to claim 6.
8. The step of constructing a local coordinate system based on the predetermined number of target mass points includes: A step of setting a first mass point in the target mass point as the origin of a local coordinate system; a step of setting a direction of a connecting line between the first mass point and the second mass point at the target mass point as a first axis direction of the local coordinate system; a step of setting a direction corresponding to a vector product of a direction of a connecting line between a third mass point and the first mass point in the target mass point and the first axis direction as a second axis direction of the local coordinate system; and obtaining the local coordinate system by setting a direction perpendicular to both the first axis direction and the second axis direction as a third axis direction of the local coordinate system.
7. The method for controlling deformation of a virtual model according to claim 6.
9. determining first rendering parameters of mesh vertices in the target model based on first positions of mass points in the mass point model and mapping relationships between the mass points and the mesh vertices, obtaining a predetermined number of target mass points corresponding to the mesh vertices from the mapping relationship; constructing a deformed coordinate system based on first positions of the predetermined number of target mass points, and determining a second transformation relationship between the deformed coordinate system and a preset world coordinate system, the world coordinate system being constructed in a virtual scene in which the target model and the mass point model are located; obtaining partial rendering parameters corresponding to the mesh vertices from the mapping relationship; determining first rendering parameters for the mesh vertices in the world coordinate system based on the second transformation relationship and the partial rendering parameters; The method for controlling deformation of a virtual model according to claim 1 .
10. A virtual model deformation control device comprising a model generation module, a position determination module, and a parameter determination module, the model generation module is configured to generate a target model located in a virtual scene and a mass point model corresponding to the target model, the mass point model and the target model are set to be superimposed on the virtual scene, the mass point model includes a plurality of mass points, the plurality of mass points are connected by virtual springs, a shape consisting of the plurality of mass points matches a shape of the target model, the number of mass points in the mass point model is smaller than the number of mesh vertices in the target model, and a preset mapping relationship exists between the mass points and the mesh vertices; the position determination module is configured to, in response to the mass model detecting a collision event, determine a first position of a mass point in the mass model after the occurrence of the collision event based on a collision parameter of the collision event and a deformation threshold of the virtual spring; the parameter determination module is configured to determine first rendering parameters of mesh vertices in the target model based on first positions of mass points in the mass point model and a mapping relationship between the mass points and the mesh vertices, and render the mesh vertices in the target model using the first rendering parameters to obtain a deformed target model; A virtual model deformation control device characterized by:
11. An electronic device including a processor and a memory, wherein the memory stores machine-executable instructions executable by the processor, and the processor executes the machine-executable instructions to realize the method for controlling deformation of a virtual model according to any one of claims 1 to 9. An electronic device characterized by:
12. A machine-readable storage medium on which machine-executable instructions are stored, the machine-executable instructions causing the processor to implement the method for controlling deformation of a virtual model according to any one of claims 1 to 9, when the machine-executable instructions are called and executed by a processor. A machine-readable storage medium comprising:
Citation Information
Patent Citations
Deformation simulation method and cut simulation method for object using adaptive mesh, and deformation simulation program and cut simulation program for object using adaptive mesh
JP2007140814A
Hybrid element having solid / SPH coupling effect
JP2011248882A
Physical simulations on graphics processor
JP2013020631A
Apparatus, system and method for simulating material
JP2013101611A