A mesh model rendering method, device, equipment and medium
By optimizing the line segment transparency processing of the mesh model, the problem of poor rendering effect caused by uneven mesh line distribution was solved, achieving a clear display of part relationships and improved visual appeal when scaled down, while also improving rendering efficiency.
Patent Information
- Application Number
- CN202411584392.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-05
- Publication Date
- 2025-11-18
- Estimated Expiration
- 2044-11-05
AI Technical Summary
Existing 3D model rendering methods produce poor rendering results when the grid lines are unevenly distributed, affecting the overall rendering effect and visual experience.
By acquiring the face and vertex data of the mesh model, face objects are drawn and the 3D coordinates and color information of line segments are extracted, converted into screen coordinates, and the line segment distance and transparency values are calculated. The transparency of the line segments is optimized to draw line objects, thus generating the mesh model.
Maintain good rendering results when the mesh model is scaled down, clearly show the relationship between the parts, avoid uneven colors, improve the user experience and enhance computer rendering efficiency.
Smart Images

Figure CN119478192B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer three-dimensional model rendering and visualization interaction, and particularly relates to a mesh model rendering method and device, equipment and medium. BACKGROUND
[0002] Three-dimensional model rendering is a core concept in computer graphics processing, which specifically refers to a technology of generating a two-dimensional image or video according to a set environment, light, material and rendering parameter of a model (such as a three-dimensional model of a mechanical part) in a three-dimensional scene. Three-dimensional model rendering often needs to present the contour line, frame and the like of the model, and especially the rendering of a mesh model, which very much needs the presentation of mesh lines to assist user interaction modeling, option setting and presentation expression.
[0003] Regarding the rendering of mesh lines, the most commonly used way is to draw using a black line primitive. A feature of the line primitive is that its width unit is a pixel, that is, the matrix transformation and viewport transformation in three-dimensional model rendering have no effect on it. This leads to a problem that when we zoom out the model (i.e. enlarge the viewport range) in the three-dimensional software, the model presented in the surface primitive way will be zoomed out, while the contour frame (including mesh lines) presented in the line primitive way will cause the model to be blackened as a whole because the width of the line (unit: pixel) will not be zoomed out, which greatly affects the overall rendering effect. As shown in FIG. 1, the presentation effect of the model after zooming out step by step can be clearly found that the display effect is very poor after zooming out the model, and it is almost impossible to see the relationship between each part of the model. Figure 1
[0004] In order to solve the above problem, the existing method is to dynamically modify the lightness of mesh line drawing according to the zooming scale of the model, that is, the transparency. However, when the mesh line drawing of the model is unevenly distributed (such as a model after mesh division according to the curvature feature of the model surface), the presentation effect of the model after zooming out is still poor after using this method. SUMMARY
[0005] The present application provides a mesh model rendering method, device, equipment and medium, which solves the problem that the existing three-dimensional model rendering method has poor presentation effect after zooming out the model after rendering the model with unevenly distributed mesh lines, which affects the overall rendering effect and visual perception.
[0006] To solve the above technical problems, the technical scheme adopted by the present application is to provide a mesh model rendering method, comprising the steps of: obtaining mesh model data, wherein the mesh model data comprises face data and vertex data; using the face data to draw a plurality of face objects of the mesh model; extracting the three-dimensional coordinates and color information of the first vertex and the second vertex of each line segment in the vertex data; converting the three-dimensional coordinates of the first vertex and the second vertex into screen coordinates; calculating the distance between the first vertex and the second vertex according to the screen coordinates of the first vertex and the second vertex; calculating the target transparency value of each line segment according to the distance between the first vertex and the second vertex of each line segment, the color information, the red component, the green component, the blue component, and the screen coordinates of the first vertex and the second vertex; and drawing the corresponding line object according to the target transparency value of each line segment, the red component, the green component, the blue component, and the screen coordinates of the first vertex and the second vertex, to generate the mesh model.
[0007] In some embodiments, the extracting the three-dimensional coordinates and color information of the first vertex and the second vertex of each line segment in the vertex data comprises: arranging the vertex data in sequence to a vertex buffer, and establishing the index ID of the first vertex of each line segment in the vertex data; and according to the index ID, finding and obtaining the three-dimensional coordinates and color information of the first vertex and the second vertex of each line segment from the vertex buffer.
[0008] In some embodiments, the index ID comprises the storage location of the first vertex in the vertex buffer.
[0009] In some embodiments, the converting the three-dimensional coordinates of the first vertex and the second vertex into screen coordinates comprises: obtaining a model view matrix and a projection matrix under a current rendering perspective; and converting the three-dimensional coordinates of the first vertex and the second vertex in a world space into the screen coordinates in an NDC space through the model view matrix and the projection matrix.
[0010] In some embodiments, the calculating the target transparency value of each line segment according to the distance between the first vertex and the second vertex of each line segment and the color information comprises: the color information comprises an original transparency value, the red component, the green component, and the blue component; using the distance between the first vertex and the second vertex of each line segment to convert the original transparency value of the first vertex and the second vertex into the target transparency value; and obtaining the target transparency value of the corresponding line segment according to the target transparency value of the first vertex and the second vertex.
[0011] In some embodiments, the drawing of the corresponding line object according to the target transparency value, the red component, the green component, the blue component of each line segment, and the screen coordinates of the first vertex and the second vertex comprises: splitting each line segment into a plurality of corresponding pixels; and performing color filling on the pixels corresponding to each line segment according to the target transparency value, the red component, the green component, the blue component of each line segment, and the screen coordinates of the first vertex and the second vertex.
[0012] The application further provides a mesh model rendering device, comprising: an acquisition unit configured to acquire mesh model data, wherein the mesh model data comprises face data and vertex data; a face drawing unit configured to draw a plurality of face objects of a mesh model by using the face data; an extraction unit configured to extract three-dimensional coordinates and color information of a first vertex and a second vertex of each line segment in the vertex data; a conversion unit configured to convert the three-dimensional coordinates of the first vertex and the second vertex into screen coordinates; a calculation unit configured to calculate a distance between the first vertex and the second vertex according to the screen coordinates of the first vertex and the second vertex, and further configured to calculate a target transparency value of each line segment according to the distance between the first vertex and the second vertex of each line segment and the color information; and a line drawing unit configured to draw a corresponding line object according to the target transparency value, the red component, the green component, the blue component of each line segment, and the screen coordinates of the first vertex and the second vertex, so as to generate the mesh model.
[0013] In some embodiments, the extraction unit comprises: a building subunit configured to arrange the vertex data in a vertex buffer in sequence and build an index ID of the first vertex of each line segment in the vertex data; and a searching subunit configured to search and acquire the three-dimensional coordinates and color information of the first vertex and the second vertex of each line segment from the vertex buffer according to the index ID.
[0014] The application further provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above method when executing the computer program.
[0015] The application further provides a computer readable storage medium, wherein the computer readable storage medium stores a computer program, and the computer program implements the steps of the above method when executed by a processor.
[0016] The beneficial effects of the present application are: the present application discloses a mesh model rendering method, device, equipment and medium, the method comprises the steps: obtaining mesh model data, wherein the mesh model data comprises face data and vertex data; using the face data, drawing a plurality of face objects of the mesh model; extracting the three-dimensional coordinates and color information of the first vertex and the second vertex of each line segment in the vertex data; converting the three-dimensional coordinates of the first vertex and the second vertex into screen coordinates; according to the screen coordinates of the first vertex and the second vertex, the distance between the first vertex and the second vertex is calculated and obtained; according to the distance between the first vertex and the second vertex of each line segment, the color information, the target transparency value of each line segment is calculated and obtained; according to the target transparency value of each line segment, the red component, the green component, the blue component, and the screen coordinates of the first vertex and the second vertex, the corresponding line object is drawn, and the mesh model is generated. When rendering the mesh model, the face object is drawn first, and then the line object is further drawn. When drawing the line object, the transparency value of each line segment is optimized by the distance between the first vertex and the second vertex of the line segment; so that when the mesh model is displayed in a reduced manner, whether the line segments are uniformly distributed or not, a good rendering effect can be presented, the relationship between the parts of the mesh model can be clearly seen when the mesh model is reduced, the color unevenness of the parts in the visual effect is avoided, and the user's perception is improved. Using the method to render the mesh model can further improve the rendering execution efficiency of the computer and improve the computer performance. BRIEF DESCRIPTION OF DRAWINGS
[0017] Figure 1 is a schematic diagram of the presentation effect of the model rendering in the prior art after step-by-step reduction;
[0018] Figure 2 is a flowchart of an embodiment of the mesh model rendering method of the present application;
[0019] Figure 3 is a schematic diagram of the mesh model in an embodiment of the mesh model rendering method of the present application;
[0020] Figure 4 is a schematic diagram of drawing the face object in an embodiment of the mesh model rendering method of the present application;
[0021] Figure 5 is a schematic diagram of the arrangement of the vertex buffer in an embodiment of the mesh model rendering method of the present application;
[0022] Figure 6 is a schematic diagram of obtaining the three-dimensional coordinates and color information of the first vertex and the second vertex in an embodiment of the mesh model rendering method of the present application;
[0023] Figure 7is a schematic view of calculating the distance between the first vertex and the second vertex in an embodiment of the mesh model rendering method of the present application;
[0024] Figure 8 is a comparison schematic view of rendering the same mesh model by the rendering method of the prior art and the rendering method of the present application;
[0025] Figure 9 is a structural block diagram of an embodiment of the mesh model rendering device of the present application;
[0026] Figure 10 is a structural block diagram of the extraction unit in an embodiment of the mesh model rendering device of the present application;
[0027] Figure 11 is an architecture schematic view of an embodiment of the electronic device of the present application;
[0028] Figure 12 is a schematic block diagram of an embodiment of the computer readable storage medium of the present application. DETAILED DESCRIPTION
[0029] In order to facilitate the understanding of the present application, the present application will be described in more detail below in conjunction with the drawings and specific embodiments. The preferred embodiments of the present application are shown in the drawings. However, the present application can be implemented in many different forms and is not limited to the embodiments described in the specification. On the contrary, the purpose of providing these embodiments is to make the disclosure of the present application more thorough and comprehensive.
[0030] It should be noted that, unless otherwise defined, all technical and scientific terms used in the specification have the same meaning as commonly understood by those skilled in the art to which the present application belongs. The terms used in the specification of the present application are only for the purpose of describing specific embodiments and are not intended to limit the present application. The term "and / or" used in the specification includes any and all combinations of one or more related listed items.
[0031] Figure 2 An implementation flowchart of the mesh model rendering method provided by the present application is shown, which includes the steps of:
[0032] S1: obtaining mesh model data, wherein the mesh model data includes face data and vertex data.
[0033] S2: using the face data to draw a plurality of face objects of the mesh model.
[0034] S3: extracting the three-dimensional coordinates and color information of the first vertex and the second vertex of each line segment in the vertex data.
[0035] S4: converting the three-dimensional coordinates of the first vertex and the second vertex into screen coordinates.
[0036] S5: Obtain the distance between the first vertex and the second vertex according to the screen coordinates of the first vertex and the second vertex; and obtain the target transparency value of each line segment according to the distance between the first vertex and the second vertex of each line segment and the color information.
[0037] S6: Draw the corresponding line object according to the target transparency value of each line segment, the red component, the green component, the blue component, and the screen coordinates of the first vertex and the second vertex, and generate the mesh model.
[0038] The face data and the vertex data are basic data for constituting the mesh model, and various mesh models with different shapes and sizes can be formed by combining these data. In the present application, the computer processing is processing of these mesh models.
[0039] In the present application, the face object is drawn first when rendering the mesh model by the computer, and then the line object is further drawn. When drawing the line object, the transparency value of each line segment is optimized by the distance between the first vertex and the second vertex of the line segment. Thus, when the mesh model is displayed by the computer in a reduced size, good rendering effect can be achieved regardless of whether the line segments are uniformly distributed or not. When the mesh model is reduced, the relationship between the parts of the mesh model can be clearly seen, and the color unevenness of the parts in the visual effect is avoided, thereby improving the user's perception. When the mesh model is rendered by the computer using the method, the rendering execution efficiency of the computer can be further improved because the mesh model is processed uniformly, and the processing difference caused by different mesh models is avoided, thereby improving the performance of the computer.
[0040] The present application will be described in detail below with reference to specific embodiments. Figures 2 to 12 The mesh model rendering method of the present application includes the following steps:
[0041] As shown in the drawings, the mesh model rendering method of the present application includes the following steps: Figure 2 S1: Obtain mesh model data, wherein the mesh model data includes face data and vertex data.
[0042] The mesh model is a three-dimensional model. The face data includes the shape, color, and drawing order of each face of the mesh model to be rendered. The vertex data includes the three-dimensional coordinates, color information, and line segment drawing order of the vertices of each line segment of the mesh model to be rendered.
[0043]
[0044] The color information of the vertex includes an original transparency value, a red component, a green component and a blue component. In the embodiment, the color information can be represented by a 32-bit unsigned integer; wherein, 8 bits represent one component of the color, for example: the highest 8 bits represent the Alpha value, i.e. the original transparency value, the next 8 bits to the lowest 8 bits represent the red component, the green component and the blue component respectively; wherein, the unsigned integer is a computer term, which represents an integer type that can only represent positive numbers and zero. In other embodiments, the color information can also use four single-precision floating-point numbers to represent the four components (original transparency value, red component, green component and blue component) respectively, and the single-precision floating-point number is used to represent a real number with a decimal part, which occupies a storage space of 4 bytes (32 bits).
[0045] Specifically, in the embodiment, the mesh model shown in FIG. 1 is taken as an example. As can be seen, the mesh model is a typical cube model, which includes six rectangular surfaces (i.e. surface 1234, surface 1456, surface 5687, surface 2378, surface 3457 and surface 1286) and 18 line segments (i.e. line segment 12, line segment 23, line segment 34, line segment 41, line segment 13, line segment 16, line segment 65, line segment 54, line segment 64, line segment 28, line segment 87, line segment 73, line segment 83, line segment 68, line segment 62, line segment 57, line segment 53 and line segment 67). Each line segment has two end points (i.e. a first vertex and a second vertex), so the 18 line segments have the three-dimensional coordinates and color information of 36 vertices in total. Each line segment needs to be drawn according to the line drawing order in the vertex data. Figure 3
[0046] S2: drawing a plurality of surface objects of the mesh model by using the surface data.
[0047] Specifically, the plurality of surface objects of the mesh model are drawn by using the shape, color and drawing order of each surface of the mesh model to be rendered in the surface data.
[0048] In the embodiment, the six rectangular surfaces (i.e. surface 1234, surface 1456, surface 5687, surface 2378, surface 3457 and surface 1286) of the mesh model shown in FIG. 1 are taken as an example, and the six rectangular surfaces are drawn. After the drawing is completed, the six rectangular surfaces are as shown in FIG. 2. Figure 3 Figure 4
[0049] Further, the plurality of line objects of the mesh model are prepared to be drawn.
[0050] S3: extracting the three-dimensional coordinates and color information of the first vertex and the second vertex of each line segment in the vertex data.
[0051] wherein, the first vertex and the second vertex represent the two end points of the line segment respectively.
[0052] Specifically, the vertex data (the 3D coordinates and color information of the vertices of each line segment) is first arranged in the line segment drawing order into the vertex buffer (such as the shader storage buffer of the OpenGL (Open Graphics Library) environment).
[0053] by Figure 3 Taking the mesh model shown as an example, the vertex data is arranged according to the set line segment drawing order (which can be adjusted as needed). Figure 5 As shown, the first position of the vertex buffer stores the three-dimensional coordinates and color information of the first vertex 1 of line segment 12, the second position of the vertex buffer stores the three-dimensional coordinates and color information of the second vertex 2 of line segment 12, and so on, with the 36th position (i.e. the last position) of the vertex buffer storing the three-dimensional coordinates and color information of the second vertex 7 of line segment 67.
[0054] Furthermore, an index ID is established for the first vertex of each line segment in the vertex data; where the index ID includes the storage location of the first vertex in the vertex buffer. For example, if an index ID is established for the first vertex 1 of line segment 14, then the index ID is 3, representing that the first vertex 1 of line segment 14 and its related information are stored in the 3rd position of the vertex buffer.
[0055] Furthermore, based on the established index ID, the three-dimensional coordinates and color information of the first and second vertices of each line segment are retrieved from the vertex buffer.
[0056] Specifically, the index ID is passed from the vertex shader to the geometry shader. Both the vertex shader and the geometry shader are specialized graphics processing units. In the geometry shader, the 3D coordinates and color information of the first and second vertices of each line segment are retrieved from the vertex buffer based on the index ID.
[0057] In this embodiment, with Figure 6 For example, if the currently drawn line segment is line segment 13, then according to the index ID of the first vertex 1 of line segment 13 (which is 5 in this case), the first vertex 1 is found from the 5th position of the vertex buffer, and the 3D coordinates and color information of the first vertex 1 are obtained; since the first vertex 1 and the second vertex 3 of line segment 13 are stored in adjacent positions in the vertex buffer, the second vertex 3 can be found from the 6th position of the vertex buffer, and the 3D coordinates and color information of the second vertex 3 can be obtained.
[0058] S4: Convert the 3D coordinates of the first and second vertices into screen coordinates.
[0059] Specifically, the model view matrix and projection matrix under the current rendering perspective are first obtained and then passed into the geometry shader.
[0060] The Model-View Matrix consists of a Model Matrix and a View Matrix. The Model Matrix transforms vertices from the local coordinate system to the world coordinate system, while the View Matrix transforms vertices from the world coordinate system to view space. The Model-View Matrix's role in transforming vertices from the local coordinate system to view space involves two main transformations: the model transformation and the view transformation. The Projection Matrix transforms vertices from view space to clip space (NDC, Normalized Device Coordinate space). During 3D model rendering, the Projection Matrix is responsible for projecting the 3D scene onto a 2D screen, typically including perspective projection and orthographic projection. Perspective projection simulates human vision, making distant objects appear smaller and nearby objects larger; orthographic projection maintains the size of objects unchanged.
[0061] Furthermore, the three-dimensional coordinates of the first and second vertices in world space are transformed into screen coordinates in NDC space through the model-view matrix (which records the position, pose, and orientation of the camera in the current rendering view) and the projection matrix (which records the intrinsic and extrinsic parameters of the camera).
[0062] S5: Calculate the distance between the first and second vertices based on their screen coordinates; calculate the target transparency value for each line segment based on the distance between the first and second vertices and the color information.
[0063] Specifically, with Figure 7 Taking the example shown, the distance d between the first vertex 1 and the second vertex 3 of the line segment 13 to be drawn is calculated based on the screen coordinates (2, 5) of the first vertex 1 and the screen coordinates (7, 2) of the second vertex 3. This distance is the length of the line segment 13.
[0064] Furthermore, using the distance between the first and second vertices of each line segment, the original transparency values in the color information of the first and second vertices are calculated and converted into target transparency values. This process can be represented by the following formula:
[0065]
[0066] Where color.a represents the target transparency value of the first and second vertices, 1.0f, 0.0f, and 50.0f represent empirical values, modelWidth represents the width of the entire mesh model displayed on the screen, screenWidth represents the screen width, length(screenPos1-screenPos2) represents the distance between the first and second vertices, and clamp(length(screenPos1-screenPos2)×50.0f, 0.0, 1.0) represents taking the range of the distance between the first and second vertices to [0, 1].
[0067] Furthermore, in this embodiment, the target transparency values of the first vertex and the second vertex are also used as the target transparency values of the corresponding line segments. That is, if the target transparency value of the first vertex 1 and the second vertex 3 of line segment 13 is 20, then the target transparency value of line segment 13 is also taken as 20.
[0068] By optimizing the target transparency value of a line segment by measuring the distance between its first and second vertices, longer line segments have higher opacity, while shorter line segments have higher transparency. This effectively improves the color difference in the display effect of each line segment caused by uneven distribution of line segments after the mesh model is scaled down, further enhancing the overall rendering effect.
[0069] S6: Based on the target transparency value, red component, green component, blue component, and screen coordinates of the first and second vertices of each line segment, draw the corresponding line object and generate a mesh model.
[0070] Specifically, each line segment is broken down into its corresponding number of pixels. For example, as shown... Figure 3 As shown, line segment 14 may correspond to multiple pixels on the screen. According to the set data, line segment 14 is divided into multiple pixels, such as 15 pixels. Then the target transparency value, red component, green component and blue component of line segment 14 are also the target transparency value, red component, green component and blue component of these 15 pixels.
[0071] Furthermore, the target opacity value, red component, green component, and blue component of the corresponding pixel are passed to the fragment shader. The fragment shader is the stage in the graphics rendering pipeline that handles pixel-level rendering. In the fragment shader, based on the corresponding target opacity value, red component, green component, blue component, and the screen coordinates of the first and second vertices of the line segment, the pixels corresponding to each line segment are filled with color, completing the drawing of the line object and generating a mesh model (e.g., ...). Figure 3 (The mesh model shown).
[0072] In summary, as shown in Figure 8 , Figure 8 is the comparison diagram of the same grid model rendered by the rendering method of the prior art (i.e. before optimization in Figure 8 ) and the rendering method of the present application (i.e. after optimization in Figure 8 ).
[0073] As shown in the grid model in Figure 8 , it is obvious that the rendering of the grid model by the rendering method of the prior art (i.e. before optimization in Figure 8 ) is poor after gradual reduction, and large black areas appear in the part where the line segments (i.e. grid lines) are densely distributed, which greatly affects the visual effect.
[0074] And the rendering of the grid model by the rendering method of the present application (i.e. after optimization in Figure 8 ) is very good after gradual reduction, even in the part where the line segments (i.e. grid lines) are densely distributed, the rendering color is basically consistent with that of other areas, without difference, effectively improving the overall rendering effect and enhancing the user's visual effect.
[0075] Based on the same inventive concept, as shown in Figure 9 , the present application also provides a grid model rendering device, which comprises:
[0076] The acquisition unit 101 is used to acquire grid model data, wherein the grid model data comprises face data and vertex data.
[0077] The face drawing unit 102 is used to draw a plurality of face objects of the grid model by using the face data.
[0078] The extraction unit 103 is used to extract the three-dimensional coordinates and color information of the first vertex and the second vertex of each line segment in the vertex data.
[0079] The conversion unit 104 is used to convert the three-dimensional coordinates of the first vertex and the second vertex into screen coordinates.
[0080] The calculation unit 105 is used to calculate the distance between the first vertex and the second vertex according to the screen coordinates of the first vertex and the second vertex, and is also used to calculate the target transparency value of each line segment according to the distance between the first vertex and the second vertex and the color information of each line segment.
[0081] The line drawing unit 106 is used to draw the corresponding line object according to the target transparency value, the red component, the green component, the blue component of each line segment, and the screen coordinates of the first vertex and the second vertex, and generate the grid model.
[0082] Further, as shown in Figure 10As shown, the extraction unit 103 includes a building sub-unit 107 and a retrieving sub-unit 108. The building sub-unit 107 is configured to arrange the vertex data in sequence to the vertex buffer, and build an index ID of a first vertex of each line segment in the vertex data. The retrieving sub-unit 108 is configured to find and acquire the three-dimensional coordinates and color information of the first vertex and the second vertex of each line segment from the vertex buffer according to the index ID.
[0083] Other technical features of the mesh model rendering device are the same as the features disclosed in the above-mentioned method embodiments, and can be referred to the descriptions in the corresponding method embodiments.
[0084] Based on the same inventive concept, the present application also provides an electronic device, which includes a processor, a memory and a communication circuit, the processor is connected to the memory and the communication circuit respectively; wherein the communication circuit is configured to be communicatively connected, the memory is configured to store a computer program, and the processor is configured to execute the computer program to implement the mesh model rendering method.
[0085] Referring to Figure 11 The electronic device described in the embodiments of the present application can specifically include a processor 210 and a memory 220. The memory 220 is coupled to the processor 210.
[0086] The processor 210 is configured to control the operation of the electronic device, and the processor 210 can also be referred to as a CPU (Central Processing Unit). The processor 210 can be an integrated circuit chip with a signal processing capability. The processor 210 can also be a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application-Specific Integrated Circuit), an FPGA (Field Programmable Gate Array) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. The general-purpose processor can be a microprocessor or the processor 210 can also be any conventional processor.
[0087] The memory 220 is configured to store a computer program, and can be a RAM or a ROM, or other types of storage terminals. Specifically, the memory 220 can include one or more computer-readable storage media, which can be non-transitory or transitory. The memory 220 can also include a high-speed random access memory and a non-volatile memory such as one or more disk storage terminals, flash memory storage terminals. In some embodiments, the non-transitory computer-readable storage medium in the memory 220 is configured to store at least one program code.
[0088] The processor 210 is configured to execute the computer program stored in the memory 220 to implement the method described in the method embodiments of the present application.
[0089] In some embodiments, the electronic device can further include a peripheral terminal interface 230 and at least one peripheral terminal. The processor 210, the memory 220 and the peripheral terminal interface 230 can be connected through a bus or a signal line. Each peripheral terminal can be connected to the peripheral terminal interface 230 through a bus, a signal line or a circuit board. Specifically, the peripheral terminal includes at least one of a radio frequency circuit 240, a display screen 250, an audio circuit 260 and a power supply 270.
[0090] The peripheral terminal interface 230 can be used to connect at least one peripheral terminal related to I / O (Input / output) to the processor 210 and the memory 220. In some embodiments, the processor 210, the memory 220 and the peripheral terminal interface 230 are integrated on the same chip or circuit board; in some other embodiments, any one or two of the processor 210, the memory 220 and the peripheral terminal interface 230 can be implemented on a separate chip or circuit board, and the present embodiment does not limit this.
[0091] The radio frequency circuit 240 is used to receive and transmit RF (Radio Frequency) signals, also known as electromagnetic signals. The radio frequency circuit 240 communicates with a communication network and other Internet of Things devices through electromagnetic signals, and the radio frequency circuit 240 is the communication circuit of the electronic device. The radio frequency circuit 240 converts electrical signals into electromagnetic signals for transmission, or converts received electromagnetic signals into electrical signals. Optionally, the radio frequency circuit 240 includes an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chip set, a subscriber identity module, and the like. The radio frequency circuit 240 can communicate with other terminals through at least one wireless communication protocol. The wireless communication protocol includes but is not limited to the World Wide Web, a metropolitan area network, an intranet, various generations of mobile communication networks (2G, 3G, 4G and 5G), a wireless local area network and / or a WiFi (Wireless Fidelity) network. In some embodiments, the radio frequency circuit 240 can also include NFC (Near Field Communication) related circuit, and the present application does not limit this.
[0092] The display screen 250 is configured to display a UI (User Interface). The UI can include graphics, text, icons, video, and any combination thereof. When the display screen 250 is a touch display screen, the display screen 250 is further configured to capture touch signals on or above the surface of the display screen 250. The touch signals can be input to the processor 210 as control signals for processing. In this case, the display screen 250 can also be configured to provide virtual buttons and / or virtual keyboards, also known as soft buttons and / or soft keyboards. In some embodiments, the display screen 250 can be one, disposed on the front panel of the electronic device; in other embodiments, the display screen 250 can be at least two, respectively disposed on different surfaces of the electronic device or in a folding design; in yet other embodiments, the display screen 250 can be a flexible display screen, disposed on a curved surface or a folding surface of the electronic device. Even, the display screen 250 can also be disposed in an irregular shape, i.e., a special-shaped screen. The display screen 250 can be made of materials such as LCD (Liquid Crystal Display), OLED (Organic Light-Emitting Diode), etc.
[0093] The audio circuit 260 can include a microphone and a speaker. The microphone is configured to capture sound waves of the operator and the environment, and convert the sound waves into electrical signals input to the processor 210 for processing, or input to the radio frequency circuit 240 to realize voice communication. For the purpose of stereo sound collection or noise reduction, the microphone can be multiple, respectively disposed on different parts of the electronic device. The microphone can also be an array microphone or an omnidirectional collection microphone. The speaker is configured to convert electrical signals from the processor 210 or the radio frequency circuit 240 into sound waves. The speaker can be a traditional thin-film speaker or a piezoelectric ceramic speaker. When the speaker is a piezoelectric ceramic speaker, it can not only convert electrical signals into sound waves audible to humans, but also convert electrical signals into sound waves inaudible to humans for ranging purposes. In some embodiments, the audio circuit 260 can further include a headphone jack.
[0094] The power supply 270 is configured to supply power to various components in the electronic device. The power supply 270 can be an alternating current, a direct current, a disposable battery, or a rechargeable battery. When the power supply 270 includes a rechargeable battery, the rechargeable battery can be a wired rechargeable battery or a wireless rechargeable battery. The wired rechargeable battery is a battery that is charged through a wired line, and the wireless rechargeable battery is a battery that is charged through a wireless coil. The rechargeable battery can also be used to support fast charging technology.
[0095] For detailed descriptions of the functions and execution processes of the functional modules or components in the embodiments of the electronic device of the present application, reference can be made to the descriptions of the embodiments of the methods of the present application described above, which will not be repeated here.
[0096] In several embodiments provided in the present application, it should be understood that the disclosed electronic device and method can be implemented in other manners. For example, the above-described embodiments of the electronic device are merely illustrative, and the division of the modules or units can be different, for example, the modules or units can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the displayed or discussed mutual couplings or direct couplings or communication connections can be indirect couplings or communication connections through some interfaces, devices or units, and can be in electrical, mechanical or other forms.
[0097] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, i.e., they can be located in one place, or distributed on multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the present embodiment.
[0098] In addition, each functional unit in each embodiment of the present application can be integrated into a processing unit, or each unit can exist physically, or two or more units can be integrated into one unit. The integrated unit can be realized in the form of hardware or in the form of a software functional unit.
[0099] Based on the same inventive concept, the present application also provides a computer readable storage medium storing a computer program, which can be executed by a processor to implement the above-mentioned grid model rendering method.
[0100] Referring to Figure 12 The integrated unit, if realized in the form of a software functional unit and sold or used as an independent product, can be stored in the computer readable storage medium 300. Based on such understanding, the technical solutions of the present application essentially or the part that contributes to the prior art or the whole or part of the technical solutions can be embodied in the form of a software product, which is stored in a storage medium and includes a number of instructions / computer programs for making an Internet of Things device (which can be a personal computer, a server, or a network terminal, etc.) or a processor execute all or part of the steps of the methods of the various embodiments of the present application. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk or an optical disk, and various media with the above storage medium, and electronic terminals such as computers, mobile phones, notebook computers, tablet computers, cameras, etc.
[0101] The execution process of the program data in the computer readable storage medium can refer to the description of the above-mentioned method embodiments of the application, and will not be repeated here.
[0102] It can be seen that the application discloses a mesh model rendering method, device, equipment and medium, the method comprising the steps of: obtaining mesh model data, wherein the mesh model data comprises face data and vertex data; using the face data to draw a plurality of face objects of the mesh model; extracting the three-dimensional coordinates and color information of the first vertex and the second vertex of each line segment in the vertex data; converting the three-dimensional coordinates of the first vertex and the second vertex into screen coordinates; calculating the distance between the first vertex and the second vertex according to the screen coordinates of the first vertex and the second vertex; calculating the target transparency value of each line segment according to the distance between the first vertex and the second vertex of each line segment and the color information; and drawing the corresponding line object according to the target transparency value of each line segment, the red component, the green component, the blue component, and the screen coordinates of the first vertex and the second vertex, and generating the mesh model. When rendering the mesh model, the application first draws the face object and further draws the line object. When drawing the line object, the transparency value of each line segment is optimized by the distance between the first vertex and the second vertex of the line segment, so that when the mesh model is displayed in a reduced manner, good rendering effect can be presented regardless of whether the line segments are uniformly distributed or not, the relationship between the parts of the mesh model can be clearly seen when the mesh model is reduced, the color unevenness of the parts in the visual effect is avoided, and the user's perception of the computer processing and display is improved. Using the method to render the mesh model can further improve the rendering execution efficiency of the computer and improve the computer performance.
[0103] The above is only an embodiment of the application, and does not limit the protection scope of the application, and any equivalent structural transformation or direct or indirect application in other related technical fields by using the content of the specification and drawings of the application is included in the protection scope of the application.
Claims
1. A method for rendering mesh models, characterized in that, Including the following steps: Obtain mesh model data, wherein the mesh model data includes face data and vertex data; Using the surface data, draw multiple surface objects of the mesh model; Extract the three-dimensional coordinates and color information of the first and second vertices of each line segment from the vertex data; Convert the three-dimensional coordinates of the first vertex and the second vertex into screen coordinates; Based on the screen coordinates of the first vertex and the second vertex, the distance between the first vertex and the second vertex is calculated; based on the distance between the first vertex and the second vertex of each line segment and the color information, the target transparency value of each line segment is calculated, including: the color information includes the original transparency value, red component, green component, and blue component; using the distance between the first vertex and the second vertex of each line segment, the original transparency value of the first vertex and the second vertex is converted into the target transparency value; based on the target transparency value of the first vertex and the second vertex, the target transparency value of the corresponding line segment is obtained; Based on the target transparency value, red component, green component, and blue component of each line segment, as well as the screen coordinates of the first vertex and the second vertex, the corresponding line object is drawn to generate the mesh model.
2. The mesh model rendering method according to claim 1, characterized in that, The step of extracting the three-dimensional coordinates and color information of the first and second vertices of each line segment in the vertex data includes: The vertex data is arranged sequentially in the vertex buffer, and an index ID of the first vertex of each line segment in the vertex data is established; Based on the index ID, the three-dimensional coordinates and color information of the first and second vertices of each line segment are retrieved from the vertex buffer.
3. The mesh model rendering method according to claim 2, characterized in that, The index ID includes the storage location of the first vertex in the vertex buffer.
4. The mesh model rendering method according to claim 1, characterized in that, The step of converting the three-dimensional coordinates of the first vertex and the second vertex into screen coordinates includes: Obtain the model view matrix and projection matrix from the current rendering perspective; The model-view matrix and projection matrix are used to transform the three-dimensional coordinates of the first vertex and the second vertex in world space into screen coordinates in NDC space.
5. The mesh model rendering method according to claim 1, characterized in that, The step of drawing the corresponding line object based on the target transparency value, red component, green component, and blue component of each line segment, as well as the screen coordinates of the first vertex and the second vertex, includes: Each line segment is divided into a corresponding number of pixels; Based on the target transparency value, red component, green component, and blue component of each line segment, and the screen coordinates of the first vertex and the second vertex, the pixel corresponding to each line segment is filled with color.
6. A mesh model rendering device, characterized in that, include: An acquisition unit is used to acquire mesh model data, wherein the mesh model data includes face data and vertex data; A face drawing unit is used to draw multiple face objects of the mesh model using the face data; The extraction unit is used to extract the three-dimensional coordinates and color information of the first and second vertices of each line segment in the vertex data; The conversion unit is used to convert the three-dimensional coordinates of the first vertex and the second vertex into screen coordinates; The calculation unit is configured to calculate the distance between the first vertex and the second vertex based on the screen coordinates of the first vertex and the second vertex; and to calculate the target transparency value of each line segment based on the distance between the first vertex and the second vertex of each line segment and the color information, including: the color information including an original transparency value, a red component, a green component, and a blue component; using the distance between the first vertex and the second vertex of each line segment, converting the original transparency value of the first vertex and the second vertex into the target transparency value; and obtaining the target transparency value of the corresponding line segment based on the target transparency value of the first vertex and the second vertex. The line drawing unit is used to draw the corresponding line object and generate the mesh model based on the target transparency value, red component, green component, blue component, and the screen coordinates of the first vertex and the second vertex of each line segment.
7. The mesh model rendering apparatus according to claim 6, characterized in that, The extraction unit includes: A subunit is established to arrange the vertex data sequentially into the vertex buffer and to establish the index ID of the first vertex of each line segment in the vertex data; The lookup sub-unit is used to search for and obtain the three-dimensional coordinates and color information of the first and second vertices of each line segment from the vertex buffer based on the index ID.
8. An electronic device, characterized in that, It includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, implements the steps of the method as claimed in any one of claims 1 to 5.
9. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Rendering method and device of three-dimensional grid body
CN111508052A
Volume rendering image generation method and device based on generative network
CN118096984A