Three-dimensional model display method and device, equipment and storage medium
By calculating the reference size value and model size value during the display of the three-dimensional model, determining the matching scaling ratio, and automatically adjusting the size of the three-dimensional model, the problem of distortion of the display effect of the three-dimensional model is solved and the user experience is improved.
Patent Information
- Application Number
- CN202410203100.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-02-23
- Publication Date
- 2025-09-02
AI Technical Summary
Due to the different size units of the three-dimensional model production software and application software, the display effect of the three-dimensional model in the application software is distorted, and the user needs to manually adjust the size, which has a poor user experience.
By reading the target three-dimensional model of the current three-dimensional scene, determining the reference size value and model size value, calculating the matching model scaling ratio, and automatically scaling the three-dimensional model in proportion to ensure that the model size conforms to the dimension relationship of the three-dimensional scene.
The automatic dimensional adjustment of the three-dimensional model is realized, which improves the user experience and makes the display effect real and accurate and meets user expectations.
Smart Images

Figure CN120580342A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of three-dimensional model processing, and in particular to a three-dimensional model display method, apparatus, device and storage medium. Background Art
[0002] A 3D model is a mathematical representation of the geometric shape and properties of an object in three-dimensional space. It consists of a collection of vertices, edges, and faces. 3D models can be used in computer graphics, virtual reality, animation, game development, and other fields.
[0003] 3D model creation software and application software are generally separate programs, and the units of measurement used in the two software may differ. When a 3D model file generated by the 3D model creation software is imported into the 3D model application software for display, the directly imported 3D model may appear as an apple larger than a building, or a car smaller than an apple. This results in a distorted 3D model display that deviates significantly from user expectations. Users are required to import the 3D model file into the application software for display and then manually adjust it to the appropriate size. Summary of the Invention
[0004] The present application provides a three-dimensional model display method, apparatus, device and storage medium to solve the technical problem of distorted display effects of three-dimensional models caused by different size units between three-dimensional model production software and application software.
[0005] In a first aspect, a three-dimensional model display method is provided, comprising:
[0006] Read the target 3D model to be displayed in the current 3D scene;
[0007] Determining a reference size value based on the three-dimensional model displayed in the current three-dimensional scene, wherein the reference size value is used to reflect the maximum point distance corresponding to the current three-dimensional scene;
[0008] Determining a model size value according to the target three-dimensional model, wherein the model size value is used to reflect the maximum point distance of the target three-dimensional model;
[0009] determining a model scaling ratio that matches the target three-dimensional model according to the model size value and the reference size value, wherein a product of the model size value and the model scaling ratio is within a reference size range, and the reference size range is obtained based on the reference size value;
[0010] The target three-dimensional model is scaled according to the model scaling ratio, and the scaled target three-dimensional model is displayed in the current three-dimensional scene.
[0011] In this technical solution, after reading the target three-dimensional model to be displayed in the current three-dimensional scene, a reference size value is first determined according to the three-dimensional model displayed in the current three-dimensional scene, and the reference size value is used to reflect the maximum point distance corresponding to the current three-dimensional scene. The model size value is determined according to the target three-dimensional model, and the model size value is used to reflect the maximum point distance of the target three-dimensional model to be displayed. Then, according to the model size value and the reference size value, a model scaling ratio matching the target three-dimensional model is determined. The product of the model size value and the model scaling ratio is within the reference size range. The reference size range is obtained based on the reference size value. Finally, the target three-dimensional model is scaled according to the model scaling ratio, and the scaled target three-dimensional model is displayed in the current three-dimensional scene. The three-dimensional model can be automatically adjusted. The size of the 3D model is determined and displayed without the user having to manually adjust the size of the 3D model, thereby improving the user experience. Since the reference size value is determined according to the 3D model displayed in the 3D scene, the reference size value is used to reflect the maximum point distance corresponding to the current 3D scene, and the reference size value can reasonably reflect the size of the 3D scene. The model size value is used to reflect the maximum point distance of the target 3D model to be displayed, and the model size value is used to reflect the maximum point distance of the target 3D model. The product of the model size value and the model scaling ratio is within the reference size range. The reference size range is obtained based on the reference size value, which can make the model scaling ratio conform to the size relationship between the 3D model to be displayed and the 3D scene, so that the display effect of the target 3D model adjusted according to the model scaling ratio is real and accurate, meeting user expectations.
[0012] In conjunction with the first aspect, in one possible implementation, determining the reference size value based on the 3D models displayed in the current 3D scene includes: calculating a first bounding box, where the first bounding box is the minimum bounding box that contains all 3D models displayed in the current 3D scene; and determining the size of the first bounding box that reflects the distance to the maximum point of the object as the reference size value. Determining the size of the 3D scene by calculating the minimum bounding box of all 3D models in the scene can simplify the 3D models in the scene, improve computational efficiency, and reduce computational complexity.
[0013] In combination with the first aspect, in a possible implementation method, before determining the reference size value based on the three-dimensional model in the current three-dimensional scene, it also includes: determining whether there is a three-dimensional model in the current three-dimensional scene; if there is a three-dimensional model in the current three-dimensional scene, executing the step of determining the reference size value based on the three-dimensional model displayed in the current three-dimensional scene.
[0014] In conjunction with the first aspect, in one possible implementation, the method further includes: if no 3D model exists in the current 3D scene, determining the reference size value based on a camera imaging area of the current 3D scene. When no 3D model exists in the 3D scene, determining the size of the 3D scene based on the camera imaging area of the 3D scene can reasonably determine the size of the 3D scene.
[0015] In conjunction with the first aspect, in one possible implementation, determining the model size value based on the target 3D model includes: calculating a second bounding box, where the second bounding box is a minimum bounding box that contains the target 3D model; and determining the size of the second bounding box, which reflects the maximum point distance of the object, as the model size value. Determining the model size value by calculating the minimum bounding box of the 3D model is equivalent to approximating the 3D model with a simple shape to determine the maximum point distance of the 3D model, which can improve computational efficiency and reduce computational complexity.
[0016] In conjunction with the first aspect, in a possible implementation, determining the model scaling ratio that matches the target three-dimensional model based on the model size value and the reference size value includes: determining whether the product of the model size value and the target scaling ratio is within the reference size range, the target scaling ratio being one of the scaling ratios in a preset scaling ratio set, the preset scaling ratio set including multiple preset scaling ratios, the multiple scaling ratios being scaling ratios corresponding to multiple different size units; if the product of the model size value and the target scaling ratio is within the reference size range, determining the target scaling ratio as the model scaling ratio that matches the target three-dimensional model. By presetting a preset scaling ratio set containing multiple scaling ratios and determining the model scaling ratio based on the preset scaling ratio set, the model scaling ratio can be quickly determined by searching and comparing in the set; and, since each scaling ratio in the preset scaling ratio set has a corresponding size unit, this method can also determine the size unit of the three-dimensional model, thereby achieving calibration of the size unit of the three-dimensional model.
[0017] In combination with the first aspect, in a possible implementation, determining the model scaling ratio that matches the target three-dimensional model based on the model size value and the reference size value also includes: if the product of the model size value and the target scaling ratio is not within the reference size range, using the next scaling ratio of the target scaling ratio in the preset scaling ratio set as the target scaling ratio, and returning to execute the step of determining whether the product of the model size value and the target scaling ratio is within the reference size range.
[0018] In combination with the first aspect, in a possible implementation, after determining the target scaling ratio as a model scaling ratio that matches the target three-dimensional model, it also includes: determining the size unit corresponding to the target scaling ratio as the size unit of the target three-dimensional model.
[0019] In conjunction with the first aspect, in one possible implementation, scaling the target three-dimensional model according to the model scaling ratio includes scaling the target three-dimensional model according to the model scaling ratio with a preset point as the scaling center. Scaling the three-dimensional model with the preset point as the scaling center can prevent origin offset, thereby achieving a better display effect of the three-dimensional model in the three-dimensional scene.
[0020] In a second aspect, a three-dimensional model display device is provided, comprising:
[0021] A model reading module is used to read the target 3D model to be displayed in the current 3D scene;
[0022] a size acquisition module, configured to determine a reference size value based on the three-dimensional model displayed in the current three-dimensional scene, the reference size value being used to reflect the maximum point distance corresponding to the current three-dimensional scene; and to determine a model size value based on the target three-dimensional model, the model size value being used to reflect the maximum point distance of the target three-dimensional model;
[0023] a scale determination module, configured to determine a model scaling ratio that matches the target three-dimensional model based on the model size value and the reference size value, wherein a product of the model size value and the model scaling ratio is within a reference size range, and the reference size range is obtained based on the reference size value;
[0024] The scaling display module is used to scale the target three-dimensional model according to the model scaling ratio and display the scaled target three-dimensional model in the current three-dimensional scene.
[0025] In a third aspect, a computer device is provided, comprising a memory and one or more processors, wherein the memory is connected to the one or more processors, and the one or more processors are used to execute one or more computer programs stored in the memory. When the one or more processors execute the one or more computer programs, the computer device implements the three-dimensional model display method of the first aspect mentioned above.
[0026] In a sixth aspect, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, and the computer program includes program instructions. When the program instructions are executed by a processor, the processor executes the three-dimensional model display method of the first aspect.
[0027] The present application can achieve the following technical effects: the size of the three-dimensional model can be automatically adjusted and displayed without the user having to manually adjust the size of the three-dimensional model, thereby improving the user experience; since the reference size value is determined based on the three-dimensional model displayed in the three-dimensional scene, the reference size value is used to reflect the maximum point distance corresponding to the current three-dimensional scene, and the reference size value can reasonably reflect the size of the three-dimensional scene; the model size value is used to reflect the maximum point distance of the target three-dimensional model to be displayed; the model size value is used to reflect the maximum point distance of the target three-dimensional model; the product of the model size value and the model scaling ratio is within the reference size range; the reference size range is obtained based on the reference size value, which can make the model scaling ratio conform to the size relationship between the three-dimensional model to be displayed and the three-dimensional scene, so that the display effect of the target three-dimensional model adjusted according to the model scaling ratio is real and accurate, and meets user expectations. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments of the present application. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0029] Figure 1 The figure shows the display of the cube model after the model files obtained by making the same cube model using three different size units are directly imported into the application software;
[0030] Figure 2 A schematic diagram of a flow chart of a three-dimensional model display method provided in an embodiment of the present application;
[0031] Figure 3 Schematic diagram of a three-dimensional model provided in an embodiment of the present application before and after scaling processing;
[0032] Figure 4 A schematic diagram of a three-dimensional model in a three-dimensional scene and a minimum bounding box of the three-dimensional model in the three-dimensional scene provided in an embodiment of the present application;
[0033] Figure 5 A schematic diagram of a flow chart of a three-dimensional model display method provided in an embodiment of the present application;
[0034] Figure 6 A schematic diagram of a camera imaging area of a three-dimensional scene is provided for an embodiment of the present application;
[0035] Figure 7 This is a schematic structural diagram of a three-dimensional model display device provided in an embodiment of the present application;
[0036] Figure 8It is a structural diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0037] In order to make the purpose, technical solutions and advantages of this application more clearly understood, the present application is further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0038] It should be noted that, if there is no conflict, the various features in the embodiments of the present application can be combined with each other and are all within the scope of protection of the present application. In addition, although the functional modules are divided in the device schematic and the logical order is shown in the flow chart, in some cases, the steps shown or described can be performed in a different order than the module division in the device or the order in the flow chart. Furthermore, the words "first", "second", "third", etc. used in this application do not limit the data and execution order, but only distinguish between the same items or similar items with basically the same functions and effects.
[0039] The technical solution of the present application is applicable to the application scenarios of three-dimensional models, and the application scenarios of three-dimensional models can be, for example, the editing scenarios of three-dimensional models, the display scenarios of three-dimensional models, etc. In the application scenarios of three-dimensional models, the model files of three-dimensional models are usually generated by the production software of three-dimensional models, and the application software of three-dimensional models completes the display of three-dimensional models by importing the model files of three-dimensional models. Since some model files lack unit information, such as model files in formats such as obj, fbx, glb, gltl, etc., they usually only have the numerical value of the size but not the unit of the value, and the production software and application software of three-dimensional models both have units. When the three-dimensional model application software directly imports the model file of the three-dimensional model and displays it according to the numerical value of the size in the model file of the three-dimensional model, it will appear Figure 1 The three cases shown are: Figure 1 The figure shows the display of the cube model after the model files obtained by making the same cube model using three production software with different size units are directly imported into the application software. Figure 1The default unit of the application software in is meter. The three-dimensional models produced by the three production software are cube models, and the length, width and height of the cube model are all 1 meter. The default unit of the production software 3Dmax is feet. The length, width and height of the cube model produced by the production software 3Dmax are all 0.3 feet. The model file generated by the production software 3Dmax is an obj file. The length, width and height of the cube model in the obj file containing the cube model are all 0.3. When the application software directly imports the obj file and displays it according to the values of the obj file, the length, width and height of the cube model are all 0.3 meters. In this way, the cube is displayed too small; the default unit of the production software Blender is meter. The length, width and height of the cube model produced by the production software Blender are all 1 meter. The three-dimensional model file generated by the production software Blender is a glb file, containing The length, width and height values of the cube model in the glb file of this cube model are all 1. When the application software directly imports the glb file and displays it according to the values in the glb file, the length, width and height of the cube model are all 1 meter, and the cube is displayed normally. The default unit of the production software Maya is centimeters. The length, width and height of the cube model produced by the production software Maya are all 100 centimeters. The model file generated by the production software Maya is an fbx file. The length, width and height values of the cube model in the fbx file containing the cube model are all 100. When the application software directly imports the fbx file and displays it according to the values in the fbx file, the length, width and height of the cube model are all 100 meters. In this way, the cube model is displayed too large. Figure 1 It can be seen that when the units of the 3D model production software and the application software are different, when the 3D model application software directly imports the model file of the 3D model and displays it according to the size values in the model file of the 3D model, the 3D model will be displayed too large or too small, that is, the display effect of the 3D model will be distorted and will not meet the user's expectations.
[0040] Since there are many kinds of 3D model production software and different production software have different units, in order to avoid distorted display of 3D models in application software, users are usually required to import the model file of the 3D model into the application software and then manually adjust the size of the 3D model to the appropriate size, which is cumbersome and provides a poor user experience.
[0041] In view of this, the present application proposes a three-dimensional model processing and display solution. After obtaining a three-dimensional model without a size unit, a scaling ratio suitable for the three-dimensional model is determined for the three-dimensional model based on the model size of the three-dimensional model and the size of the three-dimensional scene. The three-dimensional model is scaled according to the scaling ratio and then displayed, so that the display effect of the three-dimensional model is normal, and the user does not need to manually adjust the size of the three-dimensional model, which can improve the user experience.
[0042] Among them, the technical solution of this application can be applied to computer equipment that includes application software for three-dimensional models. The application software for three-dimensional models can be three-dimensional model editing software, three-dimensional model display software, or three-dimensional model production software, etc., and this application does not impose any restrictions.
[0043] The technical solution of this application is described in detail below.
[0044] See also Figure 2 , Figure 2 A flow chart of a three-dimensional model display method provided in an embodiment of the present application is shown as follows: Figure 2 As shown, the method includes the following steps:
[0045] S101: Read a target 3D model to be displayed in a current 3D scene.
[0046] Here, the current 3D scene is the 3D scene currently being displayed. A 3D model file may be imported and a target 3D model to be displayed may be read from the 3D model file.
[0047] S102: Determine a reference size value according to the three-dimensional model displayed in the current three-dimensional scene.
[0048] The reference size value is used to reflect the maximum point distance corresponding to the current three-dimensional scene; the maximum point distance of the current three-dimensional scene refers to the maximum distance between any two points in the current three-dimensional scene. The maximum point distance of the current three-dimensional scene can be used to describe the spatial size of the current three-dimensional scene and indicate the spatial range of the current three-dimensional scene.
[0049] In a feasible implementation, the reference size value may be determined through the following steps A1-A2:
[0050] A1. Calculate the first bounding box.
[0051] Here, the first bounding box is the minimum bounding box that encompasses all 3D models displayed in the current 3D scene. The minimum bounding box that encompasses all 3D models displayed in the current 3D scene refers to the smallest simple geometric body that can encompass all 3D models displayed in the current 3D scene. For example, it can be the smallest sphere that can encompass all 3D models displayed in the current 3D scene, the smallest cube that can encompass all 3D models displayed in the current 3D scene, the smallest cuboid that can encompass all 3D models displayed in the current 3D scene, and so on, without limitation to the examples given here.
[0052] Take the first bounding box as an example, the geometry type is a cuboid, you can refer to Figure 3 , Figure 3 There are two 3D models in the scene, then the first bounding box can be as follows Figure 3As shown in the cuboid in , the cuboid can include both three-dimensional models, and the spatial size of the cuboid can reflect the spatial size jointly occupied by the two three-dimensional models in the three-dimensional scene.
[0053] In a feasible implementation, all 3D models displayed in the current 3D scene can be regarded as 3D point clouds, and the minimum and maximum values of the x, y, and z coordinates in the 3D point clouds are determined, which are denoted as x and z, respectively. min , x max ,y min ,y max , z min , z max ; According to the minimum and maximum values of the x, y, and z coordinates in the 3D point cloud, calculate the range of the 3D point cloud on the x, y, and z axes, respectively denoted as x r =x max -x min ,y r =y max -y min , z r =z max -z min ; Select the axis with the largest range as the major axis of the bounding box. The range on the major axis is the length of the minimum bounding box. For example, x r >y r >z r , then select the x-axis as the major axis of the bounding box, and the range on the x-axis is the length of the minimum bounding box; calculate the center coordinates (x o ,y o , z o ), x o =(x min +x max ) / 2,y o =(y min +y max ) / 2,z o =(z min +z max ) / 2, and x r 、y r 、z r The length, width and height of the minimum bounding box containing all three-dimensional models displayed in the current three-dimensional scene are used to obtain a first bounding box.
[0054] Alternatively, the first bounding box may be obtained by calculating the minimum bounding box that includes all 3D models displayed in the current 3D scene using a bounding box calculation method such as a naive algorithm, a rotating caliper algorithm, a convex hull algorithm, a maximum vertex method, or a minimum vertex method. This application does not impose any restrictions.
[0055] A2. Determine the size value of the first bounding box that reflects the maximum point distance of the object as the reference size value.
[0056] Here, the size value of the first bounding box that reflects the maximum point distance of the object refers to the length value between the two points on the first bounding box that are farthest apart.
[0057] If the first bounding box is a cuboid, the two points on the first bounding box that are farthest apart are the two vertices on the diagonal of the cuboid. The size value of the first bounding box that reflects the maximum point distance of the object is the diagonal length of the first bounding box, that is, the reference size value is the diagonal length of the first bounding box. The calculation formula for the diagonal length of the first bounding box is L1 is the diagonal length of the first bounding box, and l, w, and h are the length, width, and height of the first bounding box respectively.
[0058] If the first bounding box is a sphere, the two points on the first bounding box that are farthest apart are the two points at the two ends of the diameter of the sphere. The size value of the first bounding box that reflects the maximum point distance of the object is the diameter length of the first bounding box, that is, the reference size value is the diameter length of the first bounding box.
[0059] It is understandable that the size value reflecting the maximum point distance of the object is different for different geometric types of the first bounding box, and the size value reflecting the maximum point distance of the object can be determined according to the geometric type of the first bounding box.
[0060] Determining the size of a 3D scene by calculating the minimum bounding box of all 3D models in the scene can simplify the 3D models in the scene, improve computational efficiency, and reduce computational complexity.
[0061] Optionally, the distances between all pairs of points on the 3D model in the current 3D scene may be calculated to obtain a distance set corresponding to the current 3D scene, and the maximum distance in the distance set corresponding to the current 3D scene may be determined as the reference size value.
[0062] S103: Determine the model size value according to the target three-dimensional model.
[0063] Here, the model size value is used to reflect the maximum point distance of the target three-dimensional model to be displayed. The maximum point distance of the target three-dimensional model refers to the maximum distance between any two points on the target three-dimensional model. The maximum point distance of the target three-dimensional model can be used to describe the spatial size of the target three-dimensional model, indicating the farthest range occupied by the target three-dimensional object in space.
[0064] In some possible cases, the model size value can be obtained through the following steps B1-B2:
[0065] B1. Calculate the second bounding box.
[0066] Here, the second bounding box is the minimum bounding box that contains the target 3D model. The minimum bounding box that contains the target 3D model refers to the smallest simple geometric body that can enclose the target 3D model. For example, it can be the smallest sphere that can enclose the target 3D model, the smallest cube that can enclose the target 3D model, the smallest cylinder that can enclose the target 3D model, the smallest rectangular parallelepiped that can enclose the target 3D model, and so on. The geometry type of the second bounding box can be the same as that of the first bounding box. In this way, the size of the 3D scene and the size of the target 3D model can be evaluated under the same size measurement standard, which helps to accurately determine the scaling ratio of the target 3D model.
[0067] Take the second bounding box as an example, the geometry type is a cuboid, you can refer to Figure 4 , Figure 4 The puppy in the figure is the target 3D model, then the second bounding box can be as follows Figure 4 As shown in the rectangle in the figure, the puppy is completely enclosed in it, and the spatial size of the rectangle can reflect the spatial size of the puppy.
[0068] B2. Determine the size value of the second bounding box reflecting the maximum point distance of the object as the model size value.
[0069] Here, the size value of the second bounding box that reflects the maximum point distance of the object refers to the length value between the two points on the second bounding box that are farthest apart.
[0070] The method for determining the size value of the second bounding box reflecting the maximum point distance of the object is the same as the method for determining the size value of the maximum point distance of the object of the first bounding box in the aforementioned step A2. Please refer to the relevant description of the aforementioned step A2 and will not be repeated here.
[0071] Determining the model size by calculating the minimum bounding box of the 3D model is equivalent to using a simple shape to approximate the 3D model to determine the maximum point distance of the 3D model, which can improve computing efficiency and reduce computational complexity.
[0072] S104: Determine a model scaling ratio that matches the target three-dimensional model according to the model size value and the reference size value.
[0073] Here, the product of the model size value and the model scaling ratio is within the reference size range, and the reference size range is obtained based on the reference size value.
[0074] In one possible implementation, the upper limit of the reference size range can be the product of the reference size value and a first ratio, and the upper limit of the reference size range can be the product of the reference size value and a second ratio, where the second ratio is greater than the first ratio. For example, if the first ratio is 10% and the second ratio is 120%, the reference size range is [Lc*10%, Lc*120%], where Lc is the reference size value. The first and second ratios can be set and modified by the user based on actual needs.
[0075] Optionally, the upper and lower limits of the reference dimension range may be obtained by summing and subtracting the reference dimension value from a preset constant dimension value. The reference dimension range may be [Lc-Lb, Lc+Lb], where Lb is a preset constant dimension value. This application does not limit the specific relationship between the reference dimension range and the reference dimension value.
[0076] In a feasible implementation, the scaling ratio of the model that matches the target three-dimensional model may be determined through the following steps C1-C4:
[0077] C1. Set the first zoom ratio in the preset zoom ratio set as the target zoom ratio.
[0078] Here, the target zoom ratio is one of the zoom ratios in a preset zoom ratio set. The preset zoom ratio set includes a plurality of preset zoom ratios. The plurality of zoom ratios are zoom ratios corresponding to a plurality of different size units.
[0079] Among them, the conversion relationship between different dimensional units and the dimensional units of the application software of the three-dimensional model can be determined in advance to obtain the scaling ratios corresponding to different dimensional units, and the scaling ratios corresponding to different dimensional units can be combined to obtain a preset scaling ratio set, which is stored in the computer device.
[0080] Taking the example of a three-dimensional model application software in which the dimension unit is meter, some commonly used dimension units are shown in the first column of Table 1. The scaling ratio corresponding to each dimension unit in the first column can be determined based on the conversion relationship between the dimension units shown in the first column of Table 1 and the dimension unit meter. The scaling ratio corresponding to each dimension unit is shown in the third column of Table 1. The various scaling ratios shown in the third column of Table 1 are combined to obtain a preset scaling ratio set.
[0081]
[0082]
[0083] Table 1
[0084] In some possible cases, the scaling ratios corresponding to each size unit can be sorted in advance based on the matching priority of each size unit, so that the order of the scaling ratios corresponding to each size unit in the preset scaling ratio set conforms to the priority of each size unit, that is, the order of each scaling ratio in the preset scaling ratio set is obtained based on the matching priority of the size unit corresponding to each scaling ratio.
[0085] For example, the matching priorities of the dimensional units in Table 1 are: 1. centimeter; 2. meter; 3. foot; 4. millimeter; 5. kilometer; 6. decimeter; 7. mile; 8. inch; 9. milliinch; then the order of the scaling ratios corresponding to each dimensional unit in the preset scaling ratio set is: 1. 0.01; 2. 1; 3. 0.3048; 4. 0.001; 5. 1000; 6. 0.1; 7. 1609.344; 8. 0.0254; 9. 0.0000254.
[0086] Among them, the matching priority of the dimension units can be pre-set according to the frequency of use of each dimension unit, specific business needs, etc. The matching priority of the dimension unit can also be adjusted and modified by the user. In response to the priority adjustment instruction for the dimension unit, the order of the scaling ratios in the scaling ratio set can also be adjusted so that the order of the scaling ratios in the scaling ratio set is the same as the priority order of the dimension units in the priority adjustment instruction. For example, the user adjusts the priority order of the dimension units in Table 1 to: 1. meter; 2. centimeter; 3. foot; 4. millimeter; 5. kilometer; 6. decimeter; 7. mile; 8. inch; 9. milliinch; then after the user adjusts, the priority adjustment instruction is obtained, and the order of the scaling ratios in the preset scaling ratio set is adjusted to: 1. 1; 2. 0.01; 3. 0.3048; 4. 0.001; 5. 1000; 6. 0.1; 7. 1609.344; 8. 0.0254; 9. 0.0000254.
[0087] The order of the scaling ratios in the scaling ratio set conforms to the priority of the size units corresponding to the scaling ratios, which helps to quickly match the model scaling ratio that matches the target 3D model.
[0088] C2. Determine whether the product of the model size value and the target scaling ratio is within the reference size range.
[0089] Among them, the product of the model size value and the target scaling ratio can be compared with the upper limit value and the lower limit value of the reference size range. If the model size value is greater than or equal to the lower limit value of the reference size range, and the model size value is less than or equal to the upper limit value of the reference size range, then it is determined that the model size value is within the reference size range; if the model size value is less than the lower limit value of the reference size range, or the model size value is greater than the upper limit value of the reference size range, then it is determined that the model size value is not within the reference size range.
[0090] C3. If the product of the model size value and the target scaling ratio is within the reference size range, the target scaling ratio is determined as a model scaling ratio that matches the target three-dimensional model.
[0091] Optionally, after the target scaling ratio is determined as the model scaling ratio that matches the target three-dimensional model, the dimension unit corresponding to the target scaling ratio may also be determined as the dimension unit of the target three-dimensional model.
[0092] For example, if the target scaling ratio is 0.01 in Table 1, then the size unit of the target three-dimensional model can be determined to be centimeters.
[0093] C4. If the product of the model size value and the target scaling ratio is not within the reference size range, the scaling ratio next to the target scaling ratio in the preset scaling ratio set is used as the target scaling ratio, and the process returns to step C2 until the target scaling ratio is the last scaling ratio in the preset scaling ratio set.
[0094] By pre-setting a preset scaling ratio set containing multiple preset scaling ratios, and determining the model scaling ratio based on the preset scaling ratio set, the model scaling ratio can be quickly determined by searching and comparing in the set; and, since each scaling ratio in the preset scaling ratio set has a corresponding size unit, this method can also determine the size unit of the three-dimensional model, thereby realizing the calibration of the size unit of the three-dimensional model.
[0095] Optionally, a scaling ratio range may be pre-set, and the scaling ratio of the model that matches the target three-dimensional model may be determined based on the dichotomy method.
[0096] S105: scaling the target three-dimensional model according to the model scaling ratio.
[0097] The target 3D model can be scaled based on the model scale ratio, with the preset point as the scaling center. The scaling center, also known as the scaling origin, is the reference position for scaling; the scaling center remains unchanged during scaling. The preset point can be the center point of the target 3D model, the center point of a second bounding box, or the center point of the bottom surface of the second bounding box. For details on the definition of the second bounding box, please refer to the description of step B1 above.
[0098] Take the preset point as the center point of the target 3D model as an example, assuming the model scaling ratio is 0.1. Figure 4 The target three-dimensional model after scaling the puppy shown is as follows Figure 4 As shown in Q.
[0099] Scaling the 3D model with a preset point as the scaling center can prevent the origin from shifting, so that the 3D model can have a better display effect in the 3D scene.
[0100] S106: Display the target three-dimensional model after the scaling process in the current three-dimensional scene.
[0101] In the above Figure 2 In the corresponding technical solution, after reading the target three-dimensional model to be displayed in the current three-dimensional scene, a reference size value is first determined according to the three-dimensional model displayed in the current three-dimensional scene, and the reference size value is used to reflect the maximum point distance corresponding to the current three-dimensional scene. The model size value is determined according to the target three-dimensional model, and the model size value is used to reflect the maximum point distance of the target three-dimensional model to be displayed. Then, according to the model size value and the reference size value, a model scaling ratio that matches the target three-dimensional model is determined. The product of the model size value and the model scaling ratio is within the reference size range. The reference size range is obtained based on the reference size value. Finally, the target three-dimensional model is scaled according to the model scaling ratio, and the scaled target three-dimensional model is displayed in the current three-dimensional scene, which can automatically adjust the three-dimensional model. The size of the model is determined and displayed, without the user having to manually adjust the size of the 3D model, thereby improving the user experience; since the reference size value is determined according to the 3D model displayed in the 3D scene, the reference size value is used to reflect the maximum point distance corresponding to the current 3D scene, and the reference size value can reasonably reflect the size of the 3D scene; the model size value is used to reflect the maximum point distance of the target 3D model to be displayed; the model size value is used to reflect the maximum point distance of the target 3D model; the product of the model size value and the model scaling ratio is within the reference size range; the reference size range is obtained based on the reference size value, which can make the model scaling ratio conform to the size relationship between the 3D model to be displayed and the 3D scene, so that the display effect of the target 3D model adjusted according to the model scaling ratio is real and accurate, meeting user expectations.
[0102] See also Figure 5 , Figure 5 A flow chart of a three-dimensional model display method provided in an embodiment of the present application is shown as follows: Figure 5 As shown, the method includes the following steps:
[0103] S201: Read a target 3D model to be displayed in the current 3D scene.
[0104] S202: Determine whether there is a three-dimensional model in the current three-dimensional scene.
[0105] If there is a three-dimensional model in the current three-dimensional scene, execute step S203; if there is no three-dimensional model in the current three-dimensional scene, execute step S204.
[0106] S203: Determine a reference size value according to the three-dimensional model displayed in the current three-dimensional scene.
[0107] Here, for a specific implementation of determining the reference size value according to the three-dimensional model in the current three-dimensional scene, reference may be made to the description of the aforementioned step S102 .
[0108] S204: Determine a reference size value according to the camera imaging area of the current three-dimensional scene.
[0109] The diagonal length of the camera imaging area of the current 3D scene can be determined as the reference size value. The camera imaging area of a 3D scene refers to the visible area of the virtual camera projection within the 3D scene. The camera imaging area can also be called the field of view, which describes the viewing angle range and display area that the virtual camera can see.
[0110] For reference Figure 6 , Figure 6 shows the camera imaging area of the three-dimensional scene, Figure 6 The pyramid in the figure represents the viewing cone range of the virtual camera. The location of the black dot represents the focus position of the virtual camera. The distance from the virtual camera to the focus is the focal length of the virtual camera. The gray shaded area is the camera imaging area. The width of the camera imaging area is W = 2*tan(Fov / 2)*f, where W represents the width of the camera imaging area, Fov represents the viewing angle of the virtual camera, and f represents the focal length of the virtual camera. The height of the camera imaging area is H = W / ar, where H represents the height of the camera imaging area, and ar represents the aspect ratio of the camera imaging area, also known as the width-to-height ratio of the camera imaging area. For example, if the aspect ratio of the camera imaging area is 16:9, then H = 9W / 16. The diagonal length of the camera imaging area of the current three-dimensional scene is L2 represents the diagonal length of the camera imaging area, that is, the reference size value.
[0111] S205: Determine the model size value according to the target three-dimensional model.
[0112] S206: Determine a model scaling ratio that matches the target three-dimensional model based on the model size value and the reference size value.
[0113] S207: scaling the target three-dimensional model according to the model scaling ratio.
[0114] S208: Display the target three-dimensional model after the scaling process in the current three-dimensional scene.
[0115] Here, regarding the specific implementation of steps S205 to S208, please refer to the description of the aforementioned steps S103 to S106, which will not be repeated here.
[0116] In the above Figure 6 In the corresponding technical solution, when determining the reference size value, it is first determined whether there is a three-dimensional model in the current three-dimensional scene. When there is a three-dimensional model, the reference size value is determined based on the three-dimensional model in the current three-dimensional scene. When there is no three-dimensional model, the reference size value is determined based on the camera imaging area, which can reasonably determine and express the size of the three-dimensional scene.
[0117] The method of the present application is introduced above, and the device of the present application is introduced below.
[0118] See also Figure 7 , Figure 7 This is a schematic diagram of the structure of a three-dimensional model display device provided in an embodiment of the present application. Figure 7 As shown, the three-dimensional model display device 30 includes:
[0119] The model reading module 301 is used to read the target 3D model to be displayed in the current 3D scene;
[0120] The size acquisition module 302 is configured to determine a reference size value based on the 3D model displayed in the current 3D scene, the reference size value being used to reflect the maximum point distance corresponding to the current 3D scene; and to determine a model size value based on the target 3D model, the model size value being used to reflect the maximum point distance of the target 3D model.
[0121] a scale determination module 303 for determining a model scale ratio that matches the target three-dimensional model based on the model size value and the reference size value, wherein the product of the model size value and the model scale ratio is within a reference size range, and the reference size range is obtained based on the reference size value;
[0122] The scaling display module 304 is configured to scale the target 3D model according to the model scaling ratio and display the scaled target 3D model in the current 3D scene.
[0123] In one possible design, the size acquisition module 302 is specifically used to: calculate a first bounding box, which is the minimum bounding box that contains all three-dimensional models displayed in the current three-dimensional scene; and determine the size value of the first bounding box that reflects the maximum point distance of the object as the reference size value.
[0124] In a possible design, the above-mentioned size acquisition module 302 is also used to: determine whether there is a three-dimensional model in the current three-dimensional scene; if there is a three-dimensional model in the current three-dimensional scene, execute the step of determining the reference size value based on the three-dimensional model in the current three-dimensional scene.
[0125] In a possible design, the size acquisition module 302 is further configured to: if no three-dimensional model exists in the current three-dimensional scene, determine the reference size value according to a camera imaging area of the current three-dimensional scene.
[0126] In a possible design, the size acquisition module 302 is specifically configured to determine the diagonal length of the camera imaging area as the reference size value.
[0127] In one possible design, the size acquisition module 302 is specifically used to: calculate a second bounding box, which is the minimum bounding box containing the target three-dimensional model; and determine the size value of the first bounding box reflecting the maximum point distance of the object as the model size value.
[0128] In one possible design, the above-mentioned ratio determination module 303 is specifically used to: determine whether the product of the model size value and the target scaling ratio is within the reference size range, the target scaling ratio is one of the scaling ratios in a preset scaling ratio set, and the preset scaling ratio set includes multiple preset scaling ratios, and the multiple scaling ratios are scaling ratios corresponding to multiple different size units; if the product of the model size value and the target scaling ratio is within the reference size range, the target scaling ratio is determined as a model scaling ratio that matches the target three-dimensional model.
[0129] In one possible design, the above-mentioned ratio determination module 303 is also used to: if the product of the model size value and the target scaling ratio is not within the reference size range, use the next scaling ratio of the target scaling ratio in the preset scaling ratio set as the target scaling ratio, and return to execute the step of determining whether the product of the model size value and the target scaling ratio is within the reference size range.
[0130] In a possible design, the ratio determination module 303 is further configured to determine the size unit corresponding to the target scaling ratio as the size unit of the target three-dimensional model.
[0131] In a possible design, the zoom display module 304 is specifically used to: zoom the target three-dimensional model according to the model zoom ratio and with a preset point as the zoom center.
[0132] It should be noted that Figure 7 For the contents not mentioned in the corresponding embodiments, please refer to the description of the aforementioned method embodiments and will not be repeated here.
[0133] The above-mentioned device, after reading the target three-dimensional model to be displayed in the current three-dimensional scene, first determines a reference size value according to the three-dimensional model displayed in the current three-dimensional scene, the reference size value is used to reflect the maximum point distance corresponding to the current three-dimensional scene, and determines a model size value according to the target three-dimensional model, the model size value is used to reflect the maximum point distance of the target three-dimensional model to be displayed, and then determines a model scaling ratio that matches the target three-dimensional model according to the model size value and the reference size value, the product of the model size value and the model scaling ratio is within the reference size range, the reference size range is obtained based on the reference size value, and finally scales the target three-dimensional model according to the model scaling ratio, and displays the scaled target three-dimensional model in the current three-dimensional scene, which can automatically adjust the three-dimensional model. The model size value is used to reflect the maximum point distance of the target 3D model to be displayed, and the model size value is used to reflect the maximum point distance of the target 3D model. The product of the model size value and the model scaling ratio is within the reference size range. The reference size range is obtained based on the reference size value, which can make the model scaling ratio conform to the size relationship between the 3D model to be displayed and the 3D scene, so that the display effect of the target 3D model adjusted according to the model scaling ratio is real and accurate, meeting user expectations.
[0134] See also Figure 8 , Figure 8 4 is a schematic diagram of a computer device according to an embodiment of the present application, wherein the computer device 40 includes a processor 401 and a memory 402. The memory 402 is connected to the processor 401, for example, via a bus.
[0135] The processor 401 is configured to support the computer device 40 in executing the corresponding functions of the method in the above method embodiment. The processor 401 can be a central processing unit (CPU), a network processor (NP), a hardware chip, or any combination thereof. The above hardware chip can be an application specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. The above PLD can be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof.
[0136] Memory 402 is used to store program code, etc. Memory 402 may include volatile memory (VM), such as random access memory (RAM); non-volatile memory (NVM), such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid-state drive (SSD); or a combination of the aforementioned types of memory.
[0137] The processor 401 may call the program code to perform the following operations:
[0138] Read the target 3D model to be displayed in the current 3D scene;
[0139] Determining a reference size value based on the three-dimensional model displayed in the current three-dimensional scene, wherein the reference size value is used to reflect the maximum point distance corresponding to the current three-dimensional scene;
[0140] Determining a model size value according to the target three-dimensional model, wherein the model size value is used to reflect the maximum point distance of the target three-dimensional model;
[0141] determining a model scaling ratio that matches the target three-dimensional model according to the model size value and the reference size value, wherein a product of the model size value and the model scaling ratio is within a reference size range, and the reference size range is obtained based on the reference size value;
[0142] The target three-dimensional model is scaled according to the model scaling ratio, and the scaled target three-dimensional model is displayed in the current three-dimensional scene.
[0143] An embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a computer, the computer executes the method as described in the above embodiment.
[0144] Those skilled in the art will appreciate that all or part of the processes in the above-described method embodiments can be implemented by instructing related hardware through a computer program. The program can be stored in a computer-readable storage medium, and when executed, the program can include the processes in the above-described method embodiments. The storage medium can be a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).
[0145] The above disclosure is only a preferred embodiment of the present application, and certainly cannot be used to limit the scope of rights of the present application. Therefore, equivalent changes made according to the claims of the present application are still within the scope covered by the present application.
Claims
1. A three-dimensional model display method, characterized in that: include: Read the target 3D model to be displayed in the current 3D scene; Determining a reference size value based on the three-dimensional model displayed in the current three-dimensional scene, wherein the reference size value is used to reflect the maximum point distance corresponding to the current three-dimensional scene; Determining a model size value according to the target three-dimensional model, wherein the model size value is used to reflect the maximum point distance of the target three-dimensional model; determining a model scaling ratio that matches the target three-dimensional model according to the model size value and the reference size value, wherein a product of the model size value and the model scaling ratio is within a reference size range, and the reference size range is obtained based on the reference size value; The target three-dimensional model is scaled according to the model scaling ratio, and the scaled target three-dimensional model is displayed in the current three-dimensional scene.
2. The method according to claim 1, characterized in that The determining the reference size value according to the three-dimensional model displayed in the current three-dimensional scene includes: Calculating a first bounding box, where the first bounding box is a minimum bounding box that contains all three-dimensional models displayed in the current three-dimensional scene; The size value of the first bounding box reflecting the maximum point distance of the object is determined as the reference size value.
3. The method according to claim 1, characterized in that Before determining the reference size value according to the three-dimensional model displayed in the current three-dimensional scene, the method further includes: Determining whether a three-dimensional model exists in the current three-dimensional scene; If there is a three-dimensional model in the current three-dimensional scene, the step of determining the reference size value according to the three-dimensional model displayed in the current three-dimensional scene is performed.
4. The method according to claim 3, characterized in that The method further comprises: If no three-dimensional model exists in the current three-dimensional scene, the reference size value is determined according to a camera imaging area of the current three-dimensional scene.
5. The method according to claim 4, characterized in that The determining the reference size value according to the camera imaging area of the current three-dimensional scene includes: The diagonal length of the camera imaging area is determined as the reference size value.
6. The method according to claim 1, wherein Determining the model size value according to the target three-dimensional model includes: Calculating a second bounding box, where the second bounding box is a minimum bounding box that contains the target three-dimensional model; The size value of the second bounding box reflecting the maximum point distance of the object is determined as the model size value.
7. The method according to any one of claims 1 to 6, characterized in that Determining a model scaling ratio that matches the target three-dimensional model based on the model size value and the reference size value includes: Determining whether a product of the model size value and a target scaling ratio is within the reference size range, where the target scaling ratio is one of a set of preset scaling ratios, the set of preset scaling ratios including a plurality of preset scaling ratios, each of which corresponds to a plurality of different size units; If the product of the model size value and the target scaling ratio is within the reference size range, the target scaling ratio is determined as a model scaling ratio that matches the target three-dimensional model.
8. The method according to claim 7, characterized in that The step of determining a model scaling ratio that matches the target three-dimensional model based on the model size value and the reference size value further includes: If the product of the model size value and the target scaling ratio is not within the reference size range, the next scaling ratio of the target scaling ratio in the preset scaling ratio set is used as the target scaling ratio, and the process returns to the step of determining whether the product of the model size value and the target scaling ratio is within the reference size range.
9. The method according to claim 7, characterized in that After determining the target scaling ratio as a model scaling ratio that matches the target three-dimensional model, the method further includes: The size unit corresponding to the target scaling ratio is determined as the size unit of the target three-dimensional model.
10. The method according to any one of claims 1 to 6, characterized in that: The scaling process of the target three-dimensional model according to the model scaling ratio includes: The target three-dimensional model is scaled according to the model scaling ratio and with the preset point as the scaling center.
11. A three-dimensional model display device, characterized in that: include: A model reading module is used to read the target 3D model to be displayed in the current 3D scene; a size acquisition module, configured to determine a reference size value based on the three-dimensional model displayed in the current three-dimensional scene, the reference size value being used to reflect the maximum point distance corresponding to the current three-dimensional scene; and to determine a model size value based on the target three-dimensional model, the model size value being used to reflect the maximum point distance of the target three-dimensional model; a scale determination module, configured to determine a model scaling ratio that matches the target three-dimensional model based on the model size value and the reference size value, wherein a product of the model size value and the model scaling ratio is within a reference size range, and the reference size range is obtained based on the reference size value; The scaling display module is used to scale the target three-dimensional model according to the model scaling ratio and display the scaled target three-dimensional model in the current three-dimensional scene.
12. A computer device, characterized in that: The computer device comprises a memory and a processor, wherein the memory is connected to the processor, and the processor is used to execute one or more computer programs stored in the memory. When the processor executes the one or more computer programs, the computer device implements the method according to any one of claims 1 to 10.
13. A computer-readable storage medium, characterized in that The computer-readable 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 is caused to perform the method according to any one of claims 1 to 10.