A three-dimensional model encoding method, device and terminal
By re-abstracting and encoding the obj format of the 3D model, the problems of large files and slow encoding and decoding of the obj format in mobile Internet transmission are solved, and a smaller and faster file format is realized, which is suitable for mobile Internet transmission and improves Improves rendering performance and loading speed on mobile devices.
Patent Information
- Application Number
- CN202110028342.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-01-11
- Publication Date
- 2024-10-15
- Estimated Expiration
- 2041-01-11
AI Technical Summary
The obj format 3D model files in the existing technology have problems such as large files and slow encoding and decoding during mobile Internet transmission, and cannot be suitable for mobile Internet transmission.
By re-abstracting the obj format of the 3D model, merging and storing the first coordinate data, a new code format is formed, and the texture data and coordinate data are re-encoded to form a smaller and faster file format suitable for mobile Internet transmission.
It achieves small files, fast encoding and decoding, reduces network transmission bandwidth requirements, improves the rendering performance of mobile devices, reduces the probability of errors, and supports separate storage and parallel asynchronous loading of texture images, improving the loading rate.
Smart Images

Figure CN112802134B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of 3D model information technology, and in particular, relates to a three-dimensional model encoding method, device and terminal. Background Art
[0002] 3D models are image models that are closer to reality and can carry more information, but at the same time, the amount of data in 3D models far exceeds that of videos and images. With the rapid development of 3D modeling tools and 3D scanning software, the accuracy and details of 3D models have been greatly improved, and the amount of data in 3D models has increased exponentially, which has led to a sharp increase in the scale and complexity of 3D models. On the other hand, with the development and popularization of digital technology and the Internet, the emergence of a large amount of 3D data and the greatly enhanced processing power of graphics processors, 3D TV broadcasts, 3D conversations on the mobile Internet, 3D games and 3D entertainment, etc., have begun to enter the public eye. However, the high data volume and high precision of 3D models will inevitably put forward very strict and even harsh requirements on image processing technology and storage and transmission technology. If we only rely on improving hardware equipment and network transmission equipment, we cannot effectively solve the problem. Therefore, in order to more effectively store 3D model data and reduce the demand for transmission bandwidth of 3D model data, it is very necessary to process 3D model data to reduce the amount of 3D model data.
[0003] In the current 3D model transmission technology, 3D model files are generally composed of obj, mtl and local texture images. This encoding format generally does not have too many problems in stand-alone mode. Once it is in Internet technology transmission, especially mobile Internet technology, this requires the file to occupy less storage space to adapt to the small bandwidth occupied during network transmission, and the encoding and decoding speed is required to be faster during rendering to adapt to the strict software and hardware characteristics of mobile devices. This makes the original obj format of the 3D model no longer applicable, and it is urgent to develop a new encoding and decoding method that is more suitable for the current mobile Internet technology.
[0004] A method is disclosed in the prior art, comprising: obtaining coordinate data in a three-dimensional model, the coordinate data comprising vertex coordinates and texture coordinates; converting the data types of the vertex coordinates and the texture coordinates respectively to obtain compressed three-dimensional model data; and sending the compressed three-dimensional model data to a terminal for rendering. The above method can effectively improve the compression efficiency of three-dimensional model data. However, the three-dimensional model data compressed by the method is slow to decode and has many files, which makes it unsuitable for mobile Internet transmission. Summary of the invention
[0005] 1. Technical problems to be solved
[0006] The 3D models in the obj format in the prior art have defects such as large files and slow encoding and decoding, which make them unsuitable for mobile Internet transmission. The present invention provides a coding method, system and terminal for a three-dimensional model, which re-abstracts the obj format of the 3D model, merges and stores the first coordinate data in the three-dimensional model data to obtain compressed second coordinate data, and forms a new code format. This new format has small files, fast encoding and decoding, and fewer files. In the process of network transmission, it not only greatly reduces the bandwidth, but also has faster encoding and decoding speeds and is more suitable for rendering on mobile devices.
[0007] 2. Technical solution
[0008] To solve the above problems, the present invention adopts the following technical solutions:
[0009] A method for encoding a three-dimensional model, the steps of which include:
[0010] (1) obtaining first texture data from the mtl file, and re-encoding the first texture data to form second texture data;
[0011] (2) Obtaining three-dimensional model data from the obj file, the three-dimensional model data including: first coordinate data, a plane coordinate index group, and a first texture identifier, the key character of the first texture identifier is usemtl, and the key character is configurable;
[0012] (3) traverse the first texture identifier key character usemtl in the obj file to obtain a number of texture units;
[0013] (4) using each texture unit as a processing unit to obtain preset parameters of the plane coordinate index group;
[0014] (5) The preset parameter is set as an index, each texture unit is traversed, corresponding coordinate data is selected from the first coordinate data, and the corresponding coordinate data is merged and stored to obtain the re-encoded second coordinate data.
[0015] The first texture data includes: a first texture identifier, a first texture image, and first illumination data; wherein the key character of the first texture identifier is generally newmtl, and the key character is configurable;
[0016] The step of re-encoding the first texture data in step 1 includes:
[0017] Convert the address of the first texture image into a URL of a corresponding network image;
[0018] re-encoding the first illumination data to generate second illumination data;
[0019] The first texture identification index is regenerated into a second texture identification index, and the second texture identification corresponds to the first texture identification one by one
[0020] The step of obtaining the preset parameters of the plane coordinate index group in step 4 includes:
[0021] Taking each texture unit as a processing unit, traversing the identification keyword f in the plane coordinate index, and obtaining the corresponding plane coordinate index group, wherein the plane coordinate index group includes a first vertex coordinate index group, a first normal vector coordinate index group, and a first texture identification index group;
[0022] The first vertex coordinate index group, the first normal vector coordinate index group and the first texture identifier index group correspond to the subscript values of vertex coordinate data, normal vector coordinate data and texture coordinate data respectively, and the corresponding coordinate data can be obtained through the index group.
[0023] The first coordinate data in steps 2 and 5 include first vertex coordinate data, first normal vector coordinate data and first texture coordinate data.
[0024] In step 5, the step of obtaining the second coordinate data includes:
[0025] 1. Select corresponding coordinate data from the first vertex coordinate data according to the first vertex coordinate index group, merge them, and re-encode them to form new vertex coordinate data, which is the second vertex coordinate data;
[0026] 2. Select corresponding coordinate data from the first normal vector coordinate data according to the first normal vector coordinate index group, merge them, and re-encode them to form new normal vector coordinate data, which is the second normal vector coordinate data;
[0027] 3. Select corresponding coordinate data from the first texture coordinate data according to the first texture coordinate index group, merge them, and re-encode them to form new texture coordinate data, which is the second texture coordinate data;
[0028] 4. The second vertex coordinate data, the second normal vector coordinate data, the second texture coordinate data and the second texture data are stored according to the second texture unit. If they are the same texture units, the coordinate data can be merged and stored.
[0029] 3. Beneficial effects
[0030] Compared with the prior art, the present invention has the following beneficial effects:
[0031] (1) The present invention provides a three-dimensional model encoding method, that is, re-encoding the vertex coordinates, normal vector coordinates, and texture coordinates of the original obj format 3D model information, and removing the redundant information therein, so that the re-encoded new format 3D model information occupies less storage space, solving the problem of large bandwidth occupation in Internet transmission; and this new format file is small, fast to encode and decode, and has fewer files, which not only greatly reduces the bandwidth in the network transmission process, but also has a faster encoding and decoding speed and is more suitable for rendering on mobile devices;
[0032] (2) The present invention provides a three-dimensional model encoding method, which uses texture as a processing unit to centrally reorganize and encode the coordinate data in the form of vertex coordinates, normal vector coordinates, and texture coordinates, so that the re-encoded 3D model information in a new format only needs to be recorded once and then decoded according to a certain storage format, and no longer needs to be recorded and decoded line by line like in the original obj format, which greatly improves the encoding and decoding speed of the 3D model;
[0033] (3) The present invention provides a coding method for a three-dimensional model, which uses a texture unit as the minimum processing unit for coding and decoding, searches for and re-encodes the texture index involved in the original obj file and the texture details of the mtl file, and finally forms a new format file, thereby greatly improving the decoding performance of the user end and reducing the probability of errors caused by multiple files during network transmission;
[0034] (4) The present invention provides a three-dimensional model encoding method. By storing and publishing local files on the Internet, the local file name in the original mtl is converted into the URL of the network image, so that the texture image of the 3D model can be loaded from the network, and the 3D model file and the texture image are stored separately. In this way, the texture image of the 3D model can be quickly loaded using existing network acceleration technologies such as CDN, and the 3D model file and the texture image can be loaded in parallel and asynchronously, which greatly improves the loading rate of the 3D model. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0036] Figure 1 A schematic diagram of a flow chart of a three-dimensional model encoding method provided by an embodiment of the present invention;
[0037] Figure 2 A schematic diagram of the structure of a three-dimensional model encoding device provided by an embodiment of the present invention;
[0038] Figure 3A schematic diagram of converting the file name of a local image in the obj format into a URL of a network image provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0039] The embodiments of the technical solution of the present invention will be described in detail below in conjunction with the accompanying drawings. The following embodiments are only used to more clearly illustrate the technical solution of the present invention, and are therefore only used as examples, and the protection scope of the present invention cannot be limited thereto. It should be noted that, unless otherwise specified, the technical terms or scientific terms used in this application should be the common meanings understood by those skilled in the art to which the present invention belongs.
[0040] In this application, the terms "first", "second", etc. are used for descriptive purposes only and are not to be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. In the description of the present invention, the meaning of "plurality" is more than two, unless otherwise clearly and specifically defined.
[0041] It should be understood that when used in this specification and the appended claims, the term "comprising" indicates the presence of described features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof.
[0042] It should also be understood that the terms used in this specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the specification of the present invention and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.
[0043] As used in this specification and the appended claims, the term "if" may be interpreted as "when" or "upon" or "in response to determining" or "in response to detecting," depending on the context.
[0044] In a specific implementation, the terminal described in the embodiments of the present invention includes, but is not limited to, other portable devices such as mobile phones, laptop computers, or tablet computers with touch-sensitive surfaces (e.g., touch screen displays and / or touch pads). It should also be understood that in some embodiments, the device is not a portable communication device, but a desktop computer with a touch-sensitive surface (e.g., touch screen displays and / or touch pads).
[0045] In the following discussion, a terminal including a display and a touch-sensitive surface is described. However, it should be understood that the terminal may include one or more other physical user interface devices such as a physical keyboard, mouse and / or joystick.
[0046] The terminal supports various applications, such as one or more of the following: a drawing application, a presentation application, a word processing application, a website creation application, a disk burning application, a spreadsheet application, a game application, a telephone application, a video conferencing application, an email application, an instant messaging application, a workout support application, a photo management application, a digital camera application, a digital camcorder application, a web browsing application, a digital music player application, and / or a digital video player application.
[0047] Various applications that can be executed on the terminal can use at least one common physical user interface device such as a touch-sensitive surface. One or more functions of the touch-sensitive surface and corresponding information displayed on the terminal can be adjusted and / or changed between applications and / or within corresponding applications. In this way, the common physical architecture of the terminal (e.g., the touch-sensitive surface) can support various applications with user interfaces that are intuitive and transparent to the user.
[0048] The basic concept of the present invention is as follows: by re-encoding the vertex coordinates, normal vector coordinates, and texture coordinates of the original obj format 3D model information, the redundant information thereof is removed, so that the re-encoded new format 3D model information occupies less storage space, thus solving the problem of occupying a large bandwidth in Internet transmission. The following is an explanation in conjunction with a specific embodiment.
[0049] Example 1
[0050] Here are some technical terms explained:
[0051] Three-dimensional model: It is composed of a set of polygonal patches in three-dimensional space, and each set of patches includes multiple interconnected polygons. A polygon refers to a closed figure composed of three or more line segments connected end to end. Preferably, the polygons in the three-dimensional model are triangles. The three-dimensional model can present real objects or fictional objects, including but not limited to three-dimensional maps, three-dimensional equipment, three-dimensional characters and three-dimensional games.
[0052] A vertex is the connection point of three or more faces in a polyhedron. In a three-dimensional model, the vertex of each polygon is the vertex of the three-dimensional model. The vertex coordinates are three-dimensional coordinates, such as (x, y, z).
[0053] Texture is a mapping of coordinates in space, which is actually an array whose elements are some color values. A single color value is called a texture element or texture pixel. Each texture pixel (texture element) has a unique address in the texture, which is the texture coordinate. The texture coordinate is generally: "vt uvw", for example: "vt 0.011 1.000 0.000"; the three values after vt represent the coordinate values of this vertex in the three-dimensional texture. If the texture is a two-dimensional image, the value w is invalid, and only the values u and v need to be used.
[0054] like Figure 1 As shown, this embodiment provides a method for encoding a three-dimensional model, and the method steps include the following:
[0055] S101: Acquire first texture data from the mtl file, and re-encode the first texture data to form second texture data;
[0056] The texture information in the old format is called the first texture data, and its texture properties are:
[0057] newmtl mtl_1
[0058] Ns 15,000
[0059] Ni 1.500
[0060] d 1.000
[0061] Tr 1.000
[0062] Tf 1.000 1.000 1.000
[0063] illum 2
[0064] Ka 0.850 0.850 0.850
[0065] Kd 0.850 0.850 0.850
[0066] Ks 0.850 0.850 0.850
[0067] Ke 0.000 0.000 0.000
[0068] map_Ka / maps / bmp_001.jpg
[0069] map_Kd / maps / bmp_002.jpg
[0070] For the above information, the first texture identifier: newmtl mtl_1; the first texture image: map_Ka / maps / bmp_001.jpg, map_Kd / maps / bmp_002.jpg; the first illumination data; Ka 0.850 0.850 0.850, Kd 0.8500.850 0.850, Ks 0.850 0.850 0.850, Ke 0.000 0.000 0.000, Ns 15.000, etc.;
[0071] The texture information in the new format is called second texture data, and its texture attributes are as follows:
[0072] newmtl2 msjj019_1
[0073] exponent:AKJhvw3Vl78b
[0074] ambient:PxmZmj8ZmZo / GZmaP4AAAA==
[0075] diffuse:PxmZmj8ZmZo / GZmaP4AAAA==
[0076] speculer:Pwl41T8JeNU / CXjVP4AAAA==
[0077] Shininess:QgAAA==
[0078] bmp1:http: / / www.xxx.com / maps / bmp_001.jpg
[0079] bmp2:http: / / www.xxx.com / maps / bmp_001.jpg
[0080] exponent is the recoding of d, Tr, Tf, etc.
[0081] ambient is a re-encoding of Ka
[0082] diffuse is a recoding of Kd
[0083] speculer is a re-encoding of Ks
[0084] Shininess is a recoding of Ns etc.
[0085] Second texture identifier: newmtl2 msjj019_1; second texture image: bmp1: http: / / www.xxx.com / maps / b mp_001.jpg, bmp2: http: / / www.xxx.com / maps / bmp_001.jpg; second illumination data: exponent: AKJhvw 3Vl78b, ambient: PxmZmj, etc.;
[0086] S102: Obtaining three-dimensional model data of an obj format file, the three-dimensional model data including: first coordinate data, a plane coordinate index group, and a first texture identification key character usemtl;
[0087] The first coordinate data includes first vertex coordinates, first normal vector coordinates and first texture coordinates.
[0088] Specifically, read and decode the 3D model obj format file:
[0089] First of all, it should be noted that the obj format file includes obj files, mtl files, and local pictures; the obj format file is read and decoded, and the encoded attributes include: the first texture identification index, the first vertex coordinates, the first normal vector coordinates, the first texture coordinates, texture attributes and local pictures; the obj file includes: the first texture identification index, the first vertex coordinates, the first normal vector coordinates, the first texture coordinates; the mtl file includes texture attributes.
[0090] The specific process is:
[0091] (1) Read the obj file line by line. When the string at the beginning of the line is found to be the first texture identification keyword, that is, the keyword is the string usemtl, it is considered that a new texture unit begins. There will be one or more spaces after the first texture identification keyword usemtl. After skipping the spaces, there will be a string of characters, which is the first texture identification index. For example, the first texture identification index is generally "usemtl mtl_1". According to this first texture identification index, the corresponding texture attribute and the file name of the corresponding local image can be queried in the mtl file:
[0092] newmtl mtl_1
[0093] Ns 15,000
[0094] Ni 1.500
[0095] d 1.000
[0096] Tr 1.000
[0097] Tf 1.000 1.000 1.000
[0098] illum 2
[0099] Ka 0.850 0.850 0.850
[0100] Kd 0.850 0.850 0.850
[0101] Ks 0.850 0.850 0.850
[0102] Ke 0.000 0.000 0.000
[0103] map_Ka maps\bmp_001.jpg
[0104] map_Kd maps\bmp_001.jpg
[0105] (2) Continue traversing the next line. If the first character string is v, this is the first vertex coordinate identification keyword. This keyword is followed by the three-dimensional coordinates of a vertex, separated by three spaces. The format of this vertex is generally: "vx yz", for example:
[0106] v-507.493 70.386 857.811
[0107] v-462.717 70.386 813.035
[0108] v-462.717 660.527 813.035
[0109] v-462.717 660.527 813.035
[0110] The three values x, y, and z after v represent the coordinates of this vertex on the X-axis, Y-axis, and Z-axis respectively, which are the actual coordinate positions of the vertex in space. Let v_s be the first vertex coordinate group, that is, store the vertex coordinate values of each row in the first vertex coordinate group v_s in ascending order of subscripts, so that the corresponding vertex coordinates can be queried by subscript value;
[0111] (3) Continue traversing the next line. If the first string is found to be vn, this is the first normal vector coordinate identification keyword. This keyword is followed by the three-dimensional coordinates of a normal vector, separated by three spaces. The format of this normal vector is generally: "vn xyz", for example:
[0112] vn 0.707 -0.000 0.707
[0113] vn -0.000 0.000 -1.000
[0114] vn -1.000 -0.000 0.000
[0115] vn -0.159 -0.974 -0.159
[0116] The three values x, y, and z after vn represent the normal vector coordinate values of this vertex on the X-axis, Y-axis, and Z-axis respectively. Let vn_s be the first normal vector coordinate group, that is, the normal coordinate values of each row are stored in the first normal vector coordinate group vn_s in ascending order of subscripts, so that the corresponding normal vector coordinates can be queried according to the subscript values;
[0117] (4) Continue traversing the next line. If the first string is found to be vt, this is the first texture coordinate identification keyword. This keyword is followed by a texture's three-dimensional coordinates, which are separated by three spaces. The texture format is generally: "vtu vw", for example:
[0118] vt 0.260 0.000 0.500
[0119] vt 0.500 0.000 0.740
[0120] vt 0.500 1.126 0.740
[0121] vt 0.260 1.126 0.500
[0122] The three values after vt represent the coordinate values of the vertex in the three-dimensional texture. If the texture is a two-dimensional image, the value w is invalid, and only the values u and v are needed. Assuming vt_s is the first texture coordinate group, the texture coordinate values of each row are stored in the first texture coordinate group vt_s in ascending order of subscripts, so that the corresponding texture coordinates can be queried by subscript value;
[0123] (5) Continue to traverse the next line. If the first character string is found to be f, this is the plane coordinate index identification keyword. This keyword is followed by the first vertex coordinate index, the first texture coordinate index, and the first normal vector coordinate index corresponding to the vertex coordinates of the plane, which are separated by three spaces. The plane coordinate index format is generally: "f 16 / 50 / 1715 / 49 / 17 14 / 48 / 17". Assume that its format is "fv / vt / vn", where v represents the first vertex coordinate index, that is, the index in the v_s first vertex coordinate group; vt represents the first texture coordinate index, that is, the index in the vt_s first texture coordinate group; vn represents the first normal vector coordinate index, that is, the index in the vn_s first normal vector coordinate group;
[0124] (6) Until a new texture identifier key string usemtl is traversed or the obj file traversal ends, the previous texture unit ends; finally, the first vertex coordinate group starting with the first string v, the first normal vector coordinate group starting with the first string vn, the first texture coordinate group starting with the first string vt, and the first vertex coordinate index group starting with the first string f are formed; here, the first vertex coordinate group is set to v_s, the first normal vector coordinate group is set to vn_s, the first texture coordinate group is set to vt_s, and the plane coordinate index group is set to f_s; those skilled in the art should understand that the above is the process of reading and encoding an existing obj file.
[0125] S104: traverse the first texture identifier key character usemtl to obtain a plurality of texture units;
[0126] Specifically, according to step S102, the obj file of the three-dimensional model is obtained, and the identifiers in all the first texture identification index information in the obj format are traversed, where the identifier is the identification key string usemtl, so as to obtain a plurality of texture units.
[0127] S106: using each texture unit as a processing unit to obtain preset parameters of the plane coordinate index group;
[0128] Specifically, the step of obtaining the preset parameters of the plane coordinate index group includes: taking each texture unit as a processing unit, traversing the identification keyword f in the plane coordinate index, and obtaining the corresponding plane coordinate index group, wherein the plane coordinate index group includes a first vertex coordinate index group, a first normal vector coordinate index group and a first texture identification index group; obtaining corresponding subscript values according to the first vertex coordinate index group, the first normal vector coordinate index group and the first texture identification index group.
[0129] Further, the plane coordinate index group includes three or four first vertex coordinate index groups, i.e., the first vertex coordinate index groups obtained in step S102. It should be noted that these first vertex coordinate index groups constitute a polygon rendering unit for rendering the 3D model. Each vertex coordinate index group includes three integers, and the three integers are corresponding subscript values (preset parameters).
[0130] S108: traverse each texture unit, set the preset parameter as an index, respectively obtain corresponding coordinates from the first coordinate data, merge and re-encode, and obtain second coordinate data;
[0131] The steps are:
[0132] (1) obtaining a second vertex coordinate group, a second normal vector coordinate group, and a second texture coordinate group in sequence according to the first vertex coordinates, the first normal vector coordinates, and the first texture coordinates;
[0133] (2) using each texture unit as a processing unit, and adding corresponding coordinate identification keywords before the second vertex coordinate group, the second normal vector coordinate group, and the second texture coordinate group;
[0134] (3) The coordinate identification keyword is combined with the second vertex coordinate group, the second normal vector coordinate group and the second texture coordinate, and then re-encoded to obtain second coordinate data.
[0135] The specific steps are as follows:
[0136] First, assuming that the new first vertex coordinate index group is v_s_index, the obj format of the 3D model is improved as follows:
[0137] Ⅰ. For the first vertex coordinate, the first vertex coordinate in each texture unit usemtl is merged and stored. That is, three integers are obtained from the first vertex coordinate index group v_s_index, and the three integers are used as indexes to obtain three corresponding vertex coordinates from the first vertex coordinate group v_s respectively. Each vertex coordinate is three-dimensional. After traversing this texture unit, the new vertex coordinate group obtained by re-encoding the obtained vertex coordinate group is the second vertex coordinate group. Assuming that the second vertex coordinate group is v_s_new, a vertex coordinate identification keyword is added to the front of the vertex coordinate group. This vertex coordinate identification keyword only needs to be unique in the keyword of the current texture unit usemtl. Assuming that the second vertex coordinate identification keyword is v_new; that is, the storage format of the merged vertices in the texture unit usemtl is composed of the vertex coordinate identification keyword (v_new), the separator and the second vertex coordinate group (v_s_new). The separator is composed of special characters, such as spaces. Therefore, the vertex format of the new format is generally expressed as: "v_new v_s_new", for example: "v_new wtA0vECsm6a+rpeNQr / LREC3Z...".
[0138] Ⅱ. For the first vertex coordinate, the first normal coordinates in each texture unit usemtl are merged and stored, that is, three integers are obtained from the first normal coordinate index group vn_s_index, and three corresponding normal coordinates can be obtained from the first normal coordinate group vn_s respectively according to these three integers as indexes. Each normal coordinate is three-dimensional; after traversing this texture unit, the normal coordinate group obtained is re-encoded to obtain a new normal coordinate group, that is, a new normal coordinate group is obtained, which is the second normal coordinate group. Assuming that this new normal coordinate group is vn_s_new, a normal coordinate identification keyword is added before the second normal coordinate group. This normal coordinate identification keyword only needs to be unique in the keyword of the current texture unit usemtl. Assuming that the second normal coordinate identification keyword is vn_new; that is, the storage format of the merged normal vector in the texture unit usemtl is composed of: normal coordinate identification keyword (vn_new), separator and vertex coordinate group (vn_s_new). The separator is composed of special characters, such as spaces. Therefore, the vertex format of the new format is generally: "vn_new separator vn_s_new", for example: "vn_newvxRDXz8Umnq / EoeyPtB / fT...".
[0139] Ⅲ. For the first texture coordinate, the first texture coordinate in each texture unit usemtl is merged and stored, that is, three integers are obtained from the first texture coordinate index group vt_s_index, and three corresponding texture coordinates can be obtained from the vertex coordinate group vt_s respectively according to the three integers as indexes, and each texture coordinate is two-dimensional or three-dimensional; after traversing this texture unit, the new texture coordinate group obtained after re-encoding the obtained texture coordinate group is obtained, that is, a new texture coordinate group is obtained, which is the second texture coordinate group. Assuming that the second texture coordinate group is vt_s_new, a texture coordinate identification keyword is added before this texture coordinate group. This texture coordinate identification keyword only needs to be guaranteed to be unique in the keyword of the current texture unit usemtl. Assuming that this texture coordinate identification keyword is vt_new; that is, the storage format of the merged texture in the texture unit usemtl is composed of: texture coordinate identification keyword (vt_new), separator and texture coordinate group (vt_s_new). Among them, the separator is composed of special characters, such as space. The vertex format of this new format is generally: "vt_new separator vt_s_new", for example: "vt_new AAAAADw0OUA / gAAAPDQ...".
[0140] Optionally, the address of the local image in the texture attribute corresponding to the first texture identification index information is converted into the URL of the corresponding network image to generate a second texture identification index; each texture unit is used as a processing unit to construct a second texture identification keyword before the second texture identification index.
[0141] The second coordinate data includes second vertex coordinate information, second normal coordinate information, and second texture coordinate information.
[0142] Furthermore, the second texture identification information is composed of the texture key string usemtl and the texture identification index; the second vertex coordinate information is composed of the vertex coordinate identification keyword v_new and the vertex coordinate group v_s_new; the second normal coordinate information is composed of the normal vector coordinate identification keyword vn_new and the normal vector coordinate group vn_s_new; the second texture coordinate information is composed of the texture coordinate identification keyword vt_new and the texture coordinate group vt_s_new.
[0143] The details are as follows:
[0144] usemtl msjj019_1
[0145] v_new:-507.493 70.386 857.811 -462.717 70.386 813.035 -462.717660.527 813.035......
[0146] vn_new:0.707 -0.000 0.707 -0.000 0.000 -1.000 -1.000 -0.0000.000......
[0147] vt_new:0.260 0.000 0.500 0.500 0.000 0.740 0.500 1.126 0.740......
[0148] The processing units of this new format correspond one-to-one to the processing units of the original format, wherein v_new, vn_new, and vt_new are encoded and decoded based on three vertices (9 coordinate values) as a platform.
[0149] like Figure 3As shown, the file name of the local image in the obj format is converted into the URL of the network image, the vertex coordinates, normal vector coordinates, and texture coordinates of the original obj format 3D model information are re-encoded, and the redundant information is removed, so that the re-encoded new format of 3D model information occupies less storage space, solving the problem of large bandwidth occupation in Internet transmission; and this new format has small files, fast encoding and decoding, and fewer files. In the process of network transmission, it not only greatly reduces the bandwidth, but also has faster encoding and decoding speeds and is more suitable for mobile device rendering.
[0150] Example 2
[0151] This embodiment provides a terminal, including a processor, an input device, an output device and a memory, wherein the processor, input device, output device and memory are connected in sequence, the memory is used to store a computer program, the computer program includes program instructions, and the processor is configured to call the program instructions to execute the method described in Example 1.
[0152] Example 3
[0153] This embodiment provides a computer-readable storage medium, which stores a computer program. The computer program includes program instructions. When the program instructions are executed by a processor, the processor executes the method described in Embodiment 1.
[0154] Specifically, the computer-readable storage medium may be an internal storage unit of the terminal described in the foregoing embodiment, such as a hard disk or memory of the terminal. The computer-readable storage medium may also be an external storage device of the terminal, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the terminal. Further, the computer-readable storage medium may also include both an internal storage unit of the terminal and an external storage device. The computer-readable storage medium is used to store the computer program and other programs and data required by the terminal. The computer-readable storage medium may also be used to temporarily store data that has been output or is to be output.
[0155] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0156] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the terminals and units described above can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here.
[0157] In the several embodiments provided in the present application, it should be understood that the disclosed terminal and method can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, or it can be an electrical, mechanical or other form of connection.
[0158] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the embodiments of the present invention.
[0159] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0160] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0161] Example 4
[0162] As attached Figure 2 As shown, this embodiment provides a three-dimensional model encoding system, including:
[0163] The three-dimensional model data acquisition module 10 is used to parse and acquire the three-dimensional model data, wherein the three-dimensional model data includes: first coordinate data, a plane coordinate index group, and a first texture identification key character usemtl;
[0164] The texture unit processing module 20 is used to traverse the key string usemtl in the first texture identification index information to obtain a plurality of texture units;
[0165] The parameter generation module 30 uses each texture unit as a processing unit to obtain preset parameters of the plane coordinate index group;
[0166] The encoding module 40 sets the preset parameter as an index, traverses each texture unit, selects corresponding coordinate data from the first coordinate data, merges and stores them, and obtains re-encoded second coordinate data.
[0167] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein by equivalents. These modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present invention, and they should all be included in the scope of the claims and specification of the present invention.
Claims
1. A method for encoding a three-dimensional model, the steps of which are include: (1) Obtaining first texture data from the mtl file, and re-encoding the first texture data to form second texture data; (2) Obtaining three-dimensional model data from the obj file, the three-dimensional model data including: first coordinate data, a plane coordinate index group, and a first texture identifier, wherein the key character of the first texture identifier is usemtl; (3) Traverse the first texture identifier key character usemtl in the obj file to obtain a number of texture units; (4) using each texture unit as a processing unit to obtain preset parameters of the plane coordinate index group; (5) setting the preset parameter as an index, traversing each texture unit, selecting corresponding coordinate data from the first coordinate data, merging and storing them, and obtaining re-encoded second coordinate data; The step of obtaining the second coordinate data in step (5) includes: 1) selecting corresponding coordinate data from the first vertex coordinate data according to the first vertex coordinate index group, merging and re-encoding the corresponding coordinate data to form new vertex coordinate data, which is the second vertex coordinate data; 2) selecting corresponding coordinate data from the first normal vector coordinate data according to the first normal vector coordinate index group, merging and re-encoding the corresponding coordinate data to form new normal vector coordinate data, which is the second normal vector coordinate data; 3) selecting corresponding coordinate data from the first texture coordinate data according to the first texture coordinate index group, merging and re-encoding the corresponding coordinate data to form new texture coordinate data, which is the second texture coordinate data; 4) The second vertex coordinate data, the second normal vector coordinate data, the second texture coordinate data and the second texture data are stored according to the second texture unit. If they are the same texture units, the coordinate data are selected to be merged and stored.
2. The method for encoding a three-dimensional model according to claim 1, It is characterized in that The step of obtaining the preset parameters of the plane coordinate index group in step (4) includes: Taking each texture unit as a processing unit, traversing the identification keyword f in the plane coordinate index, and obtaining the corresponding plane coordinate index group, wherein the plane coordinate index group includes a first vertex coordinate index group, a first normal vector coordinate index group, and a first texture identification index group; The first vertex coordinate index group, the first normal vector coordinate index group and the first texture identifier index group correspond to the subscript values of vertex coordinate data, normal vector coordinate data and texture coordinate data respectively, and the corresponding coordinate data can be obtained through the index group.
3. The method for encoding a three-dimensional model according to claim 1, It is characterized in that The first coordinate data in steps (2) and (5) include first vertex coordinates, first normal vector coordinates and first texture coordinates.
4. The method for encoding a three-dimensional model according to claim 1, It is characterized in that The step of re-encoding the first texture data in step (1) includes: Convert the address of the first texture image into the URL of the corresponding network image; re-encoding the first illumination data to generate second illumination data; The first texture identifier index is regenerated into a second texture identifier index, and the second texture identifier corresponds to the first texture identifier in a one-to-one manner.
5. A coding system for a three-dimensional model, It is characterized in that include: A three-dimensional model data acquisition module, used to parse and acquire three-dimensional model data, wherein the three-dimensional model data includes: first coordinate data, a plane coordinate index group, and a first texture identification key character usemtl; A texture unit processing module, used for traversing the first texture identification key character usemtl to obtain a plurality of texture units; A parameter generation module, taking each texture unit as a processing unit, and obtaining preset parameters of the plane coordinate index group; The encoding module sets the preset parameter as an index, traverses each texture unit, selects corresponding coordinate data from the first coordinate data, merges and stores them, and obtains re-encoded second coordinate data; The steps of obtaining the second coordinate data include: 1) selecting corresponding coordinate data from the first vertex coordinate data according to the first vertex coordinate index group, merging and re-encoding the corresponding coordinate data to form new vertex coordinate data, which is the second vertex coordinate data; 2) selecting corresponding coordinate data from the first normal vector coordinate data according to the first normal vector coordinate index group, merging and re-encoding the data to form new normal vector coordinate data, which is the second normal vector coordinate data; 3) selecting corresponding coordinate data from the first texture coordinate data according to the first texture coordinate index group, merging and re-encoding the corresponding coordinate data to form new texture coordinate data, which is the second texture coordinate data; 4) The second vertex coordinate data, the second normal vector coordinate data, the second texture coordinate data and the second texture data are stored according to the second texture unit. If they are the same texture units, the coordinate data are selected to be merged and stored.
6. A readable storage medium, It is characterized in that The storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a processor, the processor executes the method according to any one of claims 1 to 4.
7. A terminal, It is characterized in that The method comprises a processor, an input device, an output device and a memory, wherein the processor, the input device, the output device and the memory are connected in sequence, the memory is used to store a computer program, the computer program comprises program instructions, and the processor is configured to call the program instructions to execute the method according to any one of claims 1 to 4.
Citation Information
Patent Citations
Characteristic reservation based three-dimensional model progressive transmission method
CN101119485A
FlashVR-based three-dimensional mini-scene network publishing engine
CN101923462A
Method for rendering global illumination in computer three-dimensional model
CN104361624A
Large-scale three-dimensional model rendering method, device, system and storage medium
CN109377554A
Geographical coordinate compression coding and decoding method based on three-dimensional space partition
CN109544650A
