A method for close-up 3D model based on Unity3d

By calculating the position and angle of the virtual camera and utilizing Unity3d's collider simplification and vector formulas, the problem of determining the camera angle and position in close-up shots of 3D models was solved, achieving a perfect close-up effect for 3D models.

CN112837400BActive Publication Date: 2024-11-29BEIJING INBASIS TECH
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202110218538.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-02-26
Publication Date
2024-11-29
Estimated Expiration
2041-02-26

AI Technical Summary

Technical Problem

When displaying close-up shots of 3D models, Unity3D software struggles to quickly determine the camera's angle and position to achieve perfect close-up effects.

Method used

By calculating the position coordinates of the virtual camera, use AddComputer The method adds a collider, simplifies the 3D model into a cuboid, and determines the camera's angle and position by combining the vector angle formula and distance calculation.

Benefits of technology

It achieves a perfect close-up of the 3D model on the screen, with a suitable angle and size, occupying 80% of the screen size, and solves the problem of camera angle and position.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112837400B_ABST
    Figure CN112837400B_ABST
Patent Text Reader

Abstract

The present invention discloses a method for taking a close-up of a three-dimensional model based on Unity3d, comprising first calculating the position coordinates of a virtual camera of Unity3d, aligning the virtual camera with the three-dimensional model that needs a close-up, and adjusting the size of the virtual camera in the three-dimensional model screen; by moving the position of the virtual camera, determining and calculating the angle of the virtual camera, calculating the position of the virtual camera, and then taking a close-up of the three-dimensional model. The present invention can quickly find a good shooting angle and position, determine the distance from the virtual camera to the three-dimensional model, and can make the three-dimensional model that needs a close-up appear in the screen at an angle with a good visual sense, and can make it just occupy 80% of the size of the screen, perfectly achieving the purpose of close-up, being very convenient, suitable for any angle and any direction, and solving a problem that is generally troubled within the industry.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of three-dimensional models, and in particular to a method for close-up three-dimensional models based on Unity3d. Background Art

[0002] Unity3d software is a commonly used 3D product development software with a high market share. Many mobile games, 3D applications, and virtual reality products on the market are developed using Unity3d software.

[0003] When developing 3D software products, there is often a need to show a close-up of a 3D model. However, Unity3d does not provide relevant functions for showing a close-up of the 3D model at a good angle and distance, and technical developers need to implement it themselves.

[0004] The method of displaying 3D models in Unity3d software is to shoot the 3D model with a virtual camera, and the shot picture is the picture displayed on the screen. When a 3D model needs to be taken close-up, the angle and position must be found so that the 3D model can be presented in the picture with a relatively perfect angle and size. How to quickly find the shooting angle and position and determine the distance from the camera to the 3D model is a big difficulty. At present, there is no widely recognized solution to this problem in the field of Unity3d development. Summary of the invention

[0005] In view of the above technical problems in the related art, the present invention proposes a method based on Unity3d close-up three-dimensional model, which can overcome the above shortcomings of the prior art methods.

[0006] To achieve the above technical objectives, the technical solution of the present invention is implemented as follows:

[0007] A method for close-up 3D model based on Unity3d, comprising the following steps:

[0008] S1: First, calculate the position coordinates of the virtual camera of Unity3d, aim the virtual camera at the 3D model that needs a close-up, and adjust the size of the virtual camera in the 3D model screen;

[0009] S2: By moving the position of the virtual camera, determine and calculate the angle of the virtual camera, calculate the position of the virtual camera, and then take a close-up of the 3D model.

[0010] Furthermore, the method to determine the angle of the virtual camera is to use Unity3d's own AddComputer <boxcollider>Method, add a collision body to the 3D model, this collision body simplifies the 3D model into a rectangular model according to the position of each vertex of the 3D model, and then determines the angle of the camera relative to the 3D model based on the rectangular model.

[0011] Furthermore, the position of the virtual camera is determined by first drawing a line segment A from the virtual camera to the center point of the three-dimensional model, and calculating the length of the line segment A; then drawing a line segment B from the virtual camera to the highest vertex of the three-dimensional model, and calculating the angle X between the two line segments AB according to the vector angle formula; using the Vector3.Distance method provided by Unity3d to calculate the distance M between the two points, according to the Unity3d screen width and the camera position, the length of the line segment A is: 0.3*(M÷0.27), and the vector and the distance are multiplied to obtain the position of the virtual camera.

[0012] Furthermore, the vector angle formula is: cos<a,b> =ab / (|a|·|b|).

[0013] Furthermore, a method for calculating the angle of the virtual camera is to define three axes in the three-dimensional space, namely the X-axis, the Y-axis, and the Z-axis, determine the first longest axis, the second longest axis, and the shortest axis, and place the angle of the virtual camera relative to the three-dimensional model by calculation according to the length of the axis, and then calculate the distance between the camera and the three-dimensional model to obtain the position of the camera.

[0014] The beneficial effects of the present invention are as follows: by quickly finding a good shooting angle and position and determining the distance from the virtual camera to the three-dimensional model, the three-dimensional model that needs a close-up can be made to appear on the screen at an angle with a good visual sense, and can also be made to occupy exactly 80% of the size of the screen, thus perfectly achieving the purpose of a close-up. It is very convenient and suitable for any angle and any direction, solving a problem that is commonly troubled within the industry. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0016] Figure 1 It is a schematic diagram of the spatial perspective of a Unity3d virtual camera according to the method for a Unity3d close-up three-dimensional model according to an embodiment of the present invention.

[0017] Figure 2 It is a schematic diagram of a three-dimensional shape collision body according to the method based on the Unity3d close-up three-dimensional model according to an embodiment of the present invention.

[0018] Figure 3 It is a schematic diagram of a spatial picture model of a virtual camera according to a method based on a Unity3d close-up three-dimensional model according to an embodiment of the present invention.

[0019] Figure 4 It is a schematic flow chart of the invention steps of the method based on Unity3d close-up three-dimensional model according to an embodiment of the present invention.

[0020] In the figure: 1. Virtual camera, 2. Screen image, 3. Screen center point, 4. Three-dimensional model. DETAILED DESCRIPTION

[0021] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field belong to the scope of protection of the present invention. In order to facilitate the understanding of the above technical solutions of the present invention, the above technical solutions of the present invention are described in detail below through specific usage methods.

[0022] The present invention quickly obtains the position coordinates where the virtual camera 1 of Unity3d should appear through calculation, and makes the virtual camera 1 aim at the three-dimensional model 4 that needs a close-up, so that the three-dimensional model 4 is presented on the screen 2 at a relatively perfect angle and size.

[0023] like Figure 4 As shown, according to the method for close-up 3D model based on Unity3d according to an embodiment of the present invention, the method comprises close-up 3D model 4 by moving the position of virtual camera 1, as shown in FIG. Figure 1 As shown, the principle is that the icon of the virtual camera 1 is the location of the virtual camera 1, the quadrilateral frame is the screen image 2, and anything to the left of the screen image 2 and within the dotted line range can be presented in the final product image.

[0024] To achieve a perfect close-up of the 3D model 4, it is necessary to control the angle and position of the virtual camera 1; the angle of the virtual camera 1 determines the shape of the 3D model 4 on the screen 2. For example, a model of a telephone pole is a cylinder from a normal angle, but a circle from an angle directly above. The position of the virtual camera 1 determines the size of the 3D model 4 on the screen 2. The closer the distance, the larger the display, and vice versa.

[0025] First, determine the angle of the virtual camera 1. A 3D model 4 is a three-dimensional shape with three dimensions: length, width, and height. Use Unity3d's own AddComputer <boxcollider>Method, add a cuboid or cube collision body to the three-dimensional model 4. This collision body simplifies the three-dimensional model 4 into a cuboid model according to the positions of each vertex, such as Figure 2 As shown, the dotted line shows that the model of a house is simplified into a rectangular parallelepiped shape. Then, according to the situation of the rectangular parallelepiped, the angle of the virtual camera 1 relative to the three-dimensional model can be determined.

[0026] Then define three axes in the three-dimensional space, namely the X axis (left and right), the Y axis (up and down), and the Z axis (front and back). Find the first longest axis. If the X axis is the longest, then place the virtual camera 1 in front of the three-dimensional model 4, with the height flush with the center point of the three-dimensional model 4. Find the second longest axis. If the Z axis is the second longest, rotate the virtual camera 1 rightward 0-45 degrees with its own Y axis as the center. The degree value is: (Z axis length ÷ X axis length) * 45 degrees. Find the shortest axis. If it is the Y axis, rotate the virtual camera 1 downward 0-45 degrees with its own Z axis as the center. The degree value is: (Y axis length ÷ X axis length) * 45 degrees. Therefore, the angle of the virtual camera 1 is calculated.

[0027] Calculate the position of virtual camera 1. In Unity3d software, the straight-line distance from virtual camera 1 to the center point 3 of the screen is 0.3 meters. The length and width of the screen are 1 meter and 0.67 meters respectively. Assuming that the length, width and height of the 3D model 4 are the same, first draw a line segment A from virtual camera 1 to the center point of the 3D model 4, such as Figure 3 As shown, this line will definitely pass through the center point 3 of the screen, and the length of this line needs to be calculated. Then draw a line segment B from the virtual camera 1 to the highest vertex of the 3D model 4. According to the vector angle formula: cos<a,b> =ab / (|a|·|b|), the angle X between the two lines can be calculated.

[0028] It is known that the height of screen image 2 is 0.67 meters, 80% of the height is approximately 0.54 meters, and half of it is 0.27 meters. The center point and the highest coordinates of 3D model 4 are known. The Vector3.Distance method provided by Unity3d can be used to calculate the distance between the two points as M. According to the Unity3d screen width and camera position, the length of line segment A is 0.3*(M÷0.27). The vector and distance are multiplied to get the position of virtual camera 1.

[0029] After determining the angle and position of the virtual camera 1 and the distance from the virtual camera 1 to the three-dimensional model 4, the position coordinates of the virtual camera 1 are calculated by multiplying the vector and the distance. After the coordinates are determined by calculation, the three-dimensional model 4 that needs to be close-up appears in the screen 2 at a good visual angle, just occupying about 80% of the screen 2. It is also very convenient to adjust the size of the screen 2 for the three-dimensional model 4.

[0030] In summary, with the aid of the above technical solution of the present invention, by quickly finding a good shooting angle and position and determining the distance from the virtual camera 1 to the three-dimensional model 4, the three-dimensional model 4 that needs a close-up can be made to appear in the screen 2 at a visually good angle, and can also be made to occupy just about 80% of the size of the screen 2, thus perfectly achieving the purpose of a close-up. This is very convenient and suitable for any angle and any direction, solving a problem that is commonly troubled within the industry.

[0031] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.< / boxcollider> < / boxcollider>

Claims

1. A method based on Unity3d close-up 3D model, characterized in that: The following steps are involved: S1: First, calculate the position coordinates of the virtual camera of Unity3d, aim the virtual camera at the 3D model that needs a close-up, and adjust the size of the virtual camera in the 3D model screen; S2: by moving the position of the virtual camera, determining and calculating the angle of the virtual camera, calculating the position of the virtual camera, and then taking a close-up of the three-dimensional model; Define three axes in three-dimensional space, namely X-axis, Y-axis and Z-axis, and find the first longest axis. If the X-axis is the longest, place the virtual camera in front of the three-dimensional model at the same height as the center point of the three-dimensional model; find the second longest axis. If the Z-axis is the second longest, rotate the virtual camera to the right 0-45 degrees with its Y-axis as the center. The degree value is: (Z-axis length ÷ X-axis length) * 45 degrees; find the shortest axis. If it is the Y-axis, rotate the virtual camera downward 0-45 degrees with its Z-axis as the center. The degree value is: (Y-axis length ÷ X-axis length) * 45 degrees, so the angle of the virtual camera is calculated.

2. The method based on Unity3d close-up 3D model according to claim 1, characterized in that: The method to determine the angle of the virtual camera is to use Unity3d's own AddComputer <boxcollider> Method, add a collision body to the 3D model, this collision body simplifies the 3D model into a rectangular model according to the position of each vertex of the 3D model, and then determines the angle of the camera relative to the 3D model based on the rectangular model.< / boxcollider> 3. The method based on Unity3d close-up 3D model according to claim 1, characterized in that: The position of the virtual camera is obtained by first drawing a line segment A from the virtual camera to the center point of the three-dimensional model, and calculating the length of the line segment A; then drawing a line segment B from the virtual camera to the highest vertex of the three-dimensional model, and calculating the angle X between the two line segments AB according to the vector angle formula; using the Vector3.Distance method provided by Unity3d to calculate the distance M between the two points, according to the Unity3d screen width and the camera position, the length of the line segment A is: 0.3*(M÷0.27), and the vector and the distance are multiplied to obtain the position of the virtual camera.

4. The method based on Unity3d close-up 3D model according to claim 3, characterized in that: The vector angle formula is: cos<a,b> =ab / (|a|·|b|).

5. The method based on Unity3d close-up 3D model according to claim 1, characterized in that: In step S2, the method for calculating the angle of the virtual camera is to define three axes in the three-dimensional space, namely the X-axis, the Y-axis, and the Z-axis, determine the first major axis, the second major axis, and the shortest axis, and place the angle of the virtual camera relative to the three-dimensional model by calculation according to the length of the axis, and then calculate the distance between the camera and the three-dimensional model to obtain the position of the camera.

Citation Information

Patent Citations

  • Method, system and software program for shooting and editing a film comprising at least one image of a 3D computer-generated animation

    US20130135315A1