1. Technical Field
Embodiments of the present disclosure generally relate to image processing systems and methods, and more particularly to a system and method for displaying a three-dimensional object on a display screen.
2. Description of Related Art
Computer aided design (CAD) can be used to design three-dimensional (3D) objects. The 3D objects are being expressed using mathematics formulas or free-form surfaces, such as B-spline curve, in CAD. In order to display a 3D object through a display screen of an electronic device, such as a computer, an image of the 3D object needs to be drawn. It may be understood that, an ordinary display screen can only display two-dimensional (2D) images, thus, it is necessary to convert 3D images to 2D images. Accordingly, how to convert 3D images to 2D images quickly and accurately is necessary.
The disclosure is illustrated by way of examples and not by way of limitation in the figures of the accompanying drawings in which like references indicate similar elements. It should be noted that references to “an” or “one” embodiment in this disclosure are not necessarily to the same embodiment, and such references mean at least one.
In general, the word “module,” as used hereinafter, refers to logic embodied in hardware or firmware, or to a collection of software instructions, written in a programming language, such as, for example, Java, C, or assembly. One or more software instructions in the modules may be embedded in firmware. It will be appreciated that modules may comprised connected logic units, such as gates and flip-flops, and may comprise programmable units, such as programmable gate arrays or processors. The modules described herein may be implemented as either software and/or hardware modules and may be stored in any type of computer-readable medium or other computer storage device.
The creation module 100 creates a pixel value matrix and a projection depth matrix, and stores the created pixel value matrix and the created projection depth matrix into the storage system 12.
The pixel value matrix is a matrix of pixel values of an image displayed on the display screen 13. The pixel value matrix is used to record a pixel value of each of the pixels of an image displayed on the display screen 13. In one embodiment, each element in the created pixel value matrix is a pixel value of the background color of the display screen, such as the blue. A column and a row of the created pixel value matrix is determined according to a resolution of the display screen 13. For example, if the resolution of the display screen 13 is 1024*768, the column of the created pixel value matrix may be 1024, and the row of the created pixel value matrix may be 768.
The projection depth matrix is a matrix of projection depths of pixels of an image displayed on the display screen 13. The projection depth matrix is used to record a projection depth of each of the pixels of an image displayed on the display screen 13. It may be understood that, the projection depth of a pixel stands for a distance between the pixel and the display screen 13 when the pixel is played on the display screen 13. In one embodiment, each element in the created projection depth matrix is 1. As with the pixel value matrix, a column and a row of the created projection depth matrix is determined according to a resolution of the display screen 13. For example, if the resolution of the display screen 13 is 1024*768, the column of the created projection depth matrix may be 1024, and the row of the created projection depth matrix may be 768.
The coordinate reading module 101 reads three-dimensional coordinates of points of the three-dimensional object according to the B-spline curve stored in the storage system 12.
The triangle constructing module 102 creates a triangle mesh model by constructing triangles using the three-dimensional coordinates, as follows, referring to
The selection module 103 selects a three-dimensional triangle from the triangle mesh model, and obtains three-dimensional coordinates of vertexes of the selected three-dimensional triangle. The selection of a three-dimensional triangle from the triangle mesh model is repeated until all the three-dimensional triangles of the triangle mesh model have been selected.
The coordinate conversion module 104 converts the three-dimensional coordinates of the vertexes to two-dimensional coordinates by projecting the selected three-dimensional triangle onto the display screen 13, and generates a two-dimensional figure according to the two-dimensional coordinates. It may be understood that, the two-dimensional figure may be a triangle or a line. It may be further understood that, a point located by each two-dimensional coordinate on the display screen 13 corresponds to a pixel of the display screen 13.
The projection depth comparison module 105 computes a projection depth of the selected three-dimensional triangle by projecting a center of the selected three-dimensional triangle onto the display screen 13 to generate a projected center and obtaining a z-axis coordinate of the projected center. The z-axis coordinate of the projected center is the projection depth of the selected three-dimensional triangle. Referring to
The color adding module 106 compares the computed projection depth with a projection depth of a pixel, which corresponds to the projected center, of the display screen 13 recorded in the created projection depth matrix, and adds the color of the selected three-dimensional triangle to the two-dimensional
The updating module 107 updates the created pixel value matrix according to the color added to the two-dimensional figure to generate an updated pixel value matrix, and updates the created projection depth matrix according to the computed projection depth to generate an updated projection depth matrix.
The outputting module 108 outputs a two-dimensional image of the three-dimensional object, which is formed according to the elements of the updated pixel value matrix and the updated projection depth matrix, onto the display screen 13.
In block S400, the creation module 100 creates a pixel value matrix and a projection depth matrix, and stores the created pixel value matrix and the created projection depth matrix into the storage system 12. In one embodiment, each element in the created pixel value matrix is a pixel value of the background color of the display screen 13, such as blue. A column and a row of the created pixel value matrix is determined according to a resolution of the display screen 13. In one embodiment, each element in the created projection depth matrix is 1. A column and a row of the created projection depth matrix is determined according to the resolution of the display screen 13.
In block S401, the coordinate reading module 101 reads three-dimensional coordinates of points of the three-dimensional object according to the B-spline curve stored in the storage system 12.
In block S402, the triangle constructing module 102 creating a triangle mesh model by constructing triangles using the three-dimensional coordinates. A triangular mesh model is a type of polygon mesh in computer graphics. A triangular mesh model comprises a set of triangles (typically in three dimensions) that are connected by points located by the three-dimensional coordinates.
In block S403, the selection module 103 selects a three-dimensional triangle from the triangle mesh model, and obtains three-dimensional coordinates of vertexes of the selected three-dimensional triangle.
In block S404, the coordinate conversion module 104 converts the three-dimensional coordinates of the vertexes to two-dimensional coordinates, and generates a two-dimensional figure according to the two-dimensional coordinates. In one embodiment, the conversion is implemented by projecting the selected three-dimensional triangle onto the display screen 13. It may be understood that, the two-dimensional figure may be a triangle or a line, and a point located by each two-dimensional coordinate on the display screen 13 corresponding to a pixel of the display screen 13.
In block S405, the projection depth comparison module 105 computes a projection depth of the selected three-dimensional triangle. The projection depth of the selected three-dimensional triangle is computed by projecting a center of the selected three-dimensional triangle onto the display screen 13 to generate a projected center, and obtaining a z-axis coordinate of the projected center. The z-axis coordinate of the projected center is the projection depth of the selected three-dimensional triangle.
In block S406, the color adding module 106 determines whether the computed projection depth is less than a projection depth of a pixel, which corresponds to the projected center, of the display screen 13 recorded in the created projection depth matrix. Block S407 is implemented if the computed projection depth is less than the projection depth recorded in the created projection depth matrix. Otherwise, block S409 is implemented if the computed projection depth is equal to or greater than the projection depth recorded in the created projection depth matrix.
In block S407, the color adding module 106 adds the color of the selected three-dimensional triangle to the two-dimensional figure.
In block S408, the updating module 107 updates the created pixel value matrix according to the color added to the two-dimensional figure to generate an updated pixel value matrix, and updates the created projection depth matrix according to the computed projection depth to generate an updated projection depth matrix.
In block S409, the selection module 103 determines whether all the three-dimensional triangles of the triangle mesh model have been selected. Block S403 is repeated if at least one three-dimensional triangle of the triangle mesh model has not been selected. Otherwise, block S410 is implemented if all the three-dimensional triangles of the triangle mesh model have been selected.
In block S410, the outputting module 108 outputs a two-dimensional image of the three-dimensional object, which is formed according to the elements of the updated pixel value matrix and the updated projection depth matrix, onto the display screen 13.
Although certain inventive embodiments of the present disclosure have been specifically described, the present disclosure is not to be construed as being limited thereto. Various changes or modifications may be made to the present disclosure without departing from the scope and spirit of the present disclosure.
Number | Date | Country | Kind |
---|---|---|---|
200910312165.1 | Dec 2009 | CN | national |