Vertex number-based OBJ file quantization method
Patent Information
- Application Number
- CN202610897288.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-22
- Publication Date
- 2026-09-11
AI Technical Summary
[0004](1)不能增大模型的文件大小,只能缩小模型,即只有三维模型轻量化功能,没有增量化功能;
[0012] Compared with the prior art, the present invention has the following significant advantages: 1. It can enlarge or reduce the original model as needed; 2. It can quantize the scaling ratio and specify the number of bytes to increase or decrease; 3. It can perform lightweighting or blurring processing on specified local areas.
Smart Images

Figure CN122737366A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the technical field of quantitatively adding or subtracting from OBJ format three-dimensional digital models, specifically, a method for quantizing OBJ files based on the number of vertices. Background Technology
[0002] OBJ is a common 3D digital model format that can be converted to and from FBX and STL formats to suit different scenarios. In practical applications of 3D digital models, it's often necessary to lightweight the model to improve loading and running speed; on the other hand, sometimes to enhance rendering effects, it's necessary to add data to the model, requiring incremental processing.
[0003] However, current software and methods generally suffer from the following shortcomings:
[0004] (1) The file size of the model cannot be increased, but can only be reduced. That is, it only has the function of lightweighting the 3D model and does not have the function of incremental scaling.
[0005] (2) It lacks the function of quantifying the specific number of bytes, that is, it cannot clearly increase or decrease the number of bytes;
[0006] (3) It cannot perform quantization on a specified local area, and cannot achieve the goal of not reducing details in areas of interest and focusing on lightweighting in areas of no interest. Summary of the Invention
[0007] The purpose of this invention is to provide a method for quantizing OBJ files based on the number of vertices.
[0008] The technical solution to achieve the purpose of this invention is: a method for quantizing OBJ files based on the number of vertices, comprising:
[0009] First, select the quantization mode for the OBJ format 3D digital model. If you want to perform lightweight quantization, proceed to the second step. If you want to perform incremental quantization, proceed to the third step.
[0010] The second step is to lighten the model; the 3D digital model in OBJ format is lightened so that the size of the processed model file (i.e., the number of bytes) is smaller than the original model file size.
[0011] The third step is to incrementally process the OBJ format 3D digital model so that the size of the processed model file (i.e., the number of bytes) is greater than the original model file size.
[0012] Compared with the prior art, the present invention has the following significant advantages: 1. It can enlarge or reduce the original model as needed; 2. It can quantize the scaling ratio and specify the number of bytes to increase or decrease; 3. It can perform lightweighting or blurring processing on specified local areas. Attached Figure Description
[0013] Figure 1 This is a flowchart of the OBJ file quantization method based on vertex count according to the present invention.
[0014] Figure 2 This is a 3D model of a certain type of foot brake valve.
[0015] Figure 3 This is partial data for a certain type of foot brake valve foot pedal component. Detailed Implementation
[0016] The present invention will be further described below with reference to the accompanying drawings and embodiments.
[0017] A 3D model quantization case study using a certain type of foot brake valve as an example.
[0018] Assume a 3D model of a certain type of foot brake valve in OBJ format is as follows: Figure 2 As shown.
[0019] Figure 2 The foot brake valve model consists of parts such as a foot pedal, valve, spring, nut, and push rod. Each part includes vertex coordinates and normal coordinates, and they are respectively marked with the letters v and vn. Some data for the foot pedal are as follows: Figure 3 As shown.
[0020] In a three-dimensional digital model, any model is composed of triangular faces made up of multiple small triangles combined through a mesh structure. Figure 3 In (a), the coordinates of each vertex of the foot pedal triangle are represented by rows of data starting with v, with spaces separating v and the coordinates of each vertex, which are used to represent the spatial coordinates of x, y, and z, respectively. Figure 3 In (b), the data starting with vn represents the spatial coordinates of the x, y, and z of the normal vector corresponding to the vertex. The coordinates are also separated by spaces and are used for lighting calculations and texture mapping.
[0021] (I) Lightweight OBJ file method based on vertex count
[0022] The core idea of the vertex-count-based lightweight OBJ file method is to reduce the number of vertices and achieve lightweighting by removing vertex data that has little impact on the model. Its main steps include:
[0023] 1. Calculate the distance between each vertex.
[0024] Obtain the group data of the foot pedal in the foot brake valve, i.e. Figure 3 (a) From the second row "o foot pedal" to the next group "o", filter out the rows starting with "v", obtain the x, y, and z coordinates of each row, and calculate the distance between each point. For example, rows 3-5:
[0025] v -3.060961 3.129783 -1.293411
[0026] v -3.089890 3.174395 -1.287951
[0027] v -3.118819 3.219007 -1.282491
[0028] The corresponding spatial coordinates are respectively , , .
[0029] Then, the distance between each of these three points is calculated using the spatial coordinate distance calculation formula, thus obtaining three distance values.
[0030] 2. Calculate the difference between the maximum and minimum distances at each vertex.
[0031] After calculating the distances between each vertex in step 1, find the maximum and minimum distances, and calculate the difference between them, let it be . .
[0032] 3. Divide the vertex space coordinate range according to the lightweight ratio.
[0033] Assuming the lightweight ratio is The vertex space lightweight weight is Then the lightweight ratio of the vertex space is The distance range to be lightweighted is For example, if the original file is 100MB and the file size is reduced to 90MB after weight reduction, the weight reduction ratio is 10%. If the weight reduction of the vertex space is 50%, it means that the vertex data needs to be weighted by 10% * 50% = 5%. If the difference between the maximum and minimum distances of each vertex is 100, then vertices with a distance of less than 5 need further processing.
[0034] 4. Lightweighting vertex space data using edge folding method
[0035] For distances less than Two vertices , Connect these two vertices to form a line segment. Clustering is used to find the points on the line segment. , and then with Points are used as vertex data in the OBJ file, and then deleted. and The goal is to reduce the number of vertices by finding a point on the line segment and then deleting one of those points. Clustering is used to find the points on the line segment. The main steps are:
[0036] (1) Solving for the normal plane of the line segment
[0037] Suppose two points in space are respectively and Forming line segment AB, the corresponding vector is There is a point on it Find the normal plane R passing through point P.
[0038] (2) Statistical analysis of vertex distribution
[0039] Count the number of spatial vertices on both sides of the normal plane R passing through point P, and adjust the position of the intersection point of the normal plane and the line segment according to the number, and repeat step (1) until the ratio of the number of vertices on both sides of the plane is within a certain range.
[0040] 5. Calculate the angle between each normal vector.
[0041] Obtain the group data of the foot pedal in the foot brake valve, i.e. Figure 3 (a) From the second row "o foot pedal" to the next group "o", filter out the rows starting with "vn", obtain the x, y, and z coordinates of each row to form a spatial normal vector, and calculate the angle between each vector. Figure 3 (b) Taking rows 11080-11081 as an example, the vectors are as follows:
[0042]
[0043]
[0044] Calculate the dot product and magnitude of the two vectors respectively. , ,
[0045] Therefore, the angle between the two vectors is:
[0046]
[0047] 6. Calculate the maximum and minimum angles of each vector.
[0048] Based on step 5, calculate the angles between the vectors. For angles greater than 180°, subtract 360° (e.g., if the angle is 190°, convert it to 360-190=170°). Find the maximum and minimum angle values, and calculate the difference between them, letting it be... .
[0049] 7. Divide the normal vector coordinate interval according to the lightweight ratio.
[0050] Assuming the lightweight ratio is The lightweight weights of the normal vector are Then the lightweight ratio of the vertex space is The range of angles to be lightweighted is .
[0051] 8. Replace the original normal vector with the angle bisector vector.
[0052] against The vector is replaced by the angle bisector vector to reduce the number of vertices. Figure 3 (b) Taking the data in rows 11080-11081 as an example, the main steps to solve for the angle bisector are:
[0053] (1) Vector normalization
[0054]
[0055]
[0056] (2) Calculate the angle bisector vector
[0057] Angle bisector vector for and Adding, that is
[0058]
[0059]
[0060] (II) Incremental OBJ file generation method based on vertex count
[0061] The core idea of the vertex-based incremental OBJ file generation method is to increase the file size by increasing the number of vertices. Specifically, it involves increasing the number of triangles by adding spatial coordinate points and optimizing lighting and texture effects by adding normal vector data.
[0062] 1. Calculate the number of new rows based on the number of new bytes.
[0063] The number of lines to be added is:
[0064]
[0065] Increase the number of vertex space rows starting with 'v'. for:
[0066] , Incremental weighting of vertex space data
[0067] Increase the number of rows of normal vectors starting with "vn" for:
[0068] , Incremental weighting of normal vector data
[0069] 2. Calculate the maximum deviation of the vertex spatial coordinates in the x, y, and z directions.
[0070] Find the maximum value of x among all data that begin with 'v'. Minimum value The maximum value of y Minimum value The maximum value of z Minimum value .
[0071]
[0072]
[0073]
[0074] 3. Calculate the spatial coordinate interval values of each vertex.
[0075] Vertex space row coordinate interval for rows to be added in each direction , , They are respectively:
[0076]
[0077]
[0078]
[0079] in, This indicates rounding to the nearest integer. Incremental weights for vertex space data.
[0080] 4. Calculate the vertex spatial coordinates of each insertion point.
[0081] The coordinates of each insertion point are a set of data, and the insertion point... coordinates for:
[0082]
[0083]
[0084]
[0085] in , Indicates to Round the value up.
[0086] 5. Calculate the maximum deviation of the normal vector coordinates in the x, y, and z directions.
[0087] Find the maximum value of x among all data that begin with vn. Minimum value The maximum value of y Minimum value The maximum value of z Minimum value .
[0088]
[0089]
[0090]
[0091] 6. Calculate the coordinate interval values of each normal vector.
[0092] The row coordinate interval of the normal vector to be added in each direction , , They are respectively:
[0093]
[0094]
[0095]
[0096] in, Incremental weights for normal vector data.
[0097] 7. Calculate the coordinates of the normal vector at each insertion point.
[0098] The coordinates of each insertion point are a set of data, and the insertion point... coordinates for:
[0099]
[0100]
[0101]
[0102] in , Indicates to Round the value up.
Claims
1. A method for quantizing an OBJ file based on the number of vertices, characterized by, include: First, select the quantization mode for the OBJ format 3D digital model. If you want to perform lightweight quantization, proceed to the second step. If you want to perform incremental quantization, proceed to the third step. The second step is to lighten the model; the 3D digital model in OBJ format is lightened so that the size of the processed model file (i.e., the number of bytes) is smaller than the original model file size. The third step is to incrementally process the OBJ format 3D digital model so that the size of the processed model file (i.e., the number of bytes) is greater than the original model file size.
2. The OBJ file quantization method based on vertex count according to claim 1, characterized in that: The second step first calculates the model's lightweighting ratio, and then uses both edge folding and angle bisector replacement methods to remove some vertex data to achieve the lightweighting goal.
3. The OBJ file quantization method based on vertex count according to claim 1, characterized in that: The third step first calculates the number of bytes for the model increment and converts it into the number of rows. Then, the number of vertices is increased by vertex filling and angle bisector interpolation methods respectively to achieve the incremental purpose.
4. The OBJ file quantization method based on vertex count according to claim 2, characterized in that, The edge folding method is as follows: First, calculate the distance between each pair of spatial points that start with 'v' in the OBJ file, and arrange these distances from largest to smallest. Then, replace the line segment formed by all points whose distances are within the model lightweighting ratio described in the second step with a point in that line segment, and remove the endpoints of the line segment to reduce the number of vertices starting with 'v'.
5. The OBJ file quantization method based on vertex count according to claim 2, characterized in that, The angle bisector replacement method is as follows: First, calculate the angle between each pair of vectors that start with vn in the OBJ file, and arrange these angles from largest to smallest. Then, replace all vectors with angle bisectors within the range of the model lightweighting ratio described in the second step, and remove vector points to reduce the number of vn vertices.
6. The OBJ file quantization method based on vertex count according to claim 3, characterized in that, The vertex filling method is as follows: First, obtain the number of rows containing weights corresponding to the incremental byte count. Then, by calculating the maximum and minimum distances of the spatial points formed by data starting with 'v', the difference between the maximum and minimum distances is divided by... The distribution of vertices to be filled is obtained, and finally, vertex data is inserted according to the distribution to achieve the purpose of interpolation.
7. The OBJ file quantization method based on vertex count according to claim 3, characterized in that, The angle bisector interpolation method is as follows: First, obtain the number of rows containing weights corresponding to the incremental byte count. Then, by calculating the maximum and minimum angles of the vector formed by data starting with "vn", the value obtained by dividing the difference between the maximum and minimum angles in the x, y, and z directions is... The distribution of vector points to be filled is obtained, and finally vertex data is inserted according to the distribution to achieve the purpose of interpolation.