Model Processing Method, Model Processing Device, Electronic Device and Readable Storage Medium
By determining the target collision area in the river model that collides with the water flow, and planning the wiring grid according to different grid densities, the problems of limited river flow simulation details and excessive model files in the existing technology are solved, and efficient water flow detail simulation and reasonable size of model files are achieved.
Patent Information
- Application Number
- CN202111563929.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-20
- Publication Date
- 2025-06-13
- Estimated Expiration
- 2041-12-20
AI Technical Summary
When simulating river flows, the simulated flow direction details are limited due to the limited model wiring density, and the fluid diagram needs to be perfectly consistent with the UV of the model, resulting in too large model files and unusable.
By determining the target collision area in the river model that collides with the water flow and planning the wiring grid according to different grid densities, the water flow details of the target collision area are increased, and the details of the area are not required to be paid attention to, ensuring that there is enough flow details in the model without causing the model file to be too large.
This achieves the problem of excessive model files while ensuring sufficient flow details in the river model, and ensures the availability of the model.
Smart Images

Figure CN114255306B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computers, and in particular to a model processing method, a model processing device, an electronic device, and a readable storage medium. Background Art
[0002] In games, in order to simulate a realistic water flow effect, a fluid map is usually used to simulate the water flow in a river. The fluid map technology is to convert the 3D feature vectors in 3D space into 2D feature vectors in the UV plane and project the values within the range of 0-1. The fluid map records the vector information on the UV plane through a red-green channel texture map. Furthermore, in the engine, the UV can be deformed along a specific direction through this value to create a flowing effect. The data included in the fluid map is not complex and only includes simple color information. The reason why the fluid map is widely used in the game production process is that it can be used to simulate and generate very accurate flow details. Although the simulated result is not at the pixel level, it far exceeds the acceptable range of the game.
[0003] However, due to the limitation of the model wiring density, the simulated flow details will also be limited. And the biggest drawback of the fluid map is that as a texture map, it needs to perfectly match the model's UV within the range of 0-1. If the complete river model is composed of multiple sub-models spliced together, then as many fluid maps as there are sub-models for splicing are required; and in most cases, a complete river needs to be composed of multiple single models (i.e., sub-models, such as square patches) spliced together. Therefore, in order to make the simulated river have more flow details, only by increasing the model wiring density can the simulation realism be increased, but a large wiring density will make the model too large to be used. Summary of the Invention
[0004] In view of this, the purpose of this application is to provide a model processing method, a model processing device, an electronic device, and a readable storage medium, which can determine the target collision area in the river model where the water flow collides, thereby increasing the water flow details in the target collision area. Furthermore, it ensures that there are sufficient flow details in the simulated river and avoids the situation of being unusable due to the overly large model file.
[0005] An embodiment of this application provides a model processing method, and the model processing method includes:
[0006] Obtain the initial flow curve of the virtual water flow after colliding with the target obstacle in the river to be simulated;
[0007] Determine a target collision area where the virtual water flow collides with the target obstacle according to the flow parameters characterized by the initial flow curve and the preset normal parameters of each vertex position on the boundary of the target obstacle in the initial river model;
[0008] Plan wiring grids within the target collision area according to a first grid density and plan wiring grids outside the target collision area according to a second grid density to obtain a river model to be filled after wiring;
[0009] Determine the vertex filling color of the corresponding grid vertices in the river model to be filled according to the flow parameters characterized by the initial flow curve;
[0010] Fill the grid vertices with the vertex filling color to obtain a filled target river model.
[0011] In a possible implementation manner, the determining the vertex filling color of the corresponding grid vertices in the river model to be filled according to the flow parameters characterized by the initial flow curve includes:
[0012] Respond to a disturbance increase instruction for the initial flow curve, and determine a disturbance parameter for changing the flow parameters characterized by the initial flow curve within the target collision area;
[0013] Use the disturbance parameter to change the flow parameters characterized by the initial flow curve located within the target collision area to obtain a target flow curve; wherein, the fluctuation amplitude of the curve within the target collision area in the target flow curve is greater than the fluctuation amplitude of the curve within the target collision area in the initial flow curve;
[0014] Determine the vertex filling color of the corresponding grid vertices in the river model to be filled according to the flow parameters characterized by the target flow curve.
[0015] In a possible implementation manner, the determining the target collision area where the virtual water flow collides with the target obstacle according to the flow parameters characterized by the initial flow curve and the preset normal parameters of each vertex position on the boundary of the target obstacle in the initial river model includes:
[0016] According to the location of the target obstacle in the initial river model, determine the area around the target obstacle as a candidate collision area;
[0017] Based on the flow parameters characterized by the initial flow curve in the candidate collision area and the preset normal parameters of each vertex position on the boundary of the target obstacle, determine the target collision area from the candidate collision area; wherein, the virtual water flow flows in the direction towards the target obstacle when flowing through the target collision area.
[0018] In a possible implementation, determining the area around the target obstacle as the candidate collision area according to the location of the target obstacle in the initial river model includes:
[0019] Determining the relative distance between the boundary position of each initial grid in the initial river model and the target obstacle;
[0020] Determining the area formed by the initial grids with relative distances within a preset distance range as the candidate collision area.
[0021] In a possible implementation, determining the target collision area from the candidate collision area based on the flow parameters characterized by the initial flow curve in the candidate collision area and the preset normal parameters at each vertex position on the boundary of the target obstacle includes:
[0022] For each initial grid covered by the candidate collision area, determining the flow direction vector at the position of this initial grid according to the flow parameters of the water flow at this initial grid position;
[0023] For each vertex position on the boundary of the target obstacle, determining the preset normal vector at this vertex position according to the preset normal parameters at this vertex position;
[0024] Based on the flow direction vector of each initial grid and the preset normal vector of each vertex position, determining the target grids that make up the target collision area from the multiple initial grids covered by the candidate collision area, and obtaining the target collision area.
[0025] In a possible implementation, obtaining the initial flow curve of the virtual water flow after colliding with the target obstacle in the river to be simulated includes:
[0026] Controlling multiple fluid particles to slide along the surface of the initial river model of the river to be simulated pre-constructed, and determining the sliding trajectory of each fluid particle after colliding with the target obstacle in the initial river model;
[0027] Based on the sliding trajectory of each fluid particle, simulating and obtaining the initial flow curve of the virtual water flow flowing in the river to be simulated.
[0028] In a possible implementation, the model processing method further includes:
[0029] According to the wiring grid in the target river model, splitting and storing the target river model into multiple sub-river models for the rendering engine to render the river to be simulated based on the multiple sub-river models.
[0030] In a possible implementation, the first grid density is greater than the second grid density.
[0031] The embodiment of the present application also provides a model processing device, which includes:
[0032] A curve acquisition module, configured to acquire an initial flow curve after a virtual water flow collides with a target obstacle in a river to be simulated;
[0033] A region determination module, configured to determine a target collision region where the virtual water flow collides with the target obstacle according to the flow parameters characterized by the initial flow curve and the preset normal parameters of each vertex position on the boundary of the target obstacle in the initial river model;
[0034] A wiring planning module, configured to plan wiring grids within the target collision region according to a first grid density and plan wiring grids outside the target collision region according to a second grid density, so as to obtain a river model to be filled after wiring;
[0035] A vertex color determination module, configured to determine a vertex filling color of a corresponding grid vertex in the river model to be filled according to the flow parameters characterized by the initial flow curve;
[0036] A model filling module, configured to fill the grid vertex with the vertex filling color to obtain a filled target river model.
[0037] In a possible implementation, when the vertex color determination module is used to determine the vertex filling color of the corresponding grid vertex in the river model to be filled according to the flow parameters characterized by the initial flow curve, the vertex color determination module is configured to:
[0038] Respond to a perturbation increase instruction for the initial flow curve, and determine a perturbation parameter for changing the flow parameters characterized by the initial flow curve within the target collision region;
[0039] Use the perturbation parameter to change the flow parameters characterized by the initial flow curve within the target collision region to obtain a target flow curve; wherein, the fluctuation amplitude of the curve within the target collision region in the target flow curve is greater than the fluctuation amplitude of the curve within the target collision region in the initial flow curve;
[0040] Determine the vertex filling color of the corresponding grid vertex in the river model to be filled according to the flow parameters characterized by the target flow curve.
[0041] In a possible implementation, when the region determination module is used to determine a target collision region where the virtual water flow collides with the target obstacle according to the flow parameters characterized by the initial flow curve and the preset normal parameters of each vertex position on the boundary of the target obstacle in the initial river model, the region determination module is used to:
[0042] According to the location of the target obstacle in the initial river model, determine the area around the target obstacle as the candidate collision region;
[0043] Based on the flow parameters characterized by the initial flow curve in the candidate collision region and the preset normal parameters of each vertex position on the boundary of the target obstacle, determine the target collision region from the candidate collision region; wherein, when the virtual water flow flows through the target collision region, it flows in the direction towards the target obstacle.
[0044] In a possible implementation, when the region determination module is used to determine the area around the target obstacle as the candidate collision region according to the location of the target obstacle in the initial river model, the region determination module is used to:
[0045] Determine the relative distance between the boundary position of each initial grid in the initial river model and the target obstacle;
[0046] Determine the area formed by the initial grids with relative distances within a preset distance range as the candidate collision region.
[0047] In a possible implementation, when the region determination module is used to determine the target collision region from the candidate collision region based on the flow parameters characterized by the initial flow curve in the candidate collision region and the preset normal parameters of each vertex position on the boundary of the target obstacle, the region determination module is used to:
[0048] For each initial grid covered by the candidate collision region, determine the flow direction vector at the position of this initial grid according to the flow parameters of the water flow at the position of this initial grid;
[0049] For each vertex position on the boundary of the target obstacle, determine the preset normal vector at this vertex position according to the preset normal parameters at this vertex position;
[0050] Based on the flow direction vector of each initial grid and the preset normal vector of each vertex position, determine the target grids that form the target collision region from the multiple initial grids covered by the candidate collision region, and obtain the target collision region.
[0051] In a possible implementation, when the curve acquisition module is used to acquire the initial flow curve of the virtual water flow after colliding with the target obstacle in the river to be simulated, the curve acquisition module is used to:
[0052] Control a plurality of fluid particles to slide along the surface of the initial river model of the river to be simulated that is pre-constructed, and determine the sliding trajectories of each fluid particle after colliding with the target obstacle in the initial river model;
[0053] Based on the sliding trajectories of each fluid particle, simulate and obtain the initial flow curve of the virtual water flow flowing in the river to be simulated.
[0054] In a possible implementation, the model processing device further includes a model splitting module, and the model splitting module is used to:
[0055] According to the wiring grid in the target river model, split and store the target river model into a plurality of sub-river models for the rendering engine to render the river to be simulated based on the plurality of sub-river models.
[0056] In a possible implementation, the first grid density is greater than the second grid density.
[0057] An embodiment of the present application further provides an electronic device, including: a processor, a memory, and a bus. The memory stores machine-readable instructions executable by the processor. When the electronic device runs, the processor communicates with the memory through the bus. When the machine-readable instructions are executed by the processor, the steps of the model processing method as described above are executed.
[0058] An embodiment of the present application further provides a computer-readable storage medium. A computer program is stored on the computer-readable storage medium. When the computer program is run by a processor, the steps of the model processing method as described above are executed.
[0059] The model processing method, model processing device, electronic device, and storage medium provided by the embodiments of the present application obtain the initial flow curve of virtual water flow after colliding with a target obstacle in a river to be simulated; determine the target collision area where the virtual water flow collides with the target obstacle according to the flow parameters characterized by the initial flow curve and the preset normal parameters of each vertex position on the boundary of the target obstacle in the initial river model; plan the wiring grid within the target collision area according to the first grid density and plan the wiring grid outside the target collision area according to the second grid density to obtain the to-be-filled river model after wiring; determine the vertex filling color of the corresponding grid vertices in the to-be-filled river model according to the flow parameters characterized by the initial flow curve; and fill the grid vertices with the vertex filling color to obtain the filled target river model. In this way, the target collision area where the water flow collides with the river model can be determined, thereby increasing the water flow details in the target collision area. Furthermore, it not only ensures that sufficient flow direction details are retained in the simulated river but also avoids the situation where the model file is too large to be used.
[0060] To make the above objects, features, and advantages of the present application more obvious and understandable, the following specifically gives preferred embodiments and, in conjunction with the accompanying drawings, makes a detailed description as follows. BRIEF DESCRIPTION OF THE DRAWINGS
[0061] To more clearly illustrate the technical solutions of the embodiments of the present application, the following briefly introduces the accompanying drawings required for use in the embodiments. It should be understood that the following drawings only show some embodiments of the present application and should not be regarded as limiting the scope. For those of ordinary skill in the art, other related drawings can be obtained based on these drawings without creative efforts.
[0062] Figure 1 A flowchart of a model processing method provided by an embodiment of the present application;
[0063] Figure 2 A schematic diagram of the normal line of a target obstacle provided by an embodiment of the present application;
[0064] Figure 3 A schematic diagram of the process for determining a target collision area provided by an embodiment of the present application;
[0065] Figure 4 A schematic diagram of a partial initial river model provided by an embodiment of the present application;
[0066] Figure 5 A schematic diagram of the structure of a model processing device provided by an embodiment of the present application;
[0067] Figure 6The second structural schematic diagram of a model processing device provided by an embodiment of the present application;
[0068] Figure 7 The structural schematic diagram of an electronic device provided by an embodiment of the present application. Specific implementation manners
[0069] To make the objectives, technical solutions, and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. Apparently, the described embodiments are only some, but not all, of the embodiments of the present application. Components of the embodiments of the present application described and illustrated in the accompanying drawings here can be arranged and designed in various different configurations. Therefore, the detailed description of the embodiments of the present application provided in the accompanying drawings here is not intended to limit the scope of the claimed present application, but merely represents selected embodiments of the present application. Based on the embodiments of the present application, every other embodiment obtained by those skilled in the art without creative efforts shall fall within the protection scope of the present application.
[0070] It has been found through research that due to the limitation of the model wiring density, the simulated flow details will also be limited accordingly. Moreover, the biggest drawback of the fluid map is that as a kind of texture map, it needs to perfectly match the model's UV within the range of 0 - 1. If a complete river model is composed of multiple sub-models spliced together, then as many fluid maps as there are sub-models for splicing will be required; and in most cases, a complete river needs to be composed of multiple single models (i.e., sub-models, such as square patches) spliced together. For example, to simulate a river with obstacles such as rocks, in order to perfectly simulate the flow direction of the river and bypass the rocks and other obstacles in the middle of the river, a river may require 30 sub-models for simulation, that is, 30 fluid maps; the memory consumption of one fluid map is approximately equal to 160M; then, the total memory consumption of the entire river will exceed 4G, which is undoubtedly a large amount of computation for the engine.
[0071] However, in order to make the simulated river have more flow details, it is only possible to increase the simulation realism by increasing the model wiring density, but a larger wiring density will further increase the size of the model, making the model too large to be used.
[0072] Based on this, the embodiments of the present application provide a model processing method, which can determine the target collision area where the virtual water flow collides with the obstacle. Furthermore, by increasing the grid wiring in the target collision area, the water flow direction details in the target collision area can be increased, and then by reducing the grid wiring in the target collision area, the details in the area that does not need to be concerned can be reduced. While ensuring that there are sufficient flow details in the model, it can also ensure that the model file is not too large, ensuring that the model can be used.
[0073] When the water flow flows in the river, it usually fluctuates and changes due to hitting obstacles. For example, water ripples are generated. At this time, there are details of water flow changes near the obstacle. In order to ensure that the obtained river model can imitate the details of the water flow changes caused by the collision, the water flow is usually accurately simulated by increasing the wiring density; however, since the area affected by the collision is limited, the area far from the obstacle is not affected by the collision. Most of the areas affected by the collision are near the obstacle. Therefore, in fact, there are no "details" caused by the collision in every corner of the river; so, if the entire river model uses a high-density method for grid wiring, it will undoubtedly increase the size of the model and increase the burden on the engine.
[0074] Please refer to Figure 1 , Figure 1 which is a flowchart of a model processing method provided by the embodiments of the present application. As Figure 1 shown in
[0075] S101. Obtain the initial flow curve of the virtual water flow after colliding with the target obstacle in the river to be simulated.
[0076] S102. Determine the target collision area where the virtual water flow collides with the target obstacle according to the flow parameters represented by the initial flow curve and the preset normal parameters of each vertex position on the boundary of the target obstacle in the initial river model.
[0077] S103. Plan the wiring grid in the target collision area according to the first grid density, and plan the wiring grid outside the target collision area according to the second grid density to obtain the to-be-filled river model after wiring.
[0078] S104. Determine the vertex filling color of the corresponding grid vertex in the to-be-filled river model according to the flow parameters represented by the initial flow curve at the grid vertex position.
[0079] S105. Fill the grid vertex with the vertex filling color to obtain the filled target river model.
[0080] A model processing method provided by an embodiment of the present application can pre-simulate an initial flow curve of virtual water flowing in a river to be simulated, and determine a target collision area where the virtual water collides with a target obstacle according to the flow parameters represented by the initial flow curve and the preset normal parameters of each vertex position on the boundary of the target obstacle in the initial river model. By separately dividing the grid wiring within the target collision area and the grid wiring outside the target collision area, while ensuring that the details of the water flow direction are not lost, it can also ensure that the resulting river model to be filled after wiring will not be too large.
[0081] In step S101, for the river to be simulated, an initial flow curve of virtual water flowing on its surface can be simulated according to its river direction, starting position, ending position, the position of obstacles in the river, and meandering conditions, etc. This initial flow curve can accurately represent the real flow situation of the virtual water when flowing through each position in the river to be simulated.
[0082] In one implementation, step S101 includes: controlling a plurality of fluid particles to slide along the surface of the initial river model of the river to be simulated that is pre-constructed, and determining the sliding trajectory of each fluid particle after colliding with the target obstacle in the initial river model; based on the sliding trajectories of each fluid particle, simulating the initial flow curve of the virtual water flowing in the river to be simulated.
[0083] The initial river model is established for the river to be simulated, that is, the river direction, starting position, ending position, the position of the target obstacle, and the meandering degree represented by the initial river model are the same as those of the river to be simulated.
[0084] In this step, in order to obtain a more detailed water flow direction, Houdini can be used for flow particle calculation. Specifically, control a plurality of fluid particles to slide along the surface of the initial river model pre-constructed for the river to be simulated, and calculate in real time parameters such as the speed and orientation of each fluid particle at each position when sliding across the initial river model. At the same time, after the fluid particle collides with the target obstacle in the initial river model, the sliding trajectory of the fluid particle after encountering the target obstacle can also be determined.
[0085] Thus, by accumulating the sliding trajectories of each fluid particle, the initial flow curve of the virtual water flowing in the river to be simulated represented by the initial river model is simulated; the initial flow curve can show the flow trajectory of the virtual water when encountering the target obstacle in the river to be simulated, that is, it can present the flow situation of the water flowing in the river to be simulated with a relatively high degree of reduction.
[0086] The target collision area refers to the area affected by the collision between the virtual water flow and the target obstacle. For example, the area where water ripples are generated, etc.
[0087] According to common sense, when water flows in a river, it can only collide with the target obstacle and generate an affected target collision area when the water flow moves towards the location where the target obstacle is located. In model rendering, it can be understood that when the flow direction of the virtual water flow at a certain position is opposite to the direction indicated by the normal of the target obstacle, it indicates that when the virtual water flow passes through this position, it is already in the stage of approaching the target obstacle, and the water surface at this position will be affected by the collision between the water flow and the target obstacle. When the virtual water flow moves away from the target obstacle, it will not collide with the target obstacle, so no affected target collision area will be generated. In model rendering, it can be understood that when the flow direction of the virtual water flow at a certain position is the same as or perpendicular to the direction indicated by the normal of the target obstacle, it indicates that when the virtual water flow passes through this position, it is already in the stage of moving away from the target obstacle, and the water surface at this position will not be affected by the collision between the virtual water flow and the target obstacle. Therefore, the relative direction between the flow direction of the virtual water flow at each position and the direction pointed by the target obstacle can be determined by the flow parameters characterized by the initial flow curve and the preset normal parameters of each vertex position of the target obstacle. Here, the relative direction includes the perpendicular direction, the same direction, and the opposite direction.
[0088] The initial flow curve can characterize the flow parameters of the virtual water flow at each position of the river to be simulated. For example, the flow direction, flow velocity, flow position, and flow intensity, etc. At this time, only by relying on the flow parameters of the virtual water flow passing through each position and the preset normal parameters of each vertex position on the boundary of the target obstacle, the relative direction between the virtual water flow and each vertex position of the target obstacle at each position can be determined. Combining the relative directions at each vertex position, it can be determined whether the water surface at this position will be affected by the virtual water flow and the target obstacle.
[0089] In step S102, the target collision area where the virtual water flow can truly collide with the obstacle is determined by the flow parameters characterized by the initial flow curve and the preset normal parameters of each vertex position on the boundary of the target obstacle in the initial river model.
[0090] Here, since the target obstacle is an irregular object, such as a stone or a branch in a river, there will be multiple protruding points on the boundary of the target obstacle. Each protruding point can be regarded as the vertex position of the boundary of the target obstacle. Or, several position points can be randomly selected from the boundary of the target obstacle and regarded as the vertex positions of the boundary of the target obstacle.
[0091] For each vertex position, a direction facing outward is randomly assigned to the vertex position, and this outward direction is used as the preset normal of the vertex position. The parameters (such as direction, etc.) of this preset normal are used as the preset normal parameters of the vertex position.
[0092] Please refer to Figure 2 , Figure 2 , which is a schematic diagram of the normal of a target obstacle provided by an embodiment of the present application. As Figure 2 shown, the target obstacle 2a has 6 vertex positions 2b to 2g. The normal of vertex position 2b is 2h, the normal of vertex position 2c is 2i, the normal of vertex position 2d is 2j, the normal of vertex position 2e is 2k, the normal of vertex position 2f is 2l, and the normal of vertex position 2g is 2m.
[0093] In one implementation, please refer to Figure 3 , Figure 3 , which is a schematic flowchart of a method for determining a target collision area provided by an embodiment of the present application. As Figure 3 shown, step S102 includes: S1021. According to the location of the target obstacle in the initial river model, the area around the target obstacle is determined as a candidate collision area; S1022. Based on the flow parameters characterized by the initial flow curve in the candidate collision area and the preset normal parameters of each vertex position on the boundary of the target obstacle, a target collision area is determined from the candidate collision area; wherein, when the virtual water flow passes through the target collision area, it flows in the direction towards the target obstacle.
[0094] In this step, since, generally, the area that can be affected by the collision between the water flow and the target obstacle is located around the obstacle, therefore, in order to reduce the computational amount required to calculate the target collision area, first, according to the location of the target obstacle, the area around this location can be determined as a candidate collision area that may be affected by the collision between the virtual water flow and the target obstacle;
[0095] Then, by using the flow parameters characterized by the initial flow curve at each position in the candidate collision area and the preset normal parameters of each vertex position on the boundary of the target obstacle, it is determined whether this position will be affected by the collision between the virtual water flow and the target obstacle;
[0096] Finally, a target collision area that can be affected by the collision between the virtual water flow and the target obstacle is determined from the candidate collision area.
[0097] In one embodiment, step S1021 includes: determining the relative distance between the boundary position of each initial grid in the initial river model and the target obstacle; and determining the area formed by the initial grids with the relative distance within a preset distance range as the candidate collision area.
[0098] In the initial river model, each position of the river to be simulated has been planned as an initial grid (the initial grid can be any shape such as a square, rectangle, and triangle, and the shapes and sizes of each initial grid are the same), that is, each initial grid can represent a position of the river to be simulated.
[0099] Therefore, by calculating the relative distance between each initial grid and the boundary of the target obstacle (the relative distance is the shortest distance, that is, the straight-line distance, between each initial grid and the boundary of the target obstacle), the area formed by the initial grids with the relative distance less than the preset distance threshold is determined as the candidate collision area.
[0100] Here, in fact, the area covered by the target obstacle also has occupied initial grids. Therefore, the initial grids calculated in this application refer to the initial grids outside the range covered by the target obstacle and do not include the initial grids covered by the target obstacle itself; when calculating, the relative distance between each initial grid (outside the area covered by the target obstacle) and the boundary of the target obstacle can be calculated, that is, the relative distance between the grid and the line; or the relative distance between each initial grid (outside the area covered by the target obstacle) and the initial grids occupied by the boundary of the target obstacle can be calculated, that is, the relative distance between the grid and the grid, which can be determined according to the actual situation and is not limited here.
[0101] As an example, as Figure 4 shown, Figure 4 is a schematic diagram of a partial initial river model provided by an embodiment of the present application. As Figure 4 shown, the initial river model 4a is divided into multiple initial grids (including the position where the target obstacle 4b is located). By calculating the relative distance (i.e., the straight-line distance) between the initial grids outside the area covered by the target obstacle 4b and the boundary 4c of the target obstacle 4b, the candidate collision area 4d is determined from around the target obstacle 4b.
[0102] In one implementation, step S1022 includes: for each initial grid covered by the candidate collision region, determining a flow direction vector at the position of the initial grid according to the flow parameters of the water flow at the position of the initial grid; for each vertex position on the boundary of the target obstacle, determining a preset normal vector at the vertex position according to the preset normal parameters at the vertex position; based on the flow direction vector of each initial grid and the preset normal vector of the vertex position, determining target grids that constitute the target collision region from the multiple initial grids covered by the candidate collision region, and obtaining the target collision region.
[0103] Here, the flow direction vector can represent information such as the flow velocity, flow direction, flow position, and flow intensity of the virtual water flow when flowing through the position of the simulated river represented by the initial grid; the preset normal vector can represent relevant information about the normal line at the vertex position, for example, the direction of the normal line, etc.
[0104] In this step, first, for each initial grid at the position covered by the candidate collision region, according to the flow parameters of the virtual water flow when flowing through the position of the simulated river represented by the initial grid, the flow direction vector at the initial grid is determined.
[0105] Secondly, according to the preset normal parameters of each vertex position, the preset normal vector of each vertex position is determined.
[0106] Then, the dot product between the flow direction vector of the initial grid and the preset normal vector of each vertex position is calculated respectively, and then by calculating the average value between multiple dot products, the calculation result (dot product mean) corresponding to the initial grid is determined.
[0107] Here, the dot product between the flow direction vector of the initial grid and the preset normal vector of any vertex position is calculated by the following formula:
[0108]
[0109] where a is the flow direction vector of the initial grid, a i is the i-th element in the flow direction vector a, b is the preset normal vector of any vertex position, b i is the i-th element in the preset normal vector b, and n is the number of elements in the flow direction vector a and the preset normal vector b.
[0110] Corresponding to the above embodiment, as Figure 2As shown, the target obstacle 2a has six vertex positions 2b to 2g. The dot products between the flow direction vectors of the initial grid and the preset normal vectors of each vertex position are calculated. The dot product with vertex position 2b is -1, the dot product with vertex position 2c is -0.5, the dot product with vertex position 2d is 0, the dot product with vertex position 2e is 1, the dot product with vertex position 2f is 0, and the dot product with vertex position 2g is -0.5. The calculation result of the initial grid is determined to be -0.5 by taking the average value.
[0111] Finally, based on the average value of the dot products of each initial grid, it is determined whether the water surface at the position of the river to be simulated represented by each initial grid will be affected by the collision between the virtual water flow and the target obstacle. Here, when the average value of the dot products is less than 0, it can be considered that when the virtual water flow passes through the position of the river to be simulated represented by this initial grid, the preset direction of the target obstacle represented by each preset normal vector of the target obstacle is opposite, that is, the relative direction between the virtual water flow and the target obstacle at this initial grid position is the opposite direction. Therefore, when the average value of the dot products is less than 0, the water surface at the position of the river to be simulated represented by this initial grid will be affected by the collision between the virtual water flow and the target obstacle. On the contrary, when the average value of the dot products is greater than 0, it can be considered that when the virtual water flow passes through the position of the river to be simulated represented by this initial grid, the preset direction of the target obstacle represented by each preset normal vector of the target obstacle is the same, that is, the relative direction between the virtual water flow and the target obstacle at this initial grid position is the same direction. Therefore, when the average value of the dot products is greater than 0, the water surface at the position of the river to be simulated represented by this initial grid will not be affected by the collision between the virtual water flow and the target obstacle. Specifically, when the average value of the dot products is equal to 0, it can be considered that when the virtual water flow passes through the position of the river to be simulated represented by this initial grid, it is perpendicular to the preset direction of the target obstacle represented by each preset normal vector of the target obstacle, that is, the relative direction between the virtual water flow and the target obstacle at this initial grid position is the perpendicular direction. Therefore, when the average value of the dot products is equal to 0, the water surface at the position of the river to be simulated represented by this initial grid will not be affected by the collision between the virtual water flow and the target obstacle. Therefore, the initial grids with the average value of the dot products less than 0 can be determined as the target grids to form the target collision area.
[0112] Corresponding to the above embodiment, as Figure 4 shown, by calculating the relative directions between each initial grid in the candidate collision area 4d and each vertex position of the target obstacle 4b, the target collision area 4e is determined from the candidate collision area 4d.
[0113] In step S103, the routing grids within the target collision area and outside the target collision area can be planned respectively. Specifically, the routing grids within the target collision area are planned according to the first grid density, and the routing grids outside the target collision area are planned according to the second grid density; wherein, the first grid density is greater than the second grid density, that is, compared with the routing grids outside the target collision area, the routing grids within the target collision area are more dense.
[0114] Here, by increasing the grid density of the routing grids within the target collision area, there are more water flow details within the target collision area; while for the area outside the target collision area where water flow details do not need to be concerned, the form of reducing the grid density of the routing grids is adopted to reduce the amount of data included in the river model to be filled after routing. Furthermore, the size of the river model to be filled is indirectly reduced.
[0115] In step S104, if we want to fill each grid vertex in the river model to be filled, we need to determine the vertex filling color of this grid vertex according to the flow parameters of the initial flow curve at the position where this grid vertex is located. Specifically, for each grid vertex of each routing grid in the river model to be filled, if we want to fill this grid vertex, we need to determine the vertex filling color for filling this grid vertex according to the flow parameters of the initial flow curve at the position where this grid vertex is located.
[0116] It should be noted that the initial flow curve simulated by fluid particles is relatively smooth. However, in the real water flow process, the water flow cannot flow smoothly under the influence of the environment. For example, the blowing of the wind, etc. Therefore, in order to increase the visual beauty for players, in the embodiments of the present application, the authenticity of the water flow can be increased by increasing the perturbation parameter.
[0117] In one implementation, step S104 includes: responding to the perturbation increase instruction for the initial flow curve, determining the perturbation parameter for changing the flow parameters represented by the initial flow curve within the target collision area; using the perturbation parameter to change the flow parameters represented by the initial flow curve within the target collision area to obtain the target flow curve; wherein, the fluctuation amplitude of the curve within the target collision area in the target flow curve is greater than the fluctuation amplitude of the curve within the target collision area in the initial flow curve; determining the vertex filling color of this grid vertex according to the flow parameters of the water flow represented by the target flow curve at the position of this grid vertex.
[0118] In the solution provided by this application, in response to a perturbation increase instruction for the initial flow curve, a perturbation parameter for changing the flow parameter characterized by the initial flow curve within the target collision region is determined. Specifically, when the user presses the increase button corresponding to the perturbation parameter, an instruction to increase the perturbation can be issued. Among them, the user can issue a perturbation increase instruction through touch operations such as clicking and dragging and / or preset combination keys. Specifically, the user can increase the perturbation parameter through an increase button corresponding to a finger, mouse, etc.; or through a preset combination key on the keyboard, for example, keys such as the ctrl key, alt key, and a key on the keyboard. The preset keys can be manually set according to the user's needs.
[0119] In this step, in response to the perturbation increase instruction applied by the user to the initial flow curve, a perturbation parameter for changing the flow parameter characterized by the initial flow curve is determined. It should be noted that the perturbation parameter here can be a value or a range. When the perturbation parameter is a range, when changing the flow direction parameter through the perturbation parameter, any value within the range can be randomly selected as the perturbation parameter, or multiple values within the range can be randomly selected as multiple perturbation parameters, and the flow parameters of the water flow can be changed randomly through multiple perturbation parameters.
[0120] One or more determined perturbation parameters are used to change the flow parameter characterized by the initial flow curve within the target collision region, so as to achieve the purpose of disturbing the water flow within the target collision region and obtain a disturbed target flow curve. Here, the fluctuation amplitude of the curve within the target collision region of the target flow curve after increasing the interference is greater than the fluctuation amplitude of the curve within the target collision region of the initial flow curve before increasing the interference; that is, the change situation (such as the slope at each position) and the degree of messiness (such as the curve trend) of the curve within the target collision region in the target flow curve are both greater than the change situation and the degree of messiness of the curve within the target collision region of the initial flow curve. Visually, the flow of the virtual water presented by the target flow curve is more messy and closer to the real water flow situation.
[0121] The fluctuation amplitude is used to represent the change amplitude of the curve within a certain range. From the fluctuation amplitude, the jitter situation of the curve can be seen, and information such as the change trend of the curve can also be seen.
[0122] Determine the flow parameter characterized by the target flow curve at the vertex position of the grid, and determine the vertex filling color for filling the grid vertex according to the determined flow parameter corresponding to the grid vertex.
[0123] In step S105, the vertex filling color of each determined grid vertex is used to fill the grid vertex, and then a target river model with the color filled is obtained.
[0124] Currently, due to the limitations of the fluid diagram generation tool, when simulating a river to be simulated, it cannot be arbitrarily split due to the limitations of the wiring grid. However, in this application, since re-wiring has been performed on it, the target river model can be split and stored as any sub-river model according to the re-planned wiring grid. Therefore, it is more convenient for the rendering engine to render the river to be simulated.
[0125] In one implementation, the model processing method further includes: splitting and storing the target river model as multiple sub-river models according to the wiring grid in the target river model, for the rendering engine to render the river to be simulated based on the multiple sub-river models.
[0126] In this step, since the final target river model obtained in this application is a re-wired model, when splitting the entire target river model, it is not necessary to split it at a fixed position. According to the actual situation of the target river model, on the premise of ensuring that the split sub-river models can be used by the rendering engine, the number of split sub-river models is reduced as much as possible to achieve the purpose of reducing the generated storage files; the target river model is split and stored as multiple sub-river models for the rendering engine to render the river to be simulated based on the multiple sub-river models.
[0127] Here, since this application does not use the method of texture mapping to simulate the river to be simulated, the use of textures is reduced, and thus, the memory consumption is reduced.
[0128] The model processing method provided by the embodiments of this application obtains the initial flow curve after the virtual water flow collides with the target obstacle in the river to be simulated; determines the target collision area where the virtual water flow collides with the target obstacle according to the flow parameters represented by the initial flow curve and the preset normal parameters of each vertex position on the boundary of the target obstacle in the initial river model; plans the wiring grid within the target collision area according to the first grid density, and plans the wiring grid outside the target collision area according to the second grid density to obtain the to-be-filled river model after wiring; determines the vertex filling color of the corresponding grid vertices in the to-be-filled river model according to the flow parameters represented by the initial flow curve; fills the grid vertices with the vertex filling color to obtain the filled target river model. In this way, the target collision area where the water flow collides with the river model can be determined, thereby increasing the water flow details in the target collision area. Furthermore, it not only ensures that there are sufficient flow direction details in the simulated river but also avoids the situation where the model file is too large to be used.
[0129] Please refer to Figure 5 、 Figure 6 , Figure 5One of the structural schematic diagrams of a model processing device provided by an embodiment of the present application Figure 6 Another structural schematic diagram of a model processing device provided by an embodiment of the present application. As Figure 5 shown, the model processing device 500 includes:
[0130] A curve acquisition module 510, configured to acquire an initial flow curve of virtual water flow after colliding with a target obstacle in a river to be simulated;
[0131] An area determination module 520, configured to determine a target collision area where the virtual water flow collides with the target obstacle according to the flow parameters characterized by the initial flow curve and the preset normal parameters of each vertex position on the boundary of the target obstacle in the initial river model;
[0132] A wiring planning module 530, configured to plan wiring grids within the target collision area according to a first grid density and plan wiring grids outside the target collision area according to a second grid density to obtain a river model to be filled after wiring;
[0133] A vertex color determination module 540, configured to determine a vertex filling color of a corresponding grid vertex in the river model to be filled according to the flow parameters characterized by the initial flow curve at the grid vertex position;
[0134] A model filling module 550, configured to fill the grid vertex with the vertex filling color to obtain a filled target river model.
[0135] Further, as Figure 6 shown, the model processing device 500 further includes a model splitting module 560, and the model splitting module 560 is configured to:
[0136] Split and store the target river model into multiple sub-river models according to the wiring grids in the target river model for a rendering engine to render the river to be simulated based on the multiple sub-river models.
[0137] Further, when the vertex color determination module 540 is configured to determine the vertex filling color of the corresponding grid vertex in the river model to be filled according to the flow parameters characterized by the initial flow curve, the vertex color determination module 540 is configured to:
[0138] Respond to a perturbation increase instruction for the initial flow curve and determine a perturbation parameter for changing the flow parameters characterized by the initial flow curve within the target collision area;
[0139] Changing the flow parameters characterized by the initial flow curve within the target collision region by using the perturbation parameters to obtain a target flow curve; wherein, the fluctuation amplitude of the curve within the target collision region in the target flow curve is greater than the fluctuation amplitude of the curve within the target collision region in the initial flow curve;
[0140] Determining the vertex filling color of the corresponding grid vertices within the to-be-filled river model according to the flow parameters characterized by the target flow curve.
[0141] Further, when the region determination module 520 is used to determine the target collision region where the virtual water flow collides with the target obstacle according to the flow parameters characterized by the initial flow curve and the preset normal parameters of each vertex position on the boundary of the target obstacle in the initial river model, the region determination module 520 is used for:
[0142] Determining the area around the target obstacle as the candidate collision region according to the location of the target obstacle in the initial river model;
[0143] Based on the flow parameters characterized by the initial flow curve in the candidate collision region and the preset normal parameters of each vertex position on the boundary of the target obstacle, determining the target collision region from the candidate collision region; wherein, the virtual water flow flows in the direction towards the target obstacle when flowing through the target collision region.
[0144] Further, when the region determination module 520 is used to determine the area around the target obstacle as the candidate collision region according to the location of the target obstacle in the initial river model, the region determination module 520 is used for:
[0145] Determining the relative distance between the boundary position of each initial grid in the initial river model and the target obstacle;
[0146] Determining the area formed by the initial grids with the relative distance within a preset distance range as the candidate collision region.
[0147] Further, when the region determination module 520 is used to determine the target collision region from the candidate collision region based on the flow parameters characterized by the initial flow curve in the candidate collision region and the preset normal parameters of each vertex position on the boundary of the target obstacle, the region determination module 520 is used for:
[0148] For each initial grid covered by the candidate collision region, determining the flow direction vector at the position of this initial grid according to the flow parameters of the water flow at the position of this initial grid;
[0149] For each vertex position on the boundary of the target obstacle, a preset normal vector of the vertex position is determined according to the preset normal parameter at the vertex position;
[0150] Based on the flow direction vector of each initial grid and the preset normal vector of each vertex position, target grids that form a target collision region are determined from the multiple initial grids covered by the candidate collision region, and the target collision region is obtained.
[0151] Further, when the curve acquisition module 510 is used to acquire the initial flow curve of the virtual water flow after colliding with the target obstacle in the river to be simulated, the curve acquisition module 510 is configured to:
[0152] Control multiple fluid particles to slide along the surface of the initial river model of the river to be simulated that is pre-constructed, and determine the sliding trajectory of each fluid particle after colliding with the target obstacle in the initial river model;
[0153] Based on the sliding trajectory of each fluid particle, the initial flow curve of the virtual water flow flowing in the river to be simulated is simulated.
[0154] Further, the first grid density is greater than the second grid density.
[0155] The model processing device provided by the embodiments of the present application acquires the initial flow curve of the virtual water flow after colliding with the target obstacle in the river to be simulated; determines the target collision region where the virtual water flow collides with the target obstacle according to the flow parameters characterized by the initial flow curve and the preset normal parameters of each vertex position on the boundary of the target obstacle in the initial river model; plans the wiring grids within the target collision region according to the first grid density, and plans the wiring grids outside the target collision region according to the second grid density to obtain the river model to be filled after wiring; determines the vertex filling color of the corresponding grid vertices in the river model to be filled according to the flow parameters characterized by the initial flow curve; and fills the grid vertices with the vertex filling color to obtain the filled target river model. In this way, the target collision region where the water flow collides with the river model can be determined, thereby increasing the water flow details in the target collision region. Furthermore, it not only ensures that sufficient flow direction details are retained in the simulated river, but also avoids the situation where the model file is too large to be used.
[0156] Please refer to Figure 7 , Figure 7 which is a schematic structural diagram of an electronic device provided by the embodiments of the present application. As Figure 7 shown in, the electronic device 700 includes a processor 710, a memory 720, and a bus 730.
[0157] The memory 720 stores machine-readable instructions executable by the processor 710. When the electronic device 700 runs, the processor 710 communicates with the memory 720 via a bus 730. When the machine-readable instructions are executed by the processor 710, the steps of the simulation method for the water flow effect in the method embodiment as described above can be executed. For the specific implementation manner, reference can be made to the method embodiment and will not be elaborated here. Figure 1 shown in the method embodiment, and will not be elaborated here.
[0158] The embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is run by a processor, the steps of the simulation method for the water flow effect in the method embodiment as described above can be executed. For the specific implementation manner, reference can be made to the method embodiment and will not be elaborated here. Figure 1 shown in the method embodiment, and will not be elaborated here.
[0159] Those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working processes of the systems, devices, and units described above can refer to the corresponding processes in the foregoing method embodiments and will not be elaborated here.
[0160] In several embodiments provided by the present application, it should be understood that the disclosed systems, devices, and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of the units is only a logical function division, and there can be other division manners in actual implementation. For another example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed mutual coupling or direct coupling or communication connection can be through some communication interfaces. The indirect coupling or communication connection of the devices or units can be in an electrical, mechanical, or other forms.
[0161] The units described as separate components may or may not be physically separated. The components displayed as units may or may not be physical units, that is, they can be located in one place or distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0162] In addition, in each embodiment of the present application, the functional units can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit.
[0163] When the above-mentioned functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium executable by a processor. Based on such an understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a part of this 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 enable a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of this application. The foregoing storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memories (ROM), random access memories (RAM), magnetic disks, or optical discs that can store program codes.
[0164] Finally, it should be noted that the above-mentioned embodiments are only specific implementation manners of this application, used to illustrate the technical solutions of this application, rather than limiting them. The protection scope of this application is not limited thereto. Although this application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: any person skilled in the art within the technical scope disclosed in this application can still modify the technical solutions recorded in the foregoing embodiments or can easily think of changes, or perform equivalent replacements on some of the technical features; and these modifications, changes, or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be covered by the protection scope of this application. Therefore, the protection scope of this application should be subject to the protection scope of the claims.
Claims
1. A model processing method, characterized in that, the model processing method includes: obtaining an initial flow curve of virtual water flow after colliding with a target obstacle in a river to be simulated; determining a target collision area where the virtual water flow collides with the target obstacle according to the flow parameters characterized by the initial flow curve and the preset normal parameters of each vertex position on the boundary of the target obstacle in the initial river model; the target collision area is determined through the following steps: for each initial grid covered by the candidate collision area, determining a flow direction vector at the position of the initial grid according to the flow parameters of the water flow at the position of the initial grid; for each vertex position on the boundary of the target obstacle, determining a preset normal vector at the vertex position according to the preset normal parameters at the vertex position; based on the flow direction vector of each initial grid and the preset normal vector of each vertex position, determining target grids that constitute the target collision area from multiple initial grids covered by the candidate collision area, to obtain the target collision area; wherein, the area around the target obstacle is determined as the candidate collision area; planning wiring grids within the target collision area according to a first grid density, and planning wiring grids outside the target collision area according to a second grid density, to obtain a river model to be filled after wiring; the first grid density is greater than the second grid density; determining vertex filling colors of corresponding grid vertices within the river model to be filled according to the flow parameters characterized by the initial flow curve; filling the grid vertices with the vertex filling colors to obtain a filled target river model.
2. The model processing method according to claim 1, characterized in that, the determining vertex filling colors of corresponding grid vertices within the river model to be filled according to the flow parameters characterized by the initial flow curve includes: responding to a perturbation increase instruction for the initial flow curve, and determining a perturbation parameter for changing the flow parameters characterized by the initial flow curve within the target collision area; changing the flow parameters characterized by the initial flow curve within the target collision area by using the perturbation parameter to obtain a target flow curve; wherein, the fluctuation amplitude of the curve within the target collision area in the target flow curve is greater than the fluctuation amplitude of the curve within the target collision area in the initial flow curve; determining vertex filling colors of corresponding grid vertices within the river model to be filled according to the flow parameters characterized by the target flow curve.
3. The model processing method according to claim 1, characterized in that, determining the candidate collision area through the following steps includes: determining the relative distance between each initial grid in the initial river model and the boundary position of the target obstacle; determining the area formed by the initial grids with relative distances within a preset distance range as the candidate collision area.
4. The model processing method according to claim 1, characterized in that, the obtaining an initial flow curve of virtual water flow after colliding with a target obstacle in a river to be simulated includes: Controlling multiple fluid particles to slide along the surface of an initially constructed river model of a river to be simulated, and determining the sliding trajectories of each fluid particle after colliding with a target obstacle in the initially constructed river model; Based on the sliding trajectories of each fluid particle, an initial flow curve of the virtual water flow flowing in the river to be simulated is obtained by simulation.
5. The model processing method according to claim 1, wherein, the model processing method further includes: According to the wiring grid in the target river model, the target river model is split and stored into multiple sub-river models for the rendering engine to render the river to be simulated based on the multiple sub-river models.
6. The model processing method according to any one of claims 1-5, wherein, the first grid density is greater than the second grid density.
7. A model processing device, wherein, the model processing device includes: a curve acquisition module for acquiring an initial flow curve of the virtual water flow after colliding with a target obstacle in the river to be simulated; a region determination module for determining a target collision region where the virtual water flow collides with the target obstacle according to the flow parameters represented by the initial flow curve and the preset normal parameters of each vertex position on the boundary of the target obstacle in the initially constructed river model; the target collision region is determined through the following steps: for each initial grid covered by the candidate collision region, determining the flow direction vector at the position of this initial grid according to the flow parameters of the water flow at the position of this initial grid; for each vertex position on the boundary of the target obstacle, determining the preset normal vector at this vertex position according to the preset normal parameters at this vertex position; based on the flow direction vector of each initial grid and the preset normal vector of each vertex position, determining the target grids that make up the target collision region from the multiple initial grids covered by the candidate collision region to obtain the target collision region; wherein, the region around the target obstacle is determined as the candidate collision region; a wiring planning module for planning the wiring grid within the target collision region according to the first grid density and planning the wiring grid outside the target collision region according to the second grid density to obtain a wired river model to be filled; the first grid density is greater than the second grid density; a vertex color determination module for determining the vertex filling color of the corresponding grid vertices within the river model to be filled according to the flow parameters represented by the initial flow curve; a model filling module for filling the grid vertices with the vertex filling color to obtain a filled target river model.
8. An electronic device, wherein, including: a processor, a memory and a bus, the memory stores machine-readable instructions executable by the processor, when the electronic device runs, the processor communicates with the memory through the bus, and when the machine-readable instructions are run by the processor, the steps of the model processing method according to any one of claims 1 to 6 are executed.
9. A computer-readable storage medium, wherein, A computer program is stored on the computer-readable storage medium, and when the computer program is run by a processor, it executes the steps of the model processing method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Method for producing three-dimensional water-and-ink animation
CN102496177A
Modeled code generation method and device and computer readable storage medium
CN112596706A