Dynamic mesh coordinate generation method and system, computer device and storage medium

By receiving the viewport space coordinates of the vertices and inversely transforming them into world space coordinates, primitives are generated and rasterized. This solves the problem that grid coordinate display consumes a lot of performance resources and is not easy to dynamically adjust, and enables dynamic adjustment of the grid scale, thus improving the display effect.

CN115661402BActive Publication Date: 2026-04-28GUANGZHOU SHANDI INTELLIGENT CLOTHING TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
GUANGZHOU SHANDI INTELLIGENT CLOTHING TECH CO LTD
Filing Date
2022-10-11
Publication Date
2026-04-28

AI Technical Summary

Technical Problem

In existing technologies, grid coordinate displays generated based on straight lines consume a lot of performance resources and are not convenient for dynamically adjusting the grid scale, thus affecting the display effect.

Method used

By receiving the viewport coordinates of the vertices, inversely transforming them into world space coordinates, generating primitives and rasterizing them, and dynamically adjusting the mesh scale by combining scaling and scale calculations.

Benefits of technology

It enables dynamic adjustment of the grid scale according to actual needs, improving the display effect and reducing performance resource consumption.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115661402B_ABST
    Figure CN115661402B_ABST
Patent Text Reader

Abstract

The application relates to a dynamic grid coordinate generation method, system, computer equipment and storage medium, and the technical scheme points are as follows: receiving window space coordinates of multiple vertices, inversely transforming the window space coordinates of the vertices into corresponding world space coordinates; generating a primitive using the window space coordinates of all the vertices; performing primitive assembly and primitive rasterization on the primitive to determine target pixel points; performing interpolation calculation on the primitive after the primitive rasterization according to the world space coordinates of the vertices to obtain the world space coordinates of the target pixel points; determining a scaling ratio of the world space coordinates of the vertices and the corresponding window space coordinates according to the inverse transformation, and determining a scale according to the scaling ratio; determining to-be-colored pixel points according to the scale, a preset grid line width and the world space coordinates of the target pixel points, coloring the to-be-colored pixel points to obtain a grid; and the application has the effect of dynamically adjusting the grid scale and better display effect.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of coordinate generation technology, and more specifically, to a dynamic mesh coordinate generation method, system, computer device, and storage medium. Background Technology

[0002] Virtual clothing simulation technology has entered a stage of rapid development in recent years, and most mainstream clothing simulation technologies are based on mesh modeling and simulation.

[0003] The mesh in clothing simulation originates from the pattern design created by the designer or pattern maker. The pattern design requires clear coordinate axes to assist in positioning dimensions. Currently, most mainstream coordinate axis positioning is generated by straight lines: assuming a coordinate range of [-n, n], then (2n+1) lines in the x-direction and (2n+1) lines in the y-direction need to be generated, requiring (2n+1)*2*2 vertex data. For performance reasons, the application will perform various calculations to ensure that only the lines displayed on the screen are sent for rendering. However, at least m*2 vertex data are still required (m is the number of lines that can be displayed on the screen, and performance is positively correlated with m) to form the mesh coordinates. This results in the coordinate axis display consuming too many performance resources and making it inconvenient to dynamically adjust the scale of the mesh coordinates. Summary of the Invention

[0004] To address the shortcomings of existing technologies, the present invention aims to provide a dynamic grid coordinate generation method, system, computer device, and storage medium, which has the advantages of dynamically adjusting the grid scale and providing better display effects.

[0005] The above-mentioned technical objective of the present invention is achieved through the following technical solution:

[0006] A method for generating dynamic mesh coordinates, comprising:

[0007] Receive the view space coordinates of multiple vertices, and inversely transform the view space coordinates of each vertex into the corresponding world space coordinates;

[0008] Primitives are generated using the viewport space coordinates of all the aforementioned vertices;

[0009] The primitives are assembled and rasterized to determine the target pixels;

[0010] The world space coordinates of the target pixel are obtained by interpolating the rasterized primitive based on the world space coordinates of the vertex.

[0011] The scaling ratio of the world space coordinates of the vertex and the corresponding viewport space coordinates is determined according to the inverse transformation, and the scale is determined according to the scaling ratio.

[0012] The pixels to be colored are determined based on the scale, the preset grid line width, and the world space coordinates of each target pixel. The pixels to be colored are then colored to obtain the grid.

[0013] Optionally, the inverse transformation of the viewport space coordinates of each vertex to the corresponding world space coordinates includes:

[0014] The inverse matrix obtained by multiplying the preset orthogonal projection matrix by the preset view matrix is ​​multiplied by the view space coordinates of each vertex to obtain the corresponding world space coordinates.

[0015] Optionally, determining the scaling ratio of world space coordinates and viewport space coordinates based on the inverse transformation includes:

[0016] The value in the 0th row and 0th column of the inverse matrix obtained by multiplying the preset orthogonal projection matrix and the preset view matrix is ​​used as the scaling ratio of the world space coordinates of the vertex and the corresponding view space coordinates.

[0017] Optionally, determining the scale according to the scaling ratio includes:

[0018] ,

[0019] in, Indicates the scale, Indicates the scaling ratio. Indicates to Rounding down, It represents a power.

[0020] Optionally, determining the pixel to be colored based on the scale and the world space coordinates of each pixel includes:

[0021] The target pixel that conforms to the coloring calculation formula is determined as the pixel to be colored. The coloring calculation formula is:

[0022] ,

[0023] Among them, the Represents the pixel to be colored. Represents the target pixel. World space coordinates on the x-axis. Represents the target pixel. exist World space coordinates on the axis Indicates the scale, Indicates the preset grid line width. Represents the target pixel. The value is the world space coordinates of the right target pixel on the x-axis minus the world space coordinates of the left target pixel on the x-axis. Represents the target pixel. The value is the difference between the world space coordinates of the upper target pixel on the y-axis and the world space coordinates of the lower target pixel on the y-axis. The symbol represents the modulo operator, and | represents the OR operator.

[0024] Optionally, the view space coordinates of the three vertices are received, and the primitives generated using the view space coordinates of all the vertices are triangular type primitives.

[0025] Optionally, the step of interpolating the rasterized primitives based on the world space coordinates of the vertex to obtain the world space coordinates of the target pixel includes:

[0026] Establish a mapping relationship between each target pixel corresponding to each vertex and its corresponding world space coordinates, and obtain the world space coordinate values ​​of the remaining target pixels according to the following calculation formula;

[0027] ;

[0028] ;

[0029] ;

[0030] in, Represents the target pixel. World coordinates on the x-axis, Represents the target pixel. World space coordinates on the y-axis. Represents the target pixel. World space coordinates on the z-axis, This represents the viewport coordinates of the bottom-left vertex on the x-axis. This represents the viewport coordinates of the bottom-right vertex on the x-axis. This represents the viewport coordinates of the bottom-right vertex on the y-axis. This represents the viewport coordinates of the topmost vertex on the y-axis. This represents the viewport space value of the target pixel on the x-axis. This represents the viewport space value of the target pixel on the y-axis. This represents the world space coordinates of the bottom-left vertex on the x-axis. This represents the world space coordinates of the bottom-left vertex on the y-axis. This represents the world space coordinates of the bottom-right vertex on the x-axis. This represents the world space coordinates of the bottom-right vertex on the y-axis. This represents the world space coordinates of the uppermost of the three vertices on the y-axis.

[0031] A dynamic mesh coordinate generation system, comprising:

[0032] The receiving transformation module is used to receive the view space coordinates of multiple vertices and inversely transform the view space coordinates of each vertex into the corresponding world space coordinates.

[0033] The primitive generation module is used to generate primitives using the view space coordinates of all the vertices;

[0034] The primitive processing module is used to assemble the primitives and rasterize them to determine the target pixels.

[0035] The interpolation calculation module is used to perform interpolation calculations on the rasterized primitives based on the world space coordinates of the vertex to obtain the world space coordinates of the target pixel.

[0036] The scale determination module is used to determine the scaling ratio of the world space coordinates of the vertex and the corresponding viewport space coordinates according to the inverse transformation, and to determine the scale according to the scaling ratio.

[0037] The coloring determination module is used to determine the pixel to be colored based on the scale, the preset grid line width and the world space coordinates of each target pixel, and to color the pixel to be colored to obtain a grid.

[0038] A computer device includes a memory and a processor, the memory storing a computer program, the processor executing the computer program to implement the steps of the aforementioned method.

[0039] A computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the aforementioned method.

[0040] In summary, the present invention has the following beneficial effects: the scale of the grid is determined by the scaling ratio of the world space coordinates of the vertices and the corresponding viewport space coordinates, so as to adjust the grid scale displayed in the viewport according to the actual situation. When a large coordinate range needs to be displayed, the scaling ratio of the world space and viewport space will increase during the inverse transformation of the vertex viewport space coordinates to the corresponding world space coordinates, thereby increasing the scale. This achieves dynamic adjustment of the scale and thus dynamic adjustment of the grid, so as to display large or small coordinate ranges according to actual needs, resulting in a better display effect. Attached Figure Description

[0041] Figure 1This is a flowchart illustrating the dynamic mesh coordinate generation method provided by the present invention;

[0042] Figure 2 This is a structural block diagram of the dynamic mesh coordinate generation system provided by the present invention;

[0043] Figure 3 This is an internal structural diagram of the computer device in an embodiment of the present invention. Detailed Implementation

[0044] To make the objectives, features, and advantages of the present invention more apparent and understandable, specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings. Several embodiments of the present invention are shown in the drawings. However, the present invention can be implemented in many different forms and is not limited to the embodiments described herein.

[0045] In this invention, unless otherwise explicitly specified and limited, the terms "installation," "connection," "linking," and "fixing," etc., should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal connection of two components. Those skilled in the art can understand the specific meaning of the above terms in this invention according to the specific circumstances. The terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, a feature defined with "first" or "second" may explicitly or implicitly include one or more of that feature.

[0046] The present invention will now be described in detail with reference to the accompanying drawings and embodiments.

[0047] This invention provides a method for generating dynamic mesh coordinates, such as... Figure 1 As shown, it includes:

[0048] Step 100: Receive the view space coordinates of multiple vertices, and inversely transform the view space coordinates of each vertex into the corresponding world space coordinates;

[0049] Step 200: Generate primitives using the view space coordinates of all the vertices; In this application, the number of vertices received can be three, that is, in this application, multiple scale grids can be drawn through the memory input of the three vertices, and the overall complexity is a constant, making the space complexity of this application O(1), and the performance resources occupied are low. The three vertices are used to form triangular primitives. The primitives can include the attribute of the connection information between vertices. The connection information between vertices can indicate the order in which the vertices included in the primitive are connected to each other (e.g., in a clockwise or counterclockwise direction). The view space coordinates of the three vertices are inversely transformed into world space coordinates so as to facilitate subsequent interpolation calculations to obtain the world space coordinates of the pixel points corresponding to the primitives;

[0050] Step 300: Perform primitive assembly and primitive rasterization on the primitives to determine the target pixel. In this application, the viewport space coordinates of the three vertices are a(-1, -1, 0), b(3, -1, 0), and c(-1, 3, 0). The triangular primitive generated by these three vertices includes these three vertices. Perform primitive assembly on the triangular primitive. Since the viewport is a two-dimensional rectangular window area, and the display range defined by the viewport on the x-axis is -1 to 1, and the display range defined on the y-axis is also -1 to 1, that is, when the three vertices are a(-1, -1, 0), b(3, -1, 0), and c(-1, 3, 0), the triangular primitive is clipped, and then the clipped primitive is transformed by the viewport. This can achieve the goal of filling the entire viewport with the primitive after primitive assembly. Then, the primitive after primitive assembly is rasterized to determine the target pixel.

[0051] Step 400: Interpolate the rasterized primitives based on the world space coordinates of the vertex to obtain the world space coordinates of the target pixel.

[0052] Step 500: Determine the scaling ratio of the world space coordinates of the vertex and the corresponding viewport space coordinates according to the inverse transformation, and determine the scale according to the scaling ratio;

[0053] Step 600: Determine the pixel to be colored based on the scale, the preset grid line width, and the world space coordinates of each target pixel, and color the pixel to be colored to obtain the grid.

[0054] In this application, the scaling ratio of the world space coordinates of the vertex and the corresponding viewport space coordinates is also the scaling ratio of world space and viewport space. The scale of the grid is determined by the scaling ratio of the world space coordinates of the vertex and the corresponding viewport space coordinates, so as to adjust the grid scale displayed in the viewport according to the actual situation. If a large coordinate range needs to be displayed, the scaling ratio of world space and viewport space will increase during the inverse transformation of the vertex's viewport space coordinates to the corresponding world space coordinates, thereby increasing the scale. This achieves dynamic adjustment of the scale, thereby achieving dynamic adjustment of the grid, so as to display a large or small coordinate range according to actual needs.

[0055] Further, the inverse transformation of the viewport space coordinates of each vertex to the corresponding world space coordinates includes:

[0056] The inverse matrix obtained by multiplying the preset orthogonal projection matrix by the preset view matrix is ​​multiplied by the view space coordinates of each vertex to obtain the corresponding world space coordinates.

[0057] In practical applications, the preset orthogonal projection matrix and preset view matrix can be further adjusted. The preset orthogonal projection matrix can be established based on the relevant parameters of the scene volume, including: the field of view angle of the scene volume, the aspect ratio of the scene volume, and the distance from the camera to the nearest clipping plane of the scene volume. The preset view matrix can be established based on the relevant parameters of the camera, including: the camera position and the camera angle, etc. Multiplying the inverse matrix obtained by multiplying the preset orthogonal projection matrix and the preset view matrix with the view space coordinates of each vertex completes the inverse transformation of the view space coordinates of the vertex, thus obtaining the world space coordinates of the vertex.

[0058] Further, determining the scaling ratio of world space coordinates and viewport space coordinates based on the inverse transformation includes:

[0059] The value in the 0th row and 0th column of the inverse matrix obtained by multiplying the preset orthogonal projection matrix and the preset view matrix is ​​used as the scaling ratio of the world space coordinates of the vertex and the corresponding view space coordinates.

[0060] In practical applications, the preset orthogonal projection matrix and the preset view matrix will change according to the actual situation. The inverse matrix after multiplying the preset orthogonal projection matrix and the preset view matrix will also change. By using the value of the 0th row and 0th column of the inverse matrix after multiplying the preset orthogonal projection matrix and the preset view matrix as the scaling ratio of the world space coordinates of the vertex and the corresponding view space coordinates, the scaling ratio will change according to the actual situation, that is, the scale will change according to the actual situation, thus realizing the function of dynamically adjusting the mesh in this application.

[0061] Further, determining the scale according to the scaling ratio includes:

[0062] ;

[0063] in, Indicates the scale, Indicates the scaling ratio. Indicates to Rounding down, It represents a power.

[0064] Specifically, through the formula To calculate the scale, so that the scale is determined according to the scaling ratio, when the scaling ratio reaches... In this case, the scale changes, meaning the scale is adjusted according to a 10x scaling ratio.

[0065] Further, determining the pixel to be colored based on the scale and the world space coordinates of each pixel includes:

[0066] The target pixel that conforms to the coloring calculation formula is determined as the pixel to be colored. The coloring calculation formula is:

[0067] ;

[0068] Among them, the Represents the pixel to be colored. Represents the target pixel. World space coordinates on the x-axis. Represents the target pixel. World space coordinates on the y-axis. Indicates the scale, Indicates the preset grid line width. Represents the target pixel. The value is the world space coordinates of the right target pixel on the x-axis minus the world space coordinates of the left target pixel on the x-axis. Represents the target pixel. The value is the difference between the world space coordinates of the upper target pixel on the y-axis and the world space coordinates of the lower target pixel on the y-axis. The symbol represents the modulo operator, and | represents the OR operator.

[0069] Specifically, in this application, the determination of whether a target pixel is a pixel to be colored is based on the scale and the preset grid line width. If the remainder of the world space coordinate value of the target pixel on the x-axis divided by the scale is less than the product of the preset grid line width and the world space coordinate value of the target pixel to the right minus the world space coordinate value of the target pixel to the left, then the target pixel is determined to be a pixel to be colored. Alternatively, if the remainder of the world space coordinate value of the target pixel on the y-axis divided by the scale is less than the product of the preset grid line width and the world space coordinate value of the target pixel above minus the world space coordinate value of the target pixel below, then the target pixel is also determined to be a pixel to be colored. This ensures the accuracy of the scale representation, reduces the influence of the preset grid line width on the scale, and since this operation has a constant time complexity, the time complexity is O(1).

[0070] Further, the step of interpolating the rasterized primitives based on the world space coordinates of the vertex to obtain the world space coordinates of the target pixel includes:

[0071] Establish a mapping relationship between each target pixel corresponding to each vertex and its corresponding world space coordinates, and obtain the world space coordinate values ​​of the remaining target pixels according to the following calculation formula;

[0072] ;

[0073] ;

[0074] ;

[0075] in, Represents the target pixel. World coordinates on the x-axis, Represents the target pixel. World space coordinates on the y-axis. Represents the target pixel. World space coordinates on the z-axis, This represents the viewport coordinates of the bottom-left vertex on the x-axis. This represents the viewport coordinates of the bottom-right vertex on the x-axis. This represents the viewport coordinates of the bottom-right vertex on the y-axis. This represents the viewport coordinates of the topmost vertex on the y-axis. This represents the viewport space value of the target pixel on the x-axis. This represents the viewport space value of the target pixel on the y-axis. This represents the world space coordinates of the bottom-left vertex on the x-axis. This represents the world space coordinates of the bottom-left vertex on the y-axis. This represents the world space coordinates of the bottom-right vertex on the x-axis. This represents the world space coordinates of the bottom-right vertex on the y-axis. This represents the world space coordinates of the uppermost of the three vertices on the y-axis.

[0076] In practical applications, the world space coordinates of each target pixel are obtained through interpolation calculation, which facilitates the subsequent calculation of the pixel to be colored. With the three vertices being a(-1, -1, 0), b(3, -1, 0), and c(-1, 3, 0), vertex a is located at the lower left corner, vertex b at the lower right corner, and vertex c at the upper left corner. Based on the interpolation calculation, the world space coordinates of all target pixels within the primitive can be obtained.

[0077] The dynamic mesh coordinate generation method of the present invention determines the mesh scale by scaling the world space coordinates of the vertices and the corresponding viewport space coordinates. This allows for adjustment of the mesh scale displayed in the viewport according to actual conditions. For example, when a large coordinate range needs to be displayed, the scaling ratio between the world space and viewport space increases during the inverse transformation of the vertex's viewport space coordinates to the corresponding world space coordinates, thereby increasing the scale. This achieves dynamic adjustment of the scale and thus dynamic adjustment of the mesh, allowing for the display of large or small coordinate ranges according to actual needs.

[0078] like Figure 2 As shown, the present invention also provides a dynamic grid coordinate system, comprising:

[0079] The receiving transformation module 10 is used to receive the window space coordinates of multiple vertices and inversely transform the window space coordinates of each vertex into the corresponding world space coordinates.

[0080] Primitive generation module 20 is used to generate primitives using the view space coordinates of all the vertices;

[0081] The primitive processing module 30 is used to perform primitive assembly and primitive rasterization to determine target pixel points;

[0082] Interpolation calculation module 40 is used to perform interpolation calculation on the rasterized primitives based on the world space coordinates of the vertex to obtain the world space coordinates of the target pixel.

[0083] The scale determination module 50 is used to determine the scaling ratio of the world space coordinates of the vertex and the corresponding viewport space coordinates according to the inverse transformation, and to determine the scale according to the scaling ratio.

[0084] The coloring determination module 60 is used to determine the pixel to be colored based on the scale, the preset grid line width and the world space coordinates of each target pixel, and to color the pixel to be colored to obtain a grid.

[0085] Specific limitations regarding the dynamic mesh coordinate generation system can be found in the limitations of the dynamic mesh coordinate generation method described above, and will not be repeated here. Each module of the aforementioned dynamic mesh coordinate generation system can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in hardware or independent of the processor in a computer device, or stored in software in the memory of a computer device, so that the processor can call and execute the corresponding operations of each module.

[0086] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 3 As shown, the computer device includes a processor, memory, network interface, and database connected via a system bus. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and database. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The network interface is used for communication with external terminals via a network connection. When executed by the processor, the computer program implements a dynamic mesh coordinate generation method.

[0087] Those skilled in the art will understand that Figure 3 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0088] In one embodiment, a computer device is provided, including a memory and a processor, the memory storing a computer program, the processor executing the computer program to perform the following steps:

[0089] Receive the view space coordinates of multiple vertices, and inversely transform the view space coordinates of each vertex into the corresponding world space coordinates;

[0090] Primitives are generated using the viewport space coordinates of all the aforementioned vertices;

[0091] The primitives are assembled and rasterized to determine the target pixels;

[0092] The world space coordinates of the target pixel are obtained by interpolating the rasterized primitive based on the world space coordinates of the vertex.

[0093] The scaling ratio of the world space coordinates of the vertex and the corresponding viewport space coordinates is determined according to the inverse transformation, and the scale is determined according to the scaling ratio.

[0094] The pixels to be colored are determined based on the scale, the preset grid line width, and the world space coordinates of each target pixel. The pixels to be colored are then colored to obtain the grid.

[0095] In one embodiment, the inverse transformation of the viewport space coordinates of each vertex to the corresponding world space coordinates includes:

[0096] The inverse matrix obtained by multiplying the preset orthogonal projection matrix by the preset view matrix is ​​multiplied by the view space coordinates of each vertex to obtain the corresponding world space coordinates.

[0097] In one embodiment, determining the scaling ratio of world space coordinates and viewport space coordinates based on the inverse transformation includes:

[0098] The value in the 0th row and 0th column of the inverse matrix obtained by multiplying the preset orthogonal projection matrix and the preset view matrix is ​​used as the scaling ratio of the world space coordinates of the vertex and the corresponding view space coordinates.

[0099] In one embodiment, determining the scale according to the scaling ratio includes:

[0100] ;

[0101] in, Indicates the scale, Indicates the scaling ratio. Indicates to Rounding down, It represents a power.

[0102] In one embodiment, determining the pixel to be colored based on the scale and the world space coordinates of each pixel includes:

[0103] The target pixel that conforms to the coloring calculation formula is determined as the pixel to be colored. The coloring calculation formula is:

[0104] ;

[0105] Among them, the Represents the pixel to be colored. Represents the target pixel. World space coordinates on the x-axis. Represents the target pixel. World space coordinates on the y-axis. Indicates the scale, Indicates the preset grid line width. Represents the target pixel. The value is the world space coordinates of the right target pixel on the x-axis minus the world space coordinates of the left target pixel on the x-axis. Represents the target pixel. The value is the difference between the world space coordinates of the upper target pixel on the y-axis and the world space coordinates of the lower target pixel on the y-axis. The symbol represents the modulo operator, and | represents the OR operator.

[0106] In one embodiment, the view space coordinates of three vertices are received, and the primitives generated using the view space coordinates of all said vertices are triangular type primitives.

[0107] In one embodiment, the step of interpolating the rasterized primitives based on the world space coordinates of the vertex to obtain the world space coordinates of the target pixel includes:

[0108] Establish a mapping relationship between each target pixel corresponding to each vertex and its corresponding world space coordinates, and obtain the world space coordinate values ​​of the remaining target pixels according to the following calculation formula;

[0109] ;

[0110] ;

[0111] ;

[0112] in, Represents the target pixel. World coordinates on the x-axis, Represents the target pixel. World space coordinates on the y-axis. Represents the target pixel. World space coordinates on the z-axis, This represents the viewport coordinates of the bottom-left vertex on the x-axis. This represents the viewport coordinates of the bottom-right vertex on the x-axis. This represents the viewport coordinates of the bottom-right vertex on the y-axis. This represents the viewport coordinates of the topmost vertex on the y-axis. This represents the viewport space value of the target pixel on the x-axis. This represents the viewport space value of the target pixel on the y-axis. This represents the world space coordinates of the bottom-left vertex on the x-axis. This represents the world space coordinates of the bottom-left vertex on the y-axis. This represents the world space coordinates of the bottom-right vertex on the x-axis. This represents the world space coordinates of the bottom-right vertex on the y-axis. This represents the world space coordinates of the uppermost of the three vertices on the y-axis.

[0113] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, the computer program performing the following steps when executed by a processor:

[0114] Receive the view space coordinates of multiple vertices, and inversely transform the view space coordinates of each vertex into the corresponding world space coordinates;

[0115] Primitives are generated using the viewport space coordinates of all the aforementioned vertices;

[0116] The primitives are assembled and rasterized to determine the target pixels;

[0117] The world space coordinates of the target pixel are obtained by interpolating the rasterized primitive based on the world space coordinates of the vertex.

[0118] The scaling ratio of the world space coordinates of the vertex and the corresponding viewport space coordinates is determined according to the inverse transformation, and the scale is determined according to the scaling ratio.

[0119] The pixels to be colored are determined based on the scale, the preset grid line width, and the world space coordinates of each target pixel. The pixels to be colored are then colored to obtain the grid.

[0120] In one embodiment, the inverse transformation of the viewport space coordinates of each vertex to the corresponding world space coordinates includes:

[0121] The inverse matrix obtained by multiplying the preset orthogonal projection matrix by the preset view matrix is ​​multiplied by the view space coordinates of each vertex to obtain the corresponding world space coordinates.

[0122] In one embodiment, determining the scaling ratio of world space coordinates and viewport space coordinates based on the inverse transformation includes:

[0123] The value in the 0th row and 0th column of the inverse matrix obtained by multiplying the preset orthogonal projection matrix and the preset view matrix is ​​used as the scaling ratio of the world space coordinates of the vertex and the corresponding view space coordinates.

[0124] In one embodiment, determining the scale according to the scaling ratio includes:

[0125] ;

[0126] in, Indicates the scale, Indicates the scaling ratio. Indicates to Rounding down, It represents a power.

[0127] In one embodiment, determining the pixel to be colored based on the scale and the world space coordinates of each pixel includes:

[0128] The target pixel that conforms to the coloring calculation formula is determined as the pixel to be colored. The coloring calculation formula is:

[0129] ;

[0130] Among them, the Represents the pixel to be colored. Represents the target pixel. World space coordinates on the x-axis. Represents the target pixel. World space coordinates on the y-axis. Indicates the scale, Indicates the preset grid line width. Represents the target pixel. The value is the world space coordinates of the right target pixel on the x-axis minus the world space coordinates of the left target pixel on the x-axis. Represents the target pixel. The value is the difference between the world space coordinates of the upper target pixel on the y-axis and the world space coordinates of the lower target pixel on the y-axis. The symbol represents the modulo operator, and | represents the OR operator.

[0131] In one embodiment, the view space coordinates of three vertices are received, and the primitives generated using the view space coordinates of all said vertices are triangular type primitives.

[0132] In one embodiment, the step of interpolating the rasterized primitives based on the world space coordinates of the vertex to obtain the world space coordinates of the target pixel includes:

[0133] Establish a mapping relationship between each target pixel corresponding to each vertex and its corresponding world space coordinates, and obtain the world space coordinate values ​​of the remaining target pixels according to the following calculation formula;

[0134] ;

[0135] ;

[0136] ;

[0137] in, Represents the target pixel. World coordinates on the x-axis, Represents the target pixel. World space coordinates on the y-axis. Represents the target pixel. World space coordinates on the z-axis, This represents the viewport coordinates of the bottom-left vertex on the x-axis. This represents the viewport coordinates of the bottom-right vertex on the x-axis. This represents the viewport coordinates of the bottom-right vertex on the y-axis. This represents the viewport coordinates of the topmost vertex on the y-axis. This represents the viewport space value of the target pixel on the x-axis. This represents the viewport space value of the target pixel on the y-axis. This represents the world space coordinates of the bottom-left vertex on the x-axis. This represents the world space coordinates of the bottom-left vertex on the y-axis. This represents the world space coordinates of the bottom-right vertex on the x-axis. This represents the world space coordinates of the bottom-right vertex on the y-axis. This represents the world space coordinates of the uppermost of the three vertices on the y-axis.

[0138] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

[0139] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

Claims

1. A method for generating dynamic mesh coordinates, characterized in that, include: Receive the view space coordinates of multiple vertices, and inversely transform the view space coordinates of each vertex into the corresponding world space coordinates; Primitives are generated using the viewport space coordinates of all the aforementioned vertices; The primitives are assembled and rasterized to determine the target pixels; The world space coordinates of the target pixel are obtained by interpolating the rasterized primitive based on the world space coordinates of the vertex. The scaling ratio of the world space coordinates of the vertex and the corresponding viewport space coordinates is determined according to the inverse transformation, and the scale is determined according to the scaling ratio. The pixel to be colored is determined based on the scale, the preset grid line width and the world space coordinates of each target pixel, and the pixel to be colored is then colored to obtain the grid. The step of inversely transforming the viewport space coordinates of each vertex into the corresponding world space coordinates includes: The inverse matrix obtained by multiplying the preset orthogonal projection matrix by the preset view matrix is ​​multiplied by the view space coordinates of each vertex to obtain the corresponding world space coordinates; Determining the scaling ratio of world space coordinates and viewport space coordinates based on the inverse transformation includes: The value in the 0th row and 0th column of the inverse matrix obtained by multiplying the preset orthogonal projection matrix and the preset view matrix is ​​used as the scaling ratio of the world space coordinates of the vertex and the corresponding view space coordinates. Determining the scale according to the scaling ratio includes: , in, Indicates the scale, Indicates the scaling ratio. Indicates to Rounding down, Indicates exponentiation; The step of determining the pixel to be colored based on the scale and the world space coordinates of each pixel includes: The target pixel that conforms to the coloring calculation formula is determined as the pixel to be colored. The coloring calculation formula is: , Among them, the Represents the pixel to be colored. Represents the target pixel. World space coordinates on the x-axis. Represents the target pixel. World space coordinates on the y-axis. Indicates the scale, Indicates the preset grid line width. Represents the target pixel. The value is the world space coordinates of the right target pixel on the x-axis minus the world space coordinates of the left target pixel on the x-axis. Represents the target pixel. The value is the difference between the world space coordinates of the upper target pixel on the y-axis and the world space coordinates of the lower target pixel on the y-axis. The symbol represents the modulo operator, and | represents the OR operator.

2. The dynamic mesh coordinate generation method according to claim 1, characterized in that, Receive the view space coordinates of the three vertices, and generate a primitive of triangular type using the view space coordinates of all the vertices.

3. The dynamic mesh coordinate generation method according to claim 2, characterized in that, The step of interpolating the rasterized primitives based on the world space coordinates of the vertices to obtain the world space coordinates of the target pixel includes: Establish a mapping relationship between each target pixel corresponding to each vertex and its corresponding world space coordinates, and obtain the world space coordinate values ​​of the remaining target pixels according to the following calculation formula; ; ; ; in, Represents the target pixel. World coordinates on the x-axis, Represents the target pixel. World space coordinates on the y-axis. Represents the target pixel. World space coordinates on the z-axis, This represents the viewport coordinates of the bottom-left vertex on the x-axis. This represents the viewport coordinates of the bottom-right vertex on the x-axis. This represents the viewport coordinates of the bottom-right vertex on the y-axis. This represents the viewport coordinates of the topmost vertex on the y-axis. This represents the viewport space value of the target pixel on the x-axis. This represents the viewport space value of the target pixel on the y-axis. This represents the world space coordinates of the bottom-left vertex on the x-axis. This represents the world space coordinates of the bottom-left vertex on the y-axis. This represents the world space coordinates of the bottom-right vertex on the x-axis. This represents the world space coordinates of the bottom-right vertex on the y-axis. This represents the world space coordinates of the uppermost of the three vertices on the y-axis.

4. A dynamic mesh coordinate generation system, characterized in that, include: The receiving transformation module is used to receive the view space coordinates of multiple vertices and inversely transform the view space coordinates of each vertex into the corresponding world space coordinates. The primitive generation module is used to generate primitives using the view space coordinates of all the vertices; The primitive processing module is used to assemble the primitives and rasterize them to determine the target pixels. The interpolation calculation module is used to perform interpolation calculations on the rasterized primitives based on the world space coordinates of the vertex to obtain the world space coordinates of the target pixel. The scale determination module is used to determine the scaling ratio of the world space coordinates of the vertex and the corresponding viewport space coordinates according to the inverse transformation, and to determine the scale according to the scaling ratio. The coloring determination module is used to determine the pixel to be colored based on the scale, the preset grid line width and the world space coordinates of each target pixel, and to color the pixel to be colored to obtain a grid. The dynamic mesh coordinate generation system is used to perform the steps of the method according to any one of claims 1 to 3.

5. A computer device, comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 3.

6. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 3.

Citation Information

Patent Citations

  • Method for picking up three-dimensional geometric primitive based on GPU

    CN103473814A

  • Adaptive snapping

    US20110043517A1