Model processing method and device, electronic equipment and storage medium
By resampling and translation of the target curves in response to user perspective and drawing operations during the model cutting process, the problems of low real-time, interactiveness and accuracy in model cutting are solved, and a more efficient model cutting effect is achieved.
Patent Information
- Application Number
- CN202411658897.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-19
- Publication Date
- 2025-02-14
AI Technical Summary
There are problems of poor real-time and interactiveness and low accuracy during the model cutting process.
By responsive to the perspective determination instruction for the target model, a user perspective relative to the target model is obtained and a drawing surface is determined from the target model based on the user perspective. Then, in response to the drawing operation of the drawing surface, the target curve corresponding to the drawing operation is determined, and the target curve is resampled and translated to obtain the cutting curve. Finally, the target model is cut according to the cutting curve and the translation curve to obtain the model blocks.
Real-time and interactive improvements in the model cutting process are achieved. At the same time, through resampling and translation processing, the uniformity and smoothness of the cutting curve are improved and the accuracy of the cutting is enhanced.
Smart Images

Figure CN119444924A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of graphics processing technology, and in particular to a model processing method, a model processing device, an electronic device and a computer-readable storage medium. Background Art
[0002] In the field of computer graphics and game development, model cutting is an important technology that allows users to interact with three-dimensional objects in a virtual environment and modify and cut these objects in real time. However, in the process of cutting models, it often relies on pre-defined algorithms, which are difficult to adapt to the dynamic needs of users, and have poor real-time and interactivity, and in some cases, the accuracy of cutting cannot be guaranteed. Summary of the invention
[0003] The embodiments of the present invention provide a model processing method, device, electronic device and computer-readable storage medium to solve or partially solve the problems of poor real-time performance and interactivity and low precision in the model cutting process.
[0004] The embodiment of the present invention discloses a model processing method, comprising:
[0005] In response to a viewpoint determination instruction for a target model, obtaining a user viewpoint relative to the target model, and determining a drawing surface from the target model based on the user viewpoint;
[0006] In response to a drawing operation on the drawing surface, determining a target curve corresponding to the drawing operation;
[0007] Resampling the target curve to obtain a cutting curve corresponding to the target curve;
[0008] The cutting curve is translated along the direction corresponding to the user's viewing angle to obtain a translation curve;
[0009] The target model is cut according to the cutting curve and the translation curve to obtain model blocks corresponding to the target model.
[0010] The embodiment of the present invention also discloses a model processing device, including:
[0011] A model determination module, configured to obtain a user perspective relative to the target model in response to a perspective determination instruction for the target model, and determine a drawing surface from the target model based on the user perspective;
[0012] A curve drawing module, configured to determine, in response to a drawing operation on the drawing surface, a target curve corresponding to the drawing operation;
[0013] A resampling module, used for resampling the target curve to obtain a cutting curve corresponding to the target curve;
[0014] A translation module, used for translating the cutting curve along the direction corresponding to the user's viewing angle to obtain a translation curve;
[0015] A cutting module is used to cut the target model according to the cutting curve and the translation curve to obtain model blocks corresponding to the target model.
[0016] The embodiment of the present invention further discloses an electronic device, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;
[0017] The memory is used to store computer programs;
[0018] The processor is used to implement the method described in the embodiment of the present invention when executing the program stored in the memory.
[0019] The embodiment of the present invention further discloses a computer-readable storage medium having instructions stored thereon, which, when executed by one or more processors, enables the processors to execute the method described in the embodiment of the present invention.
[0020] The embodiments of the present invention include the following advantages:
[0021] In an embodiment of the present invention, in the process of cutting a model, by responding to a perspective determination instruction for a target model, a user perspective relative to the target model is obtained, and a drawing surface is determined from the target model based on the user perspective, and then a target curve corresponding to the drawing operation can be determined in response to a drawing operation on the drawing surface, and the target curve is resampled to obtain a cutting curve corresponding to the target curve, and then the cutting curve is translated along a direction corresponding to the user perspective to obtain a translation curve, and then the target model is cut according to the cutting curve and the translation curve to obtain a model block corresponding to the target model, so that for the entire model cutting process, through a real-time, visual interactive process, the real-time nature of the cutting is guaranteed, and the user's interactive experience and interactivity are improved, and at the same time, based on the resampling and translation processing, the uniformity of the cutting curve is improved, making the curve smoother, thereby enhancing the accuracy of the cutting. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Figure 1 is a flowchart of a method for processing a model provided in an embodiment of the present invention;
[0023] Figure 2 is a schematic diagram of a target model provided in an embodiment of the present invention;
[0024] Figure 3 is a schematic diagram of curve processing provided in an embodiment of the present invention;
[0025] Figure 4 is a schematic diagram of a model patch provided in an embodiment of the present invention;
[0026] Figure 5 is a schematic diagram of model cutting provided in an embodiment of the present invention;
[0027] Figure 6 is a schematic diagram of model cutting provided in an embodiment of the present invention;
[0028] Figure 7 is a schematic diagram of the diffusion effect provided in an embodiment of the present invention;
[0029] Figure 8 is a structural block diagram of a model processing device provided in an embodiment of the present invention;
[0030] Fig. 9 It is a block diagram of an electronic device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0031] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0032] As an example, for cutting a model, the physical engine can be used to simulate the fracture and cutting effects of the material. Although this process can produce a realistic cutting effect, it has high computational complexity and poor real-time performance, especially when multiple objects interact. It is easy to cause performance problems. The model can also be converted into voxel data for cutting through voxel cutting. This process can provide a certain degree of cutting accuracy, but it is easy to occupy memory and has a large display in calculation speed, especially when dealing with high-resolution models. It can be seen that when cutting a model, there are problems such as poor real-time performance and interactivity and low accuracy.
[0033] In this regard, in the present invention, by responding to a perspective determination instruction for the target model, the user perspective relative to the target model can be obtained, and a drawing surface can be determined from the target model based on the user perspective. Then, in response to a drawing operation on the drawing surface, a target curve corresponding to the drawing operation can be determined, and the target curve can be resampled to obtain a cutting curve corresponding to the target curve. Then, the cutting curve is translated along the direction corresponding to the user perspective to obtain a translation curve. Then, the target model is cut according to the cutting curve and the translation curve to obtain model blocks corresponding to the target model. Therefore, for the entire model cutting process, through a real-time, visual interactive process, the real-time nature of the cutting is guaranteed, and the user's interactive experience and interactivity are improved. At the same time, based on the resampling and translation processing, the uniformity of the cutting curve is improved, the curve is made smoother, and the accuracy of the cutting is enhanced.
[0034] Reference Figure 1 , shows a flowchart of a model processing method provided in an embodiment of the present invention, which may specifically include the following steps:
[0035] Step 101, in response to a viewpoint determination instruction for a target model, obtaining a user viewpoint relative to the target model, and determining a drawing surface from the target model based on the user viewpoint;
[0036] In an embodiment of the present invention, by cutting the model, a complex model can be decomposed into multiple smaller parts, thereby reducing the number of polygons of a single model and improving rendering performance; it can also help create more complex skeletal animations, such as cutting out the arms and legs of a virtual character and more finely controlling the animation of this part; it can also achieve more complex visual effects, such as explosions, destruction, etc.
[0037] In a specific implementation, the target model to be cut can be determined first, and then the user can input a perspective determination instruction for the target model to determine the user perspective relative to the target model, and determine the drawing surface from the target model based on the user perspective, and further cut the target model based on the drawing surface.
[0038] The target model may be a three-dimensional model displayed in a three-dimensional scene, and the three-dimensional model may be in a corresponding world coordinate system. In the world coordinate system, the user's viewing angle may be determined based on the position and orientation of the virtual camera. As the virtual camera changes in the world coordinate system, the terminal may present information corresponding to different angles and orientations of the target model to the user in a graphical user interface. Before cutting, the cutting direction may be locked by determining the user's viewing angle relative to the target model so that the target model may be cut based on the determined cutting direction.
[0039] In one example, assuming that the target model is a cube, and assuming that it includes faces ①, ②, ③, ④, ⑤, and ⑥, when the user adjusts the user perspective so that the user perspective faces face ① and locks this perspective as the cutting perspective, face ① can be used as the drawing surface, so that the target model can be further cut based on face ①.
[0040] It should be noted that the target model may be an AABB-type model, that is, the target model may be an axis-aligned bounding box model, and the present invention does not limit this.
[0041] Step 102, in response to a drawing operation on the drawing surface, determining a target curve corresponding to the drawing operation;
[0042] After the drawing surface is determined, the user may input a corresponding drawing operation on the drawing surface, and the terminal may determine a corresponding target curve based on the drawing operation input by the user, so as to determine a method for cutting the target model based on the target curve.
[0043] In some feasible implementations, the terminal can respond to a drawing operation on a drawing surface, obtain the screen space coordinates of the drawing point in the screen space, where the drawing point is the point on the drawing surface for each frame of drawing operation, and then convert the screen space coordinates into corresponding world space coordinates. Then, from the target position corresponding to the user's perspective, a ray is emitted along the direction of the line between the target position and the world space coordinates, and the intersection between the ray and the target model is obtained, and the corresponding first target point is created at the intersection, and each first target point is connected to obtain a target curve corresponding to the drawing operation.
[0044] Among them, in the process of cutting the model, different processing methods can be used to respond to user operations according to the different electronic terminals used by the user. For example, assuming that the electronic terminal is a PC terminal, the user inputs the corresponding drawing operation on the drawing surface through the mouse, and the terminal can determine the corresponding target curve based on the path trace of the mouse cursor on the drawing surface; when the electronic terminal is a touch terminal, the user can input the corresponding sliding operation on the touch screen of the touch terminal, and the terminal can determine the target curve on the drawing surface based on the sliding path of the touch point on the touch screen, etc. In the embodiment of the present invention, the electronic terminal is taken as a PC terminal as an example for illustrative explanation. It can be understood that the present invention is not limited to this.
[0045] In a specific implementation, for the drawing point corresponding to the user's drawing operation, the terminal obtains the screen space coordinates of the drawing point in the screen space, and can convert the screen space coordinates into world space coordinates by ray casting, so that the drawing point and the drawing surface in the target model are in the same coordinate system. Then, based on the drawing points collected by the multi-frame drawing operation, the terminal can connect the various drawing points to obtain the corresponding target curve, so as to determine the method of cutting the target model based on the target curve.
[0046] It should be noted that, for the cutting method of the target model, based on the target curve, it can be determined how many blocks the target model is cut into, the size of each block after cutting, and the position from which the target model is cut, etc. For example, assuming that the user draws a curve on the drawing surface, and the curve divides the target model into two parts, it represents that the target model is cut into two blocks; assuming that the user draws two curves on the drawing surface, and the curve divides the target model into four parts, it represents that the target model is cut into four blocks, etc. It can be understood that the curve can be an irregular line segment, and the drawing surface can be divided into several parts between different curves, etc., and the present invention does not limit this.
[0047] Step 103, resampling the target curve to obtain a cutting curve corresponding to the target curve;
[0048] After determining the target curve corresponding to the drawing operation input by the user, the terminal can resample the target curve and construct a cutting curve corresponding to the target curve based on the resampling result, thereby improving the uniformity of the cutting curve based on the resampling, making the curve smoother and enhancing the accuracy of the cutting.
[0049] In some feasible implementations, the curve length corresponding to the target curve and the number of first target points contained in the target curve can be obtained, and the sampling interval for the target curve can be calculated using the curve length and the number of points. The target curve is then sampled according to the sampling interval to generate a second target point, and the first target point is deleted. The second target point is connected to obtain a cutting curve corresponding to the target curve.
[0050] For example, suppose the user draws two target curves on the drawing surface: curve ① and curve ②. Through statistics, it is determined that the length of curve ① is 50 and the number of first target points is 25, and the length of curve ② is 60 and the number of first target points is 30. Then, after calculation, it can be obtained that the sampling intervals of curve ① and curve ② are both 2, that is, the terminal can take one of the endpoints of curve ① as the starting point in the drawing surface, sample according to the sampling interval, obtain 25 second target points, and then connect these 25 second target points. For curve ②, the processing process is the same, so based on resampling, the uniformity of the cutting curve is improved, the curve is smoother, and the cutting accuracy can be enhanced.
[0051] Step 104, translating the cutting curve along the direction corresponding to the user's viewing angle to obtain a translation curve;
[0052] After the cutting curve is determined, the cutting curve can be translated along the direction corresponding to the user's viewing angle to obtain a corresponding translation curve, thereby improving the uniformity of the cutting curve based on resampling and translation processing, making the curve smoother and further enhancing the accuracy of the cutting.
[0053] Among them, the direction of the user's viewing angle can correspond to a front direction and a back direction, which are mapped to the coordinate system, that is, the positive direction and the negative direction of the coordinate axis. Then, when translating the cutting curve, the cutting curve can be translated along the positive direction corresponding to the direction of the user's viewing angle to obtain a positive translation curve corresponding to the cutting curve. At the same time, the cutting curve can be translated along the negative direction corresponding to the direction of the user's viewing angle to obtain a negative translation curve corresponding to the cutting curve.
[0054] In one example, assuming that the direction corresponding to the user's viewing angle is the x-axis, the cutting curve can be translated along the positive and negative directions of the x-axis to obtain corresponding positive translation curves and negative translation curves, so that the target model can be cut according to the cutting curve, the positive translation curve and the negative translation curve.
[0055] In addition, the translation distance of the cutting curve can be determined by obtaining the thickness of the target model on the coordinate axis in the direction of the user's perspective. After the thickness of the target model is determined, a preset redundant value can be superimposed on the thickness to obtain the translation distance, and then the cutting curve is translated based on the translation distance, so that the first distance between the positive translation curve and the cutting curve and the second distance between the negative translation curve and the cutting curve are both greater than the thickness of the model, so as to ensure that the target model can be completely cut during the cutting process. It can be understood that other methods can also be used to translate the cutting curve, as long as the translation result is greater than the thickness of the target model, and the present invention is not limited to this.
[0056] Step 105: cutting the target model according to the cutting curve and the translation curve to obtain model blocks corresponding to the target model.
[0057] After the translation curve is determined, a model patch for the target model can be constructed based on the cutting curve and the translation curve, and the target model can be cut based on the model patch to obtain corresponding model blocks.
[0058] In a specific implementation, the translation curve includes a positive translation curve and a negative translation curve. The positive translation curve, the cutting curve and the negative translation curve can be connected to construct a target area corresponding to the cutting curve, and a model patch corresponding to the target area is generated. The target model is cut using the model patch to obtain model blocks corresponding to the target model. Based on resampling and translation processing, the uniformity of the cutting curve is improved, the curve is made smoother, and the cutting accuracy is enhanced.
[0059] In some feasible implementations, after the model patch is determined, the model faces on the model patch can be traversed. If the model face intersects with the target model, the intersection point between the model face and the target model is determined, and a new vertex is generated at the intersection point. The vertices are then connected to obtain a dividing line inside the target model. The target model is then cut along the dividing line to obtain the model blocks corresponding to the target model. Thus, for the entire model cutting process, the real-time and visual interaction process is used to ensure the real-time nature of the cutting and improve the user's interactive experience and interactivity. At the same time, based on resampling and translation processing, the uniformity of the cutting curve is improved, making the curve smoother, thereby enhancing the accuracy of the cutting.
[0060] After completing the cutting of the target model and obtaining the model blocks corresponding to the target model, corresponding diffusion effects can be added to each model block to make the model blocks diffuse outward.
[0061] In some feasible implementations, the block centroid corresponding to each model block and the global centroid of the target model can be obtained, and then the block centroid and the global centroid are used to calculate to obtain the direction vector of each model block diffusing outward, and then the model blocks are diffused according to the direction vector to obtain the diffusion effect corresponding to the target model, thereby constructing the corresponding diffusion effect to make the model cutting more intuitive, so that the user can intuitively and quickly perceive the cutting situation of the model.
[0062] Among them, for the block centroid, the first vertex position and the first area on the first polygonal surface can be obtained by traversing each first polygonal surface on the model block, and then the first average value corresponding to each first vertex position on the same first polygonal surface is calculated, and the first average value is used as the first face centroid of the first polygonal surface. Then, the first area and the first face centroid are used for calculation to obtain the weighted second face centroid. Finally, the second face centroid corresponding to each first polygonal surface in the model block and the number of faces corresponding to the first polygonal surface are used for calculation to obtain the block centroid corresponding to the model block.
[0063] For the global center of mass, the bounding box corresponding to the target model can be determined, and the second polygonal surface on the bounding box can be traversed to obtain the second vertex position and the second area on the second polygonal surface. The second average value corresponding to each second vertex position on the same second polygonal surface is then calculated, and the average value is used as the third face center of mass of the second polygonal surface. The second area and the third face center of mass are then used for calculation to obtain the weighted fourth face center of mass. The second face center of mass corresponding to each second polygonal surface in the bounding box and the number of faces corresponding to the second polygonal surface are used for calculation to obtain the global center of mass corresponding to the target model.
[0064] In the specific implementation, taking the calculation process of the block centroid as an example, for each block, traverse each polygonal face on it, obtain the vertex positions corresponding to each vertex on the currently traversed face, calculate the average value corresponding to each vertex position, use the average value as the face centroid of the currently traversed face, and calculate the area value corresponding to the current face, so as to determine the weight corresponding to the face centroid position through the area value, and obtain the weighted centroid position by multiplying the area value with the face centroid (the aforementioned average value). Based on the same method, obtain the weighted face centroid corresponding to each polygonal face on the model block, then add the weighted centroid positions of all faces and divide by the number of faces to obtain the centroid position corresponding to the model block. The global centroid of the target model can be processed in the same or similar way. After the block centroids and the global centroid corresponding to each model block are determined, the block centroids corresponding to each model block can be subtracted from the global centroid to obtain the outward diffusion direction vector corresponding to each model block. Based on the direction vector, the outward diffusion of the model blocks can be controlled to finally obtain the diffusion effect corresponding to the target model. By constructing the corresponding diffusion effect, the model cutting is made more intuitive, so that the user can intuitively and quickly perceive the cutting situation of the model.
[0065] In addition, after constructing the diffusion effect corresponding to the target model, it is also possible to traverse each of the model blocks and randomly assign corresponding colors to the model blocks. By assigning corresponding colors, the diffusion effect is more obvious, allowing the user to intuitively and quickly perceive the cutting condition of the model.
[0066] It should be noted that the embodiments of the present invention include but are not limited to the above examples. It is understandable that those skilled in the art can also make settings according to actual needs under the guidance of the ideas of the embodiments of the present invention, and the present invention is not limited to this.
[0067] In an embodiment of the present invention, in the process of cutting a model, by responding to a perspective determination instruction for a target model, a user perspective relative to the target model is obtained, and a drawing surface is determined from the target model based on the user perspective, and then a target curve corresponding to the drawing operation can be determined in response to a drawing operation on the drawing surface, and the target curve is resampled to obtain a cutting curve corresponding to the target curve, and then the cutting curve is translated along a direction corresponding to the user perspective to obtain a translation curve, and then the target model is cut according to the cutting curve and the translation curve to obtain a model block corresponding to the target model, so that for the entire model cutting process, through a real-time, visual interactive process, the real-time nature of the cutting is guaranteed, and the user's interactive experience and interactivity are improved, and at the same time, based on the resampling and translation processing, the uniformity of the cutting curve is improved, making the curve smoother, thereby enhancing the accuracy of the cutting.
[0068] In order to enable those skilled in the art to better understand the technical solutions in the embodiments of the present invention, the following examples are used for exemplary description:
[0069] Reference Figure 2 , shows a schematic diagram of a target model provided in an embodiment of the present invention, by obtaining the AABB bounding box (axis aligned bounding box) of the model for segmentation, and taking out the face facing the camera for the user's drawing plane. Then, when the user presses the mouse, the drawing command is triggered, and the current position of the user's mouse in the screen space is obtained in each frame, and the screen space coordinates are converted into world space coordinates through ray casting, and a point is created on the coordinates. Figure 3 , shows a schematic diagram of curve processing provided in an embodiment of the present invention, wherein, Figure 3 ① shows the target curve drawn by the user. Figure 3② shows the cutting curve after resampling. Based on resampling, the uniformity of the cutting curve is improved, making the curve smoother, thereby enhancing the accuracy of cutting. Specifically, the obtained screen coordinates [x, y] can be converted into viewport coordinates, and the data range is mapped from [screen_x, screen_y] to [-1, 1]. Rays are emitted from the current camera position, and the starting point of the ray is the camera position. The direction of the ray is the starting point and the mouse position of the user in the current frame. The ray and the target model are collided. If there is an intersection, the position of the intersection is recorded, and a point is created at the position of the intersection. Then, according to the order in which the points are created, they are connected in sequence to form a line segment. After obtaining the corresponding line segment, the total length of each curve can be obtained to determine how to evenly distribute new points and determine the sampling interval. The interval between each point is determined by the total length / total number of points, and then new points are generated on the line segment according to the interval, and the original points are deleted.
[0070] Further, refer to Figure 4 , shows a schematic diagram of the model face provided in an embodiment of the present invention. After the cutting curve is determined, it can be translated in a square direction along the direction corresponding to the user's viewing angle, and the translation result is connected with the cutting curve, and then the corresponding model face is generated for the connected area.
[0071] Based on the generated model patch, Boolean operations can be performed with the target model to generate a new topological structure in the overlapping area of the two models, and the divided area forms the corresponding model block. Specifically, all faces corresponding to the model patch can be traversed, and each face can be checked to see if it intersects with the face of the target model. If there is an intersection point, the corresponding intersection point is calculated, and a new vertex is formed at the intersection point, and it is connected to obtain the following: Figure 5 , Figure 6 The effect shown, Figure 6 This is a perspective view, and it can be seen that new line segments and surfaces are formed inside the model.
[0072] Further, refer to Figure 7 , showing a schematic diagram of the diffusion effect provided in an embodiment of the present invention. After the target model is cut to obtain the corresponding model blocks, the direction vector corresponding to each model block can be determined by calculating the corresponding center of mass position, and the model blocks are diffused based on the direction vector. The diffusion effect corresponding to the target model block, so that for the entire model cutting process, through a real-time, visual interaction process, not only the real-time nature of the cutting is guaranteed, but also the user's interactive experience and interactivity are improved. At the same time, based on resampling and translation processing, the uniformity of the cutting curve is improved, making the curve smoother, thereby enhancing the accuracy of the cutting. By constructing the corresponding diffusion effect, the model cutting is made more intuitive, so that the user can intuitively and quickly perceive the cutting situation of the model.
[0073] It should be noted that, for the sake of simplicity, the method embodiments are described as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.
[0074] Reference Figure 8 , shows a structural block diagram of a model processing device provided in an embodiment of the present invention, which may specifically include the following modules:
[0075] A model determination module 801 is used to obtain a user perspective relative to the target model in response to a perspective determination instruction for the target model, and determine a drawing surface from the target model based on the user perspective;
[0076] A curve drawing module 802, configured to determine a target curve corresponding to a drawing operation on the drawing surface in response to the drawing operation;
[0077] A resampling module 803 is used to resample the target curve to obtain a cutting curve corresponding to the target curve;
[0078] A translation module 804, configured to translate the cutting curve along a direction corresponding to the user's viewing angle to obtain a translation curve;
[0079] The cutting module 805 is used to cut the target model according to the cutting curve and the translation curve to obtain model blocks corresponding to the target model.
[0080] In some feasible implementations, the curve drawing module 802 is specifically used for:
[0081] In response to a drawing operation on the drawing surface, obtaining screen space coordinates of a drawing point in screen space, the drawing point being a point on the drawing surface of the drawing operation in each frame;
[0082] Converting the screen space coordinates into corresponding world space coordinates;
[0083] From the target position corresponding to the user perspective, emitting a ray along the direction of a line between the target position and the world space coordinates, and obtaining an intersection point between the ray and the target model;
[0084] A corresponding first target point is created at the intersection, and each of the first target points is connected to obtain a target curve corresponding to the drawing operation.
[0085] In some feasible implementations, the resampling module 803 is specifically used for:
[0086] Acquire a curve length corresponding to the target curve and the number of first target points included in the target curve, and calculate a sampling interval for the target curve using the curve length and the number of points;
[0087] Sampling the target curve according to the sampling interval to generate a second target point;
[0088] The first target point is deleted, and the second target point is connected to obtain a cutting curve corresponding to the target curve.
[0089] In some feasible implementations, the translation curve includes a positive translation curve and a negative translation curve, and the cutting module 805 is specifically used for:
[0090] Connecting the positive translation curve, the cutting curve and the negative translation curve, constructing a target area corresponding to the cutting curve, and generating a model patch corresponding to the target area;
[0091] The target model is cut using the model facets to obtain model blocks corresponding to the target model.
[0092] In some feasible implementations, the cutting module 805 is specifically used for:
[0093] Traversing each model surface on the model surface patch;
[0094] If the model surface intersects with the target model, determining the intersection point between the model surface and the target model, and generating a new vertex at the intersection point;
[0095] Connecting the vertices to obtain a boundary line inside the target model;
[0096] The target model is cut according to the dividing line to obtain model blocks corresponding to the target model.
[0097] In some feasible implementations, the translation module 804 is specifically used to:
[0098] The cutting curve is translated along the positive direction corresponding to the user's viewing angle to obtain a positive translation curve corresponding to the cutting curve;
[0099] The cutting curve is translated along the negative direction of the orientation corresponding to the user viewing angle to obtain a negative translation curve corresponding to the cutting curve.
[0100] Some possible implementations also include:
[0101] A centroid information acquisition module, used to obtain the block centroids corresponding to each of the model blocks and the global centroid of the target model;
[0102] A vector calculation module, used to use the block centroid and the global centroid to perform calculations to obtain a direction vector in which each of the model blocks diffuses outwards;
[0103] A diffusion module is used to diffuse the model blocks according to the direction vector to obtain a diffusion effect corresponding to the target model.
[0104] In some feasible implementations, the centroid information acquisition module is specifically used to:
[0105] Traversing each first polygonal face on the model block;
[0106] Obtain a first vertex position and a first area on the first polygonal surface;
[0107] Calculate a first average value corresponding to each of the first vertex positions on the same first polygonal surface, and use the first average value as a first surface centroid of the first polygonal surface;
[0108] Calculating using the first area and the first face centroid to obtain a weighted second face centroid;
[0109] The block centroid corresponding to the model block is obtained by using the second face centroid corresponding to each of the first polygonal faces in the model block and the number of faces corresponding to the first polygonal face to perform calculations.
[0110] In some feasible implementations, the centroid information acquisition module is specifically used to:
[0111] Determine a bounding box corresponding to the target model, and traverse a second polygonal surface on the bounding box;
[0112] Obtain a second vertex position and a second area on the second polygonal surface;
[0113] Calculate a second average value corresponding to each of the second vertex positions on the same second polygonal surface, and use the average value as the third surface centroid of the second polygonal surface;
[0114] Calculating using the second area and the third surface centroid to obtain a weighted fourth surface centroid;
[0115] The global center of mass corresponding to the target model is obtained by using the second face centroid corresponding to each of the second polygonal faces in the bounding box and the number of faces corresponding to the second polygonal faces for calculation.
[0116] Some possible implementations also include:
[0117] The color processing module is used to traverse each of the model blocks and randomly assign corresponding colors to the model blocks.
[0118] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0119] In addition, an embodiment of the present invention further provides an electronic device, comprising: a processor, a memory, and a computer program stored in the memory and executable on the processor. When the computer program is executed by the processor, the various processes of the processing method embodiment of the above-mentioned model are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.
[0120] The embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, each process of the processing method embodiment of the above-mentioned model is implemented, and the same technical effect can be achieved. To avoid repetition, it is not repeated here. The computer-readable storage medium is, for example, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0121] Fig. 9 A schematic diagram of the hardware structure of an electronic device for implementing various embodiments of the present invention.
[0122] The electronic device 900 includes but is not limited to: a radio frequency unit 901, a network module 902, an audio output unit 903, an input unit 904, a sensor 905, a display unit 906, a user input unit 907, an interface unit 908, a memory 909, a processor 910, and a power supply 911. Those skilled in the art will appreciate that the electronic device structure involved in the embodiments of the present invention does not constitute a limitation on the electronic device, and the electronic device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently. In the embodiments of the present invention, the electronic device includes but is not limited to a mobile phone, a tablet computer, a laptop computer, a PDA, a vehicle-mounted terminal, a wearable device, and a pedometer.
[0123] It should be understood that in the embodiment of the present invention, the radio frequency unit 901 can be used for receiving and sending signals during information transmission or communication. Specifically, after receiving downlink data from the base station, it is sent to the processor 910 for processing; in addition, uplink data is sent to the base station. Generally, the radio frequency unit 901 includes but is not limited to an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier, a duplexer, etc. In addition, the radio frequency unit 901 can also communicate with the network and other devices through a wireless communication system.
[0124] The electronic device provides users with wireless broadband Internet access through the network module 902, such as helping users to send and receive emails, browse web pages, and access streaming media.
[0125] The audio output unit 903 can convert the audio data received by the RF unit 901 or the network module 902 or stored in the memory 909 into an audio signal and output it as sound. Moreover, the audio output unit 903 can also provide audio output related to a specific function performed by the electronic device 900 (for example, a call signal reception sound, a message reception sound, etc.). The audio output unit 903 includes a speaker, a buzzer, a receiver, etc.
[0126] The input unit 904 is used to receive audio or video signals. The input unit 904 may include a graphics processor (GPU) 9041 and a microphone 9042, and the graphics processor 9041 processes the image data of a static picture or video obtained by an image capture device (such as a camera) in a video capture mode or an image capture mode. The processed image frame can be displayed on the display unit 906. The image frame processed by the graphics processor 9041 can be stored in the memory 909 (or other storage medium) or sent via the radio frequency unit 901 or the network module 902. The microphone 9042 can receive sound and can process such sound into audio data. The processed audio data can be converted into a format output that can be sent to a mobile communication base station via the radio frequency unit 901 in the case of a telephone call mode.
[0127] The electronic device 900 also includes at least one sensor 905, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor includes an ambient light sensor and a proximity sensor, wherein the ambient light sensor can adjust the brightness of the display panel 9061 according to the brightness of the ambient light, and the proximity sensor can turn off the display panel 9061 and / or the backlight when the electronic device 900 is moved to the ear. As a type of motion sensor, the accelerometer sensor can detect the magnitude of acceleration in each direction (generally three axes), and can detect the magnitude and direction of gravity when stationary, which can be used to identify the posture of the electronic device (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer, tapping), etc.; the sensor 905 can also include a fingerprint sensor, a pressure sensor, an iris sensor, a molecular sensor, a gyroscope, a barometer, a hygrometer, a thermometer, an infrared sensor, etc., which will not be repeated here.
[0128] The display unit 906 is used to display information input by the user or information provided to the user. The display unit 906 may include a display panel 9061, which may be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), or the like.
[0129] The user input unit 907 can be used to receive input digital or character information, and to generate key signal input related to user settings and function control of the electronic device. Specifically, the user input unit 907 includes a touch panel 9071 and other input devices 9072. The touch panel 9071, also known as a touch screen, can collect the user's touch operation on or near it (such as the user's operation on the touch panel 9071 or near the touch panel 9071 using any suitable object or accessory such as a finger, stylus, etc.). The touch panel 9071 may include two parts: a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch orientation, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into the contact point coordinates, and then sends it to the processor 910, receives the command sent by the processor 910 and executes it. In addition, the touch panel 9071 can be implemented using various types such as resistive, capacitive, infrared and surface acoustic waves. In addition to the touch panel 9071, the user input unit 907 may also include other input devices 9072. Specifically, other input devices 9072 may include but are not limited to a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, and a joystick, which will not be described in detail here.
[0130] Further, the touch panel 9071 may be covered on the display panel 9061. When the touch panel 9071 detects a touch operation on or near it, it is transmitted to the processor 910 to determine the type of the touch event, and then the processor 910 provides a corresponding visual output on the display panel 9061 according to the type of the touch event. It can be understood that in one embodiment, the touch panel 9071 and the display panel 9061 are used as two independent components to implement the input and output functions of the electronic device, but in some embodiments, the touch panel 9071 and the display panel 9061 can be integrated to implement the input and output functions of the electronic device, which is not limited here.
[0131] The interface unit 908 is an interface for connecting an external device to the electronic device 900. For example, the external device may include a wired or wireless headset port, an external power supply (or battery charger) port, a wired or wireless data port, a memory card port, a port for connecting a device with an identification module, an audio input / output (I / O) port, a video I / O port, a headphone port, etc. The interface unit 908 may be used to receive input (e.g., data information, power, etc.) from an external device and transmit the received input to one or more elements within the electronic device 900 or may be used to transmit data between the electronic device 900 and an external device.
[0132] The memory 909 can be used to store software programs and various data. The memory 909 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data created according to the use of the mobile phone (such as audio data, a phone book, etc.), etc. In addition, the memory 909 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0133] The processor 910 is the control center of the electronic device. It uses various interfaces and lines to connect various parts of the entire electronic device. It executes various functions of the electronic device and processes data by running or executing software programs and / or modules stored in the memory 909, and calling data stored in the memory 909, so as to monitor the electronic device as a whole. The processor 910 may include one or more processing units; preferably, the processor 910 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 910.
[0134] The electronic device 900 may also include a power supply 911 (such as a battery) for supplying power to each component. Preferably, the power supply 911 may be logically connected to the processor 910 through a power management system, thereby implementing functions such as charging, discharging, and power consumption management through the power management system.
[0135] In addition, the electronic device 900 includes some functional modules not shown, which will not be described in detail here.
[0136] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0137] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for enabling a terminal (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present invention.
[0138] The embodiments of the present invention are described above in conjunction with the accompanying drawings, but the present invention is not limited to the above-mentioned specific implementation modes, which are merely illustrative rather than restrictive. Under the guidance of the present invention, ordinary technicians in this field can also make many forms without departing from the scope of protection of the present invention and the claims, all of which are within the protection of the present invention.
[0139] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed in the embodiments of the present invention can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0140] 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 aforementioned method embodiments and will not be repeated here.
[0141] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as 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 mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0142] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0143] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0144] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard disks, ROM, RAM, magnetic disks, or optical disks.
[0145] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. A model processing method, characterized in that: include: In response to a viewpoint determination instruction for a target model, obtaining a user viewpoint relative to the target model, and determining a drawing surface from the target model based on the user viewpoint; In response to a drawing operation on the drawing surface, determining a target curve corresponding to the drawing operation; Resampling the target curve to obtain a cutting curve corresponding to the target curve; The cutting curve is translated along the direction corresponding to the user's viewing angle to obtain a translation curve; The target model is cut according to the cutting curve and the translation curve to obtain model blocks corresponding to the target model.
2. The method according to claim 1, characterized in that The step of determining, in response to a drawing operation on the drawing surface, a target curve corresponding to the drawing operation comprises: In response to a drawing operation on the drawing surface, obtaining screen space coordinates of a drawing point in screen space, the drawing point being a point on the drawing surface of the drawing operation in each frame; Converting the screen space coordinates into corresponding world space coordinates; From the target position corresponding to the user perspective, emitting a ray along the direction of a line between the target position and the world space coordinates, and obtaining an intersection point between the ray and the target model; A corresponding first target point is created at the intersection, and each of the first target points is connected to obtain a target curve corresponding to the drawing operation.
3. The method according to claim 1 or 2, characterized in that: The resampling of the target curve to obtain a cutting curve corresponding to the target curve includes: Acquire a curve length corresponding to the target curve and the number of first target points included in the target curve, and calculate a sampling interval for the target curve using the curve length and the number of points; Sampling the target curve according to the sampling interval to generate a second target point; The first target point is deleted, and the second target point is connected to obtain a cutting curve corresponding to the target curve.
4. The method according to claim 1, characterized in that: The translation curve includes a positive translation curve and a negative translation curve, and the target model is cut according to the cutting curve and the translation curve to obtain the model blocks corresponding to the target model, including: Connecting the positive translation curve, the cutting curve and the negative translation curve, constructing a target area corresponding to the cutting curve, and generating a model patch corresponding to the target area; The target model is cut using the model facets to obtain model blocks corresponding to the target model.
5. The method according to claim 4, characterized in that The step of cutting the target model by using the model facets to obtain model blocks corresponding to the target model includes: Traversing each model surface on the model surface patch; If the model surface intersects with the target model, determining the intersection point between the model surface and the target model, and generating a new vertex at the intersection point; Connecting the vertices to obtain a boundary line inside the target model; The target model is cut according to the dividing line to obtain model blocks corresponding to the target model.
6. The method according to claim 1 or 4, characterized in that: The translating the cutting curve along the direction corresponding to the user viewing angle to obtain a translation curve includes: The cutting curve is translated along the positive direction corresponding to the user's viewing angle to obtain a positive translation curve corresponding to the cutting curve; The cutting curve is translated along the negative direction of the orientation corresponding to the user viewing angle to obtain a negative translation curve corresponding to the cutting curve.
7. The method according to claim 1, 4 or 5, characterized in that: Also includes: Obtaining the block centroids corresponding to each of the model blocks and the global centroid of the target model; The block centroid and the global centroid are used to perform calculations to obtain a direction vector in which each of the model blocks diffuses outwards; The model blocks are diffused according to the direction vector to obtain a diffusion effect corresponding to the target model.
8. The method according to claim 7, characterized in that The obtaining of the block centroids corresponding to each of the model blocks includes: Traversing each first polygonal face on the model block; Obtain a first vertex position and a first area on the first polygonal surface; Calculate a first average value corresponding to each of the first vertex positions on the same first polygonal surface, and use the first average value as a first surface centroid of the first polygonal surface; Calculating using the first area and the first face centroid to obtain a weighted second face centroid; The block centroid corresponding to the model block is obtained by using the second face centroid corresponding to each of the first polygonal faces in the model block and the number of faces corresponding to the first polygonal face to perform calculations.
9. The method according to claim 8, characterized in that The obtaining of the global centroid of the target model comprises: Determine a bounding box corresponding to the target model, and traverse a second polygonal surface on the bounding box; Obtain a second vertex position and a second area on the second polygonal surface; Calculate a second average value corresponding to each of the second vertex positions on the same second polygonal surface, and use the average value as the third surface centroid of the second polygonal surface; Calculating using the second area and the third surface centroid to obtain a weighted fourth surface centroid; The global center of mass corresponding to the target model is obtained by using the second face centroid corresponding to each of the second polygonal faces in the bounding box and the number of faces corresponding to the second polygonal faces for calculation.
10. The method according to claim 1, 4 or 5, characterized in that: Also includes: Each of the model blocks is traversed, and corresponding colors are randomly assigned to the model blocks.
11. A model processing device, characterized in that: include: A model determination module, configured to obtain a user perspective relative to the target model in response to a perspective determination instruction for the target model, and determine a drawing surface from the target model based on the user perspective; A curve drawing module, configured to determine, in response to a drawing operation on the drawing surface, a target curve corresponding to the drawing operation; A resampling module, used for resampling the target curve to obtain a cutting curve corresponding to the target curve; A translation module, used for translating the cutting curve along the direction corresponding to the user's viewing angle to obtain a translation curve; A cutting module is used to cut the target model according to the cutting curve and the translation curve to obtain model blocks corresponding to the target model.
12. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; The memory is used to store computer programs; The processor is used to implement the method according to any one of claims 1 to 10 when executing the program stored in the memory.
13. A computer-readable storage medium having instructions stored thereon, which, when executed by one or more processors, cause the processors to perform the method according to any one of claims 1 to 10.
Citation Information
Cited By
Segmentation special effect generation method and device, electronic equipment and computer storage medium
CN120510160A