Method, device and electronic device for displaying three-dimensional model of game character
By superimposing multiple two-dimensional texture layers and adjusting the size based on the viewing frustum model, the problem of the lack of three-dimensionality in the virtual scene background is solved, and a more three-dimensional three-dimensional virtual scene display is achieved.
Patent Information
- Application Number
- CN202211427998.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-15
- Publication Date
- 2025-09-30
- Estimated Expiration
- 2042-11-15
AI Technical Summary
The virtual scenes generated in the prior art use a single texture layer, resulting in a lack of three-dimensionality in the background and a stiff display effect.
By superimposing multiple two-dimensional original texture layers and based on the viewing frustum model of the virtual camera, a size adjustment parameter is obtained, the size of the texture layer is adjusted to match the clipping space, and the target three-dimensional model is displayed in the three-dimensional virtual scene.
It improves the three-dimensional sense of the virtual scene background, enriches the performance effect of the three-dimensional virtual scene, and solves the problem of insufficient three-dimensional sense caused by a single texture layer.
Smart Images

Figure CN115738249B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computers, and more specifically, to a method, device, and electronic device for displaying a three-dimensional model of a game character. Background Art
[0002] Currently, virtual scenes are mainly generated using a single texture layer. However, due to the relatively simple texture of the single texture layer, the generated virtual scene display effect is stiff, resulting in a lack of three-dimensionality in the generated virtual scene background.
[0003] To address the above-mentioned problems, no effective solutions have been proposed so far. Summary of the Invention
[0004] At least some embodiments of the present application provide a method, apparatus, and electronic device for displaying a three-dimensional model of a game character, so as to at least solve the technical problem that the generated virtual scene background lacks a three-dimensional sense.
[0005] According to one embodiment of the present application, a method for displaying a three-dimensional model of a game character is provided, which may include: determining a target three-dimensional model and multiple preset two-dimensional original texture layers, wherein the multiple two-dimensional original texture layers are used to generate a three-dimensional virtual scene background for displaying the target three-dimensional model by overlay rendering, and the original sizes of the multiple two-dimensional original texture layers are the same and are located in the coordinate system of the virtual camera's viewing frustum; based on the relative position between the two-dimensional original texture layer and the virtual camera, obtaining a size adjustment parameter of the two-dimensional original texture layer within the viewing frustum; based on the size adjustment parameter, adjusting the original size of the two-dimensional original texture layer to a target size to obtain a target texture layer, wherein the target texture layer matches the size of a clipping plane in a clipping space, and the clipping space is determined based on the viewing frustum; generating a three-dimensional virtual scene background based on the target texture layer, and displaying the target three-dimensional model in the three-dimensional virtual scene background.
[0006] According to one embodiment of the present application, a display device for a three-dimensional model of a game character is also provided, which device may include: a determination unit, used to determine a target three-dimensional model and a plurality of preset two-dimensional original texture layers, wherein the plurality of two-dimensional original texture layers are generated by overlay rendering to generate a three-dimensional virtual scene background for displaying the target three-dimensional model, and the original sizes of the plurality of two-dimensional original texture layers are the same and are located in the coordinate system where the viewing frustum of the virtual camera is located; an acquisition unit, used to obtain a size adjustment parameter of the two-dimensional original texture layer within the viewing frustum based on the relative position between the two-dimensional original texture layer and the virtual camera; an adjustment unit, used to adjust the original size of the two-dimensional original texture layer to a target size based on the size adjustment parameter to obtain a target texture layer, wherein the target texture layer matches the size of a clipping plane in a clipping space, and the clipping space is determined based on the viewing frustum; a generation unit, used to generate a three-dimensional virtual scene background based on the target texture layer, and display the target three-dimensional model in the three-dimensional virtual scene background.
[0007] According to one embodiment of the present application, a readable storage medium is further provided, in which a computer program is stored, wherein the computer program is configured to execute any of the above methods for displaying a three-dimensional model of a game character when running.
[0008] According to one embodiment of the present application, an electronic device is also provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute any of the above methods for displaying a three-dimensional model of a game character.
[0009] In at least some embodiments of the present application, a target three-dimensional model and multiple preset original texture layers are determined; a viewing cone model is established based on the construction parameters of a virtual camera; and then, based on the relative position between the two-dimensional original texture layer and the virtual camera, a size adjustment parameter of the two-dimensional original texture layer within the viewing cone is obtained; based on the size adjustment parameter, the original size of the two-dimensional original texture layer is adjusted to the target size to obtain the target texture layer; and a virtual scene is generated based on the target texture layer corresponding to each two-dimensional original texture layer. In other words, the embodiments of the present application can automatically adjust the original size of each two-dimensional original texture layer using the preset size adjustment parameter of the two-dimensional original texture layer within the viewing cone to obtain the target texture layer, and finally, generate a three-dimensional virtual scene background based on the target texture layer corresponding to the two-dimensional original texture layer, and display the target three-dimensional model in the three-dimensional virtual scene background, thereby achieving the purpose of generating a three-dimensional virtual scene background for a virtual character by superimposing two-dimensional texture layers, thereby solving the technical problem of the virtual scene background lacking a three-dimensional sense and achieving the technical effect of enhancing the three-dimensional sense of the virtual scene background. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0011] Figure 1 This is a hardware structure block diagram of a terminal device for displaying a three-dimensional model of a game character according to an embodiment of the present application;
[0012] Figure 2 is a flow chart of a method for displaying a three-dimensional model of a game character according to an embodiment of the present application;
[0013] Figure 3 is a schematic diagram of a virtual scene generated according to a related technology of an embodiment of the present application;
[0014] Figure 4 is a schematic diagram of a virtual scene generated according to another related technology of an embodiment of the present application;
[0015] Figure 5 is a schematic diagram of a plurality of texture layers being unified into the same size according to an embodiment of the present application;
[0016] Figure 6 is a schematic diagram of a texture layer of a default size within a camera's field of view according to an embodiment of the present application;
[0017] Figure 7 is a schematic diagram of a viewing cone model of a perspective camera according to an embodiment of the present application;
[0018] Figure 8 is a schematic diagram of a side view of a viewing cone model of a perspective camera according to an embodiment of the present application;
[0019] Figure 9 is a schematic diagram of the position of a texture layer in a frustum model according to an embodiment of the present application;
[0020] Figure 10 is a schematic diagram of each texture layer after the size is modified according to the scaling factor at the corresponding position according to an embodiment of the present application;
[0021] Figure 11 is a schematic diagram of a picture within a camera's field of view after each texture layer is resized according to a scaling factor at a corresponding position according to an embodiment of the present application;
[0022] Figure 12 is a schematic diagram of generating a virtual scene effect according to an embodiment of the present application;
[0023] Figure 13 is a schematic diagram of a display device for a three-dimensional model of a game character according to an embodiment of the present application;
[0024] Figure 14 is a schematic diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0025] In order to enable those skilled in the art to better understand the present invention, the following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the drawings 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 in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of this application.
[0026] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in a sequence other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0027] First, some nouns or terms that appear in the description of the embodiments of the present application are explained as follows:
[0028] The viewing frustum is the area of the 3D world visible on the screen, i.e., the field of view of a virtual camera (which can be called a perspective camera).
[0029] Field of View (FOV) refers to the angle of view of a virtual camera, that is, the range that a perspective camera lens can cover. It can be expressed as an angle. If an object exceeds the field of view angle, it will not be included in the perspective camera lens.
[0030] Trigonometric functions are mathematical functions of angles that relate the interior angle of a right triangle to the ratio of its other two sides.
[0031] According to one embodiment of the present application, an embodiment of a method for displaying a three-dimensional model of a game character is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0032] The above method embodiments involved in this application can be executed in a terminal device, a computer terminal, or a similar computing device. Taking running on a terminal device as an example, the terminal device can be a smart phone, a tablet computer, a PDA, a mobile Internet device, a PAD, a game console, or other terminal devices. Figure 1 This is a hardware structure block diagram of a terminal device for displaying a three-dimensional model of a game character according to an embodiment of the present application. Figure 1 As shown, the terminal device may include one or more ( Figure 1 Only one is shown) a processor 102 (the processor 102 may include but is not limited to a central processing unit (CPU), a graphics processing unit (GPU), a digital signal processing (DSP) chip, a microprocessor (MCU), a field-programmable logic device (FPGA), a neural network processor (NPU), a tensor processing unit (TPU), an artificial intelligence (AI) type processor, etc.) and a memory 104 for storing data. In one embodiment of the present application, it may also include: an input and output device 108 and a display device 110.
[0033] In some optional embodiments mainly based on gaming scenarios, the above-mentioned device can also provide a human-computer interaction interface with a touch-sensitive surface, which can sense finger contact and / or gestures to perform human-computer interaction with a graphical user interface (GUI). The human-computer interaction functions may include the following interactions: creating web pages, drawing, word processing, making electronic documents, games, video conferencing, instant messaging, sending and receiving emails, call interface, playing digital videos, playing digital music and / or web browsing, etc. The executable instructions for executing the above-mentioned human-computer interaction functions are configured / stored in a computer program product or readable storage medium executable by one or more processors.
[0034] Those skilled in the art will understand that Figure 1 The structure shown is only for illustration and does not limit the structure of the above terminal device. Figure 1 More or fewer components than shown, or with Figure 1 Different configurations shown.
[0035] In a possible implementation, the present application provides a method for displaying a three-dimensional model of a game character. Figure 2is a flow chart of a method for displaying a three-dimensional model of a game character according to an embodiment of the present application, such as Figure 2 As shown, the method includes the following steps:
[0036] Step S202: determining a target three-dimensional model and a plurality of preset two-dimensional original texture layers.
[0037] In the technical solution provided in the above step S202 of the present application, the target three-dimensional model may be the three-dimensional character skin of a three-dimensional virtual character in a three-dimensional virtual scene, and multiple two-dimensional original texture layers may be generated by overlay rendering to form a three-dimensional virtual scene background for displaying the target three-dimensional model, and the multiple two-dimensional original texture layers are all in the coordinate system where the viewing frustum of the virtual camera is located. The three-dimensional virtual scene may be a scene corresponding to a real scene, or a game scene in the gaming field, and the viewing frustum may be a viewing frustum model, for example, a scene for displaying the skin of a virtual character in a gaming application, the three-dimensional virtual scene background may be a three-dimensional background in the three-dimensional virtual scene, the two-dimensional original texture layer may be a layer or texture layer component for generating a three-dimensional virtual scene, or may be a texture layer that needs to be resized to adapt to the image of the virtual camera, the virtual camera may be a perspective camera, and the viewing frustum of the virtual camera may be a pre-established viewing frustum model of a perspective camera, the viewing frustum may be used to represent the field of view of the virtual camera, and the coordinate system where the viewing frustum is located may be a two-dimensional coordinate system or a three-dimensional coordinate system, which is not specifically limited here.
[0038] Optionally, the multiple two-dimensional original texture layers are cropped separately so that the original sizes of the multiple two-dimensional original texture layers are unified to the same size, that is, the height and width of the multiple two-dimensional original texture layers can be the same. Optionally, this embodiment can determine the same size of the multiple two-dimensional original texture layers based on the model of the virtual camera in the three-dimensional virtual scene background. For example, when adjusting the two-dimensional original texture layer, the two-dimensional original texture layer is preferentially matched to the height of the virtual camera. The widest model of the virtual camera used to display the three-dimensional virtual scene background can be determined, and the width greater than the widest model is determined as the width in the above original size, so that the content of the generated three-dimensional virtual scene background can be displayed in the picture of the virtual camera of the widest model without leakage in the width direction, that is, to avoid the situation where the content of the three-dimensional virtual scene background in the width direction does not fill the picture of the virtual camera in the width direction, wherein the unfilled part can be represented as a part filled with black. It should be noted that when adjusting the two-dimensional original texture layer, it is prioritized to make the two-dimensional original texture layer match the height of the virtual camera. If the content of the three-dimensional virtual scene background in the width direction exceeds the picture of the virtual camera in the width direction, the part of the three-dimensional virtual scene background in the width direction that exceeds the picture of the virtual camera in the width direction can be cut off.
[0039] Step S204 : obtaining a size adjustment parameter of the two-dimensional original texture layer in the viewing frustum based on the relative position between the two-dimensional original texture layer and the virtual camera.
[0040] In the technical solution provided in the above step S204 of the present application, in the coordinate system where the viewing frustum of the virtual camera is located, the position of the virtual camera is determined as the origin position of the coordinate axis, so that the centers of multiple two-dimensional original texture layers and the position of the virtual camera are located on the same coordinate axis, and the relative position between each two-dimensional original texture layer and the virtual camera is determined. Based on the relative position, a size adjustment parameter of each two-dimensional original texture layer within the viewing frustum is determined, wherein the relative position may include the original coordinate position of each two-dimensional original texture layer in the coordinate system when the virtual camera is at the origin position of the coordinate system where the viewing frustum is located, and the size adjustment parameter may be a size scaling coefficient. For example, when adjusting the two-dimensional original texture layer, when the two-dimensional original texture layer is preferentially adjusted to match the height of the virtual camera, the size scaling coefficient may be a height scaling coefficient, which is used to adjust the height of the two-dimensional original texture layer.
[0041] Optionally, in this embodiment, the above-mentioned resizing parameters can be determined based on the setting parameters of the virtual camera's viewing frustum, for example, based on the near clipping plane distance, far clipping plane distance, and image aspect ratio of the viewing frustum, which are related to the corresponding two-dimensional original texture layer. That is, different two-dimensional original texture layers may have different corresponding resizing parameters.
[0042] Optionally, the size adjustment parameter can be the difference or ratio between the size of the target clipping plane of the two-dimensional original texture layer and the original size. When the size adjustment parameter is a ratio, the two-dimensional original texture layer is adjusted by multiplying or dividing the original size by the size adjustment parameter. When the size adjustment parameter is a difference, the two-dimensional original texture layer is adjusted by adding or subtracting the original size from the size adjustment parameter. The size of the target clipping plane can be the size that the two-dimensional original texture layer should have at the original coordinate position. For example, when adjusting the two-dimensional original texture layer, in order to prioritize matching the two-dimensional original texture layer with the height of the virtual camera, the size of the target clipping plane can be the height that the two-dimensional original texture layer should have at the original coordinate position.
[0043] It should be noted that before obtaining the size adjustment parameters of the two-dimensional original texture layer within the viewing frustum based on the relative position between the two-dimensional original texture layer and the virtual camera, a viewing frustum model can be established based on the construction parameters of the virtual camera, wherein the viewing frustum model is the viewing frustum in this embodiment, and the construction parameters of the virtual camera may include FOV parameters, near clipping plane distance parameters, far clipping plane distance parameters, and screen aspect ratio parameters, etc., which are not specifically limited here.
[0044] Step S206 : Based on the size adjustment parameter, the original size of the two-dimensional original texture layer is adjusted to the target size to obtain the target texture layer.
[0045] In the technical solution provided in the above step S206 of the present application, the original sizes of multiple two-dimensional original texture layers can be adjusted to the target size according to the calculated size adjustment parameters to obtain the target texture layer, and a three-dimensional virtual scene background is generated based on the multiple target texture layers, wherein the target size can be the final size of the two-dimensional original texture layer, and the size of the target texture layer can be the size of the corresponding clipping plane in the clipping space.
[0046] Optionally, as the distance between the target texture layer and the virtual camera increases from near to far, the target size of the target texture layer also increases from small to large.
[0047] Optionally, adjusting the original sizes of the plurality of two-dimensional original texture layers to the target size according to the calculated size adjustment parameters may include: multiplying, dividing, adding or subtracting the original sizes, which is not specifically limited here.
[0048] For example, when adjusting the original sizes of multiple two-dimensional original texture layers to the target size, the two-dimensional original texture layers are preferably matched with the height of the virtual camera. The height of the original size is 10 cm, and the size adjustment parameter is 5. When the size adjustment parameter is a ratio, adjusting the original size can be multiplying or dividing the original size by the size adjustment parameter, that is, if 10 is multiplied by 5, the target size is 50 cm, and if 10 is divided by 5, the target size is 2 cm. When the size adjustment parameter is a difference, adjusting the original size can be adding or subtracting the original size from the size adjustment parameter, that is, if 10 is added to 5, the target size is 15 cm, and if 10 is subtracted from 5, the target size is 5 cm.
[0049] Optionally, if the size of the two-dimensional original texture layer just matches the picture of the virtual camera, the size adjustment parameter of the above-mentioned two-dimensional original texture layer can make the target texture layer the same as the two-dimensional original texture layer. For example, if the size adjustment parameter is the ratio of the size of the target clipping plane of the two-dimensional original texture layer to the original size, the value of the size adjustment parameter is 1; if the size adjustment parameter is the difference between the size of the target clipping plane of the two-dimensional original texture layer and the original size, the value of the size adjustment parameter is 0.
[0050] Optionally, when adjusting the 2D original texture layer so as to prioritize matching the height of the virtual camera, the original height of the 2D original texture layer may be adjusted to the target height based on the height scaling parameter to obtain the target texture layer.
[0051] It should be noted that each two-dimensional original texture layer of this embodiment can be processed in the above manner to obtain a target texture layer, thereby obtaining multiple target texture layers for generating a three-dimensional virtual scene background.
[0052] Step S208 : generating a three-dimensional virtual scene background based on the target texture layer, and displaying the target three-dimensional model in the three-dimensional virtual scene background.
[0053] In the technical solution provided in the above-mentioned step S208 of the present application, after each two-dimensional original texture layer is adjusted according to the corresponding size adjustment parameter to obtain multiple target texture layers, special effects can be added between each adjacent target texture layer in the multiple target texture layers to finally generate a three-dimensional virtual scene background, and the target three-dimensional model is displayed in the three-dimensional virtual scene background to achieve the purpose of enhancing the spatial sense of the three-dimensional virtual scene background and enriching the performance effect of the three-dimensional virtual scene background. Among them, the position of adding special effects between each adjacent target texture layer can be determined according to the scene construction requirements, and no specific limitation is made here.
[0054] Through the above steps S202 to S208 of the present application, the target three-dimensional model and multiple preset original texture layers are determined; based on the construction parameters of the virtual camera, a viewing cone model is established, and then based on the relative position between the two-dimensional original texture layer and the virtual camera, the size adjustment parameters of the two-dimensional original texture layer within the viewing cone are obtained; based on the size adjustment parameters, the original size of the two-dimensional original texture layer is adjusted to the target size to obtain the target texture layer; and a virtual scene is generated based on the target texture layer corresponding to each two-dimensional original texture layer. In the embodiment of the present application, the original size of each two-dimensional original texture layer can be automatically adjusted by the preset size adjustment parameters of the two-dimensional original texture layer within the viewing cone to obtain the target texture layer, and finally a three-dimensional virtual scene background is generated based on the target texture layer corresponding to the two-dimensional original texture layer, and the target three-dimensional model is displayed in the three-dimensional virtual scene background, thereby achieving the purpose of generating a three-dimensional virtual scene background for a virtual character by superimposing two-dimensional texture layers, thereby solving the technical problem of the virtual scene background lacking three-dimensional sense and achieving the technical effect of enhancing the three-dimensional sense of the virtual scene background.
[0055] The above method of this embodiment is further introduced below.
[0056] As an optional implementation, step S204, based on the relative position between the two-dimensional original texture layer and the virtual camera, obtaining a resizing parameter of the two-dimensional original texture layer within the viewing frustum, includes: obtaining the resizing parameter based on the original coordinate position of the center of the two-dimensional original texture layer on the coordinate axis.
[0057] In this embodiment, the centers of multiple two-dimensional original texture layers and the position of the virtual camera are located on the same coordinate axis, and the position of the virtual camera can be the origin of the coordinate axis. The multiple two-dimensional original texture layers are arranged in sequence on the coordinate axis to obtain the original coordinate positions of the multiple two-dimensional original texture layers on the coordinate axis. Then, according to the original coordinate positions, the size adjustment parameters corresponding to the two-dimensional original texture layers at the original coordinate positions are obtained, and the size of the two-dimensional original texture layer is adjusted based on the size adjustment parameters, wherein the two-dimensional original texture layer is a plane image, the center of the two-dimensional original texture layer can be the geometric center of the two-dimensional original texture layer, the origin of the coordinate axis can be the zero point of the coordinate axis, the original coordinate position can be the coordinate position of the two-dimensional original texture layer on the coordinate axis, and the size adjustment parameter can be a size scaling factor. For example, when adjusting the two-dimensional original texture layer, when the two-dimensional original texture layer is preferentially made to match the height of the virtual camera, the size scaling factor can be a height scaling factor, which is used to adjust the height of the two-dimensional original texture layer.
[0058] For example, the centers of multiple two-dimensional original texture layers and the virtual camera are located on the Z axis of the coordinate system, the position of the virtual camera is the zero position of the Z axis, and the multiple two-dimensional original texture layers are arranged in sequence on the Z axis to obtain the original coordinate positions of the multiple two-dimensional original texture layers on the coordinate axis, that is, the original coordinate position of texture layer 1 is Z1, the original coordinate position of texture layer 2 is Z2, and the original coordinate position of texture layer 3 is Z3. Then, the size adjustment parameters of texture layer 1 at Z1, the size adjustment parameters of texture layer 2 at Z2, and the size adjustment parameters of texture layer 3 at Z3 are obtained respectively.
[0059] As an optional embodiment, the method may further include obtaining a size adjustment parameter of the two-dimensional original texture layer within the viewing frustum based on the original coordinate position of the center of the two-dimensional original texture layer on the coordinate axis, including: determining the size of the target clipping plane corresponding to the original coordinate position in the clipping space; and determining the size adjustment parameter based on the size of the target clipping plane and the original size.
[0060] In this embodiment, the size of the target clipping plane corresponding to the two-dimensional original texture layer at the original coordinate position can be first determined in the clipping space of the virtual camera, and then the difference or ratio between the size of the target clipping plane of the two-dimensional original texture layer at the original coordinate position and the original size can be determined as the size adjustment parameter, wherein the original size can be the original size of the two-dimensional original texture layer, and the size of the target clipping plane can be the size that the two-dimensional original texture layer should have at the original coordinate position. For example, when adjusting the two-dimensional original texture layer to prioritize matching the height of the virtual camera, the original size can be the original height of the two-dimensional original texture layer, and the size of the target clipping plane can be the height that the two-dimensional original texture layer should have at the original coordinate position.
[0061] Optionally, the size adjustment parameter can be calculated using the following formula:
[0062]
[0063] In the above formula, S Z Can be used to represent the size adjustment parameter, that is, the size scaling factor, H Z It can be used to represent the size of the target clipping plane of the two-dimensional original texture layer, H o Can be used to represent the original size of a 2D original texture layer.
[0064] For example, when adjusting the two-dimensional original texture layer, the priority is to make the two-dimensional original texture layer match the height of the virtual camera. Z It can be a height scaling factor, which is used to adjust the height of the original two-dimensional texture layer and the size of the target clipping plane H. Z Can be the height of the target clipping plane, the original size H o It can be the height of the 2D original texture layer.
[0065] As an optional embodiment, the method may further include determining the size of the target clipping plane corresponding to the original coordinate position in the clipping space, including: determining a first predetermined clipping plane and a second predetermined clipping plane in the clipping space; determining the size of the target clipping plane based on the size of the first predetermined clipping plane, the size of the second predetermined clipping plane, the first coordinate position of the center of the first predetermined clipping plane on the coordinate axis, the second coordinate position of the center of the second predetermined clipping plane on the coordinate axis, and the original coordinate position.
[0066] In this embodiment, a first predetermined clipping plane and a second predetermined clipping plane may be first determined in the clipping space. Then, according to the principle of similar triangles and the principle of linear mapping, the size of the target clipping plane may be calculated based on the size of the first predetermined clipping plane, the size of the second predetermined clipping plane, the first coordinate position of the center of the first predetermined clipping plane on the coordinate axis, the second coordinate position of the center of the second predetermined clipping plane on the coordinate axis, and the original coordinate position. The first predetermined clipping plane may be a near clipping plane, the second predetermined clipping plane may be a far clipping plane, the size of the first predetermined clipping plane may be the size of the near clipping plane, and the size of the second predetermined clipping plane may be the size of the far clipping plane. For example, when adjusting a two-dimensional original texture layer so as to preferentially match the height of a virtual camera, the size of the first predetermined clipping plane may be the height of the near clipping plane, the size of the second predetermined clipping plane may be the height of the far clipping plane, the first coordinate position may be the distance between the first predetermined clipping plane and the virtual camera, and the second coordinate position may be the distance between the second predetermined clipping plane and the virtual camera. The distance between the first predetermined clipping plane and the virtual camera is smaller than the distance between the second predetermined clipping plane and the virtual camera.
[0067] Optionally, the size of the target clipping plane can be calculated using the following formula:
[0068]
[0069] In the above formula, Z can be used to represent the original coordinate position of the two-dimensional original texture layer on the Z axis, D f It can be used to represent the distance between the near clipping plane and the virtual camera, D b It can be used to represent the distance between the far clipping plane and the virtual camera, H Z Can be used to indicate the size of the target clipping plane, H f Can be used to represent the size of the first predetermined clipping plane, H b It can be used to represent the size of the second predetermined clipping plane. For example, when adjusting the two-dimensional original texture layer, the two-dimensional original texture layer is preferably matched with the height of the virtual camera. Z Can be the height of the target clipping plane, H f Can be the height of the near clipping plane, H b Can be the height of the far clipping plane.
[0070] As an optional implementation, the method may further include determining a size of the first predetermined clipping plane based on the field of view angle of the virtual camera and the first coordinate position.
[0071] In this embodiment, it can be seen from the tangent trigonometric function that the ratio of half the size of the near clipping plane to the distance between the near clipping plane and the virtual camera is the tangent value of half the field of view angle. Therefore, the size of the first predetermined clipping plane can be calculated by the field of view angle of the virtual camera and the first coordinate position, where the field of view angle can be the Fov of the perspective camera, that is, the range that the perspective camera lens can cover.
[0072] Optionally, the size of the first predetermined clipping plane can be calculated using the following formula:
[0073]
[0074] In the above formula, H f It can be used to represent the size of the first predetermined clipping plane. For example, when adjusting the two-dimensional original texture layer, the two-dimensional original texture layer is prioritized to match the height of the virtual camera. f It can be the height of the first predetermined clipping plane, D f It can be used to represent the first coordinate position, that is, the distance between the first predetermined clipping plane and the virtual camera. Fov can be used to represent the field of view angle of the virtual camera.
[0075] As an optional implementation, the method may further include determining a size of a second predetermined clipping plane based on the field of view angle of the virtual camera and the second coordinate position.
[0076] In this embodiment, it can be seen from the tangent trigonometric function that the ratio of half the size of the far clipping plane to the distance between the far clipping plane and the virtual camera is also the tangent value of half the field of view angle. Therefore, the size of the second predetermined clipping plane can be calculated using the field of view angle of the virtual camera and the second coordinate position.
[0077] Optionally, the size of the second predetermined clipping plane can be calculated using the following formula:
[0078]
[0079] In the above formula, H b It can be used to represent the size of the second predetermined clipping plane. For example, when adjusting the two-dimensional original texture layer, the two-dimensional original texture layer is preferably matched with the height of the virtual camera. b It can be the height of the second predetermined clipping plane, D b It can be used to represent the second coordinate position, that is, the distance between the second predetermined clipping plane and the virtual camera. Fov can be used to represent the field of view angle of the virtual camera.
[0080] As an optional implementation, step S206, based on the size adjustment parameter, adjusts the original size of the two-dimensional original texture layer to the target size, including: adjusting the original size according to the size adjustment parameter to obtain the target size that is the same as the size of the target clipping plane.
[0081] In this embodiment, the original sizes of multiple two-dimensional original texture layers can be adjusted respectively according to the obtained size adjustment parameters, and adjusted to a target size that is the same as the size of the target clipping plane, wherein the target size is positively correlated with the distance between the original coordinate position and the virtual camera, that is, as the distance between the two-dimensional original texture layer and the virtual camera goes from near to far, the target size corresponding to the two-dimensional original texture layer becomes larger and larger.
[0082] Optionally, when adjusting the original sizes of the multiple two-dimensional original texture layers, they may be scaled accordingly according to the obtained size adjustment parameters, for example, by multiplying, dividing, adding or subtracting the original sizes, which is not specifically limited here.
[0083] For example, when adjusting the original sizes of multiple two-dimensional original texture layers to the target size, the two-dimensional original texture layers are preferably matched with the height of the virtual camera. The height of the original size is 10 cm, and the size adjustment parameter is 5. When the size adjustment parameter is a ratio, adjusting the original size can be multiplying or dividing the original size by the size adjustment parameter, that is, if 10 is multiplied by 5, the target size is 50 cm, and if 10 is divided by 5, the target size is 2 cm. When the size adjustment parameter is a difference, adjusting the original size can be adding or subtracting the original size from the size adjustment parameter, that is, if 10 is added to 5, the target size is 15 cm, and if 10 is subtracted from 5, the target size is 5 cm.
[0084] Optionally, if the original size of the two-dimensional original texture layer is exactly the same as the target size, then when the size adjustment parameter is the ratio of the size of the target clipping plane of the two-dimensional original texture layer to the original size, the value of the size adjustment parameter is 1; when the size adjustment parameter is the difference between the size of the target clipping plane of the two-dimensional original texture layer and the original size, the value of the size adjustment parameter is 0.
[0085] As an optional implementation, step S208, generating a three-dimensional virtual scene background based on the target texture layer, includes: in response to the original coordinate position remaining unchanged, constructing the target texture layer corresponding to each two-dimensional original texture layer into a three-dimensional virtual scene background.
[0086] In this embodiment, after the original sizes of multiple two-dimensional original texture layers are adjusted to target sizes according to the obtained size adjustment parameters, a target texture layer corresponding to each two-dimensional original texture layer is obtained, and the original coordinate position is kept unchanged. The generated multiple target texture layers can be constructed as a three-dimensional virtual scene background at the original coordinate position of the two-dimensional original texture layer.
[0087] As an optional embodiment, the method may also include, multiple two-dimensional original texture layers corresponding to multiple target texture layers, wherein, based on the target texture layer corresponding to each two-dimensional original texture layer, a three-dimensional virtual scene background is generated, including: special effects data between each adjacent target texture layer in the multiple target texture layers, and the target texture layer corresponding to each two-dimensional original texture layer, are constructed into a three-dimensional virtual scene background.
[0088] In this embodiment, based on the special effect data between each adjacent target texture layer, special effect data is added at the required position between each adjacent target texture layer in multiple target texture layers, and then based on the target texture layer corresponding to each two-dimensional original texture layer, a three-dimensional virtual scene background is constructed to enhance the spatial sense of the three-dimensional virtual scene background and enrich the performance effect of the three-dimensional virtual scene background. Among them, the special effect data can be used to generate special effects in the three-dimensional virtual scene background, and the special effect can be a motion effect.
[0089] Optionally, the position of adding special effects between each adjacent target texture layer in the multiple target texture layers can be determined according to the scene construction requirements, and is not specifically limited here.
[0090] As an optional embodiment, the method may further include: the original size includes the original width of the two-dimensional original texture layer and the original height of the two-dimensional original texture layer, the size of the clipping plane in the clipping space includes the target width of the clipping plane in the clipping space and the target height of the clipping plane in the clipping space, and the ratio between the original width and the original height is greater than the ratio between the target width and the target height.
[0091] In this embodiment, the original size of the two-dimensional original texture layer may include the original width of the two-dimensional original texture layer and the original height of the two-dimensional original texture layer, the size of the clipping plane in the clipping space may include the target width of the clipping plane in the clipping space and the target height of the clipping plane in the clipping space, the ratio between the original width and the original height is greater than the ratio between the target width and the target height, so that the content of the generated three-dimensional virtual scene background can be displayed in the picture of the virtual camera of the widest model without leakage in the width direction, that is, avoiding the situation where the content of the three-dimensional virtual scene background in the width direction does not fill the picture of the virtual camera in the width direction, wherein the unfilled part can be expressed as a part filled with black, and the target width of the clipping plane and the target height of the clipping plane in the clipping space can be the width and height of the device screen used to display the three-dimensional virtual scene background.
[0092] It should be noted that, in the embodiment of the present application, adjusting the height of the two-dimensional original texture layer based on the size adjustment parameter is only an example to adapt to actual application scenarios and is not specifically limited here.
[0093] The technical solutions of the embodiments of the present application are further described below with reference to preferred implementation methods.
[0094] In a related technology, a virtual scene can be displayed by building a real three-dimensional (3D) scene, for example, a scene showing the skins of various characters in the Egg Party game. Figure 3 is a schematic diagram of a virtual scene generated according to a related technology of an embodiment of the present application, such as Figure 3 As shown, when building a scene with this method, it is necessary to design a display scene layout and produce component models required for the corresponding scene. The model reuse rate is low, resulting in high labor costs for scene construction. In addition, the large number of high-polygon components in the scene and the rendering-related consumption will also affect the game performance.
[0095] In another related technology, a virtual scene can be displayed through a single background texture layer, for example, the game scene displayed in the King of Glory game. Figure 4 is a schematic diagram of a virtual scene generated according to another related technology of an embodiment of the present application, such as Figure 4 As shown, a single texture layer will cause the display scene to lack a sense of three-dimensionality, making the display effect rather stiff. In addition, in order to make the texture layer adapt to the camera screen size, the position and size of the texture layer need to be manually adjusted, which not only leads to low matching accuracy between the screen size and the texture layer, but also there is a technical problem that the virtual scene background lacks a sense of three-dimensionality.
[0096] However, this embodiment of the present application provides a method for generating a virtual scene based on multi-layer textures. The method uses multi-layer textures in combination with special effects between texture layers to achieve a pseudo 3D effect. In order to make each layer of texture adapt to the camera screen size, a camera frustum model is constructed through the relevant parameters of the scene perspective camera. The accurate position information and corresponding size of each layer of texture are then calculated, and then the position of each layer of texture relative to the scene perspective camera is adjusted, thereby solving the technical problems of low matching accuracy between the screen size and the texture layer, and lack of three-dimensional sense of the virtual scene background.
[0097] The above method provided in this embodiment of the present application is further introduced below. The method may include the following four parts.
[0098] In the first part, the prepared multiple texture layers are unified into the same size, and the center position of each texture layer is at its geometric center, and each texture layer is arranged on the same axis as the in-game perspective camera.
[0099] Optionally, the uniform aspect ratio of the same size must meet the requirements of the widest model to avoid leakage of the generated virtual scene in different models.
[0100] Figure 5 is a schematic diagram of a plurality of texture layers being unified into the same size according to an embodiment of the present application, such as Figure 5 As shown, texture layer 1, texture layer 2 and texture layer 3 are of the same size, and texture layer 1, texture layer 2 and texture layer 3 are arranged on the same axis (for example, Z axis) as perspective camera 4. That is, the geometric center of each texture layer and the perspective camera are both on the Z axis, and each texture layer is arranged from near to far according to the position relationship along the camera ray direction.
[0101] Figure 6 is a schematic diagram of a texture layer of a default size within the camera's viewing angle according to an embodiment of the present application, such as Figure 6 As shown, within the perspective camera angle of view, the default sizes of texture layer 1, texture layer 2, and texture layer 3 do not match the camera image, and the relative sizes and positions of the layers are disordered.
[0102] In the second part, we obtain the setting parameters of the perspective camera: FOV, near clipping plane distance, far clipping plane distance, and screen aspect ratio, and use them to build the perspective camera's viewing cone model.
[0103] Figure 7 is a schematic diagram of a viewing cone model of a perspective camera according to an embodiment of the present application, such as Figure 7 As shown, point A is located at perspective camera 1, point B is located at near clipping plane 3, and point C is located at far clipping plane 4. Field of view angle 2 represents the FOV of perspective camera 1, and the black solid line on near clipping plane 3 represents the width of near clipping plane 3 (Width front, Wf ), the black dotted line indicates the height of the near clipping surface 3 (High front, H f ), point A to point B on the near clipping surface 3, that is, line segment AB, represents the distance from the near clipping surface (Distancefront, D f ), the black solid line on the far clipping plane 4 represents the width of the far clipping plane 4 (Width back, W b ), the black dotted line indicates the height of the far clipping plane 4 (High back, H b ), point A to point C on the far clipping plane 4, that is, line segment AC, represents the distance back to the far clipping plane (Distance back, D b ).
[0104] In order to facilitate understanding of the calculation principle and calculation process of the embodiment of the present application, the embodiment of the present application also provides a side view of the cone model. Figure 8 is a schematic diagram of a side view of a viewing cone model of a perspective camera according to an embodiment of the present application, such as Figure 8 As shown, point A is located at perspective camera 1, field of view angle 2 represents the FOV of perspective camera 1, the black solid line represents the near clipping plane 3, point B is located at the near clipping plane 3, and the length of the black solid line represents the height H of the near clipping plane 3. f , the black dotted line represents the far clipping plane 4, point C is located on the far clipping plane 4, and the length of the black dotted line represents the height H of the far clipping plane 4 b , line segment AB represents the distance D from the near clipping surface f , line segment AC represents the distance D from the far clipping plane b .
[0105] From the tangent trigonometric function, we know that the ratio of half the height of the near clipping plane to the distance to the near clipping plane is the tangent value of half the field of view angle, which can be expressed by the following formula:
[0106]
[0107] The height H of the near clipping surface can be obtained by the above formula f , that is,
[0108]
[0109] In the above formula, tan can be used to represent the tangent function, Fov can be used to represent the field of view, H f Can be used to represent the height of the near clipping plane, D f Can be used to represent the near clipping plane distance.
[0110] Similarly, the ratio of half the height of the far clipping plane to the distance to the far clipping plane is also the tangent of half the field of view angle, which can be expressed by the following formula:
[0111]
[0112] The height H of the far clipping plane can be obtained by the above formula b , that is,
[0113]
[0114] In the above formula, H b Can be used to represent the height of the far clipping plane, D b Can be used to represent the far clipping plane distance.
[0115] Since the aspect ratio of the perspective camera is a camera setting parameter, the width of the near clipping plane and the width of the far clipping plane can be solved according to the camera aspect ratio formula, that is,
[0116]
[0117] In the above formula, Ratio can be used to represent the aspect ratio of the perspective camera, W can be used to represent the width of the perspective camera image, for example, the width of the near clipping plane or the width of the far clipping plane, and H can be used to represent the height of the perspective camera image, for example, the height of the near clipping plane or the height of the far clipping plane.
[0118] It should be noted that the method for solving the width value of the near clipping plane and the width value of the far clipping plane is an extension of the embodiment of the present application, and the solved width value of the near clipping plane and the width value of the far clipping plane are not applied in the embodiment of the present application.
[0119] The third part sets the position of each texture layer on the Z axis according to the position relationship of each texture layer.
[0120] Figure 9 is a schematic diagram of the position of a texture layer in a viewing cone model according to an embodiment of the present application, such as Figure 9 As shown, the black solid line represents the near clipping plane, the black dotted line represents the far clipping plane, the position of the perspective camera 4 is at the zero point of the Z axis, the position of texture layer 1 (Layer 1) is Z1, the position of texture layer 1 (Layer 2) is Z2, and the position of texture layer 3 (Layer 3) is Z3.
[0121] In order to make each texture layer accurately adapt to the size of the perspective camera screen, it is necessary to adjust the size of each texture layer at the corresponding position. According to the principle of similar triangles and the principle of linear mapping, the formula for calculating the size of the texture layer is as follows:
[0122]
[0123] In the above formula, H Z It can be used to indicate the height that the texture layer should have at the corresponding position, Hf Can be used to represent the height of the near clipping plane, H b It can be used to indicate the height of the far clipping plane, Z can be used to indicate the corresponding position of the texture layer on the Z axis, D f Can be used to indicate the distance to the near clipping plane, D b Can be used to represent the distance of the far clipping plane.
[0124] After obtaining the height that the texture layer should have at the corresponding position, the corresponding scaling factor can be obtained by the ratio of the height that the texture layer should have at this position to its original height, which can be expressed by the following formula:
[0125]
[0126] In the above formula, H o Can be used to represent the original height of the texture layer, S Z Can be used to indicate the corresponding scaling factor.
[0127] Figure 10 is a schematic diagram of each texture layer after the size is modified according to the scaling factor at the corresponding position according to an embodiment of the present application, such as Figure 10 As shown, the texture layers 1, 2 and 3 are resized according to the scaling factors at the corresponding positions. Figure 11 This is a schematic diagram of the image within the camera's field of view after each texture layer is resized according to the scaling factor at the corresponding position according to an embodiment of the present application, such as Figure 11 As shown, each texture layer accurately matches the perspective camera image.
[0128] Optionally, each texture layer whose size is modified according to the scaling factor at the corresponding position remains at the corresponding original position and satisfies the rule of increasing size from near to far.
[0129] In the fourth part, add special effects at the desired locations between the texture layers.
[0130] Figure 12 is a schematic diagram of generating a virtual scene effect according to an embodiment of the present application, such as Figure 12 As shown, after adjusting the size of each texture layer according to the scaling factor at the corresponding position, special effects can be added between the texture layers according to the scene construction requirements to enhance the spatial sense of the scene and enrich the scene performance effect.
[0131] The beneficial effects brought about by the technical solution of the embodiment of the present application may include: avoiding the problems of excessively high costs and high performance consumption caused by constructing a three-dimensional display scene, and achieving effects that meet requirements; avoiding the problems of low efficiency and low precision caused by traditional manual adjustment of the parameters of each texture layer, and automatically calculating the accurate position information and corresponding size of each texture layer, so that each texture layer can accurately adapt to the camera screen size.
[0132] In an embodiment of the present application, a camera frustum model is constructed based on the relevant parameters of the scene perspective camera, and then the accurate position information and corresponding size of each layer of texture are calculated. Finally, the position of each layer of texture relative to the scene perspective camera is adjusted, and special effects are added between texture layers. This technical solution solves the technical problem of the lack of three-dimensional sense in the virtual scene background and achieves the technical effect of enhancing the three-dimensional sense of the virtual scene background.
[0133] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus the necessary general hardware platform, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present application.
[0134] In this embodiment, a display device for a three-dimensional model of a game character is also provided. The device is used to implement the above-mentioned embodiments and preferred embodiments, and the details already described will not be repeated. As used below, the terms "unit" and "module" may refer to a combination of software and / or hardware that implements a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, implementation using hardware, or a combination of software and hardware, is also possible and contemplated.
[0135] Figure 13 is a schematic diagram of a display device for a three-dimensional model of a game character according to an embodiment of the present application, such as Figure 13 As shown, the display device 1300 for the three-dimensional model of the game character includes: a determination and acquisition unit 1301 , an acquisition unit 1302 , an adjustment unit 1303 and a generation unit 1304 .
[0136] A determination unit 1301 is used to determine a target three-dimensional model and multiple preset two-dimensional original texture layers, wherein the multiple two-dimensional original texture layers are superimposed and rendered to generate a three-dimensional virtual scene background for displaying the target three-dimensional model. The multiple two-dimensional original texture layers have the same original size and are located in the coordinate system of the virtual camera's viewing frustum.
[0137] The acquiring unit 1302 is configured to acquire a size adjustment parameter of the two-dimensional original texture layer within the viewing frustum based on the relative position between the two-dimensional original texture layer and the virtual camera.
[0138] The adjusting unit 1303 is configured to adjust the original size of the two-dimensional original texture layer to a target size based on the size adjustment parameter to obtain a target texture layer, wherein the target texture layer matches the size of the clipping plane in the clipping space, and the clipping space is determined based on the viewing frustum.
[0139] The generating unit 1304 is configured to generate a three-dimensional virtual scene background based on the target texture layer, and display the target three-dimensional model in the three-dimensional virtual scene background.
[0140] Optionally, the acquiring unit 1302 includes: an acquiring module, configured to acquire a size adjustment parameter based on an original coordinate position of a center of the two-dimensional original texture layer on a coordinate axis, wherein the relative position includes the original coordinate position.
[0141] Optionally, the acquisition module includes: a first determination submodule, used to determine the size of the target clipping plane corresponding to the original coordinate position in the clipping space; and a second determination submodule, used to determine the size adjustment parameter based on the size of the target clipping plane and the original size.
[0142] Optionally, the first determination submodule is further used to determine the size of the target clipping plane corresponding to the original coordinate position in the clipping space through the following steps: determining a first predetermined clipping plane and a second predetermined clipping plane in the clipping space, wherein the distance between the first predetermined clipping plane and the virtual camera is smaller than the distance between the second predetermined clipping plane and the virtual camera; determining the size of the target clipping plane based on the size of the first predetermined clipping plane, the size of the second predetermined clipping plane, the first coordinate position of the center of the first predetermined clipping plane on the coordinate axis, the second coordinate position of the center of the second predetermined clipping plane on the coordinate axis, and the original coordinate position.
[0143] Optionally, the first determining submodule is further configured to determine a size of the first predetermined clipping plane based on the field of view angle and the first coordinate position of the virtual camera.
[0144] Optionally, the first determining submodule is further configured to determine a size of the second predetermined clipping plane based on the field of view angle of the virtual camera and the second coordinate position.
[0145] Optionally, the adjusting unit 1303 includes: an adjusting module, configured to adjust the original size according to the size adjustment parameter to obtain a target size that is the same as the size of the target clipping plane, wherein the target size is positively correlated with the distance between the original coordinate position and the virtual camera.
[0146] Optionally, the generating unit 1304 includes: a first constructing module, configured to construct a target texture layer corresponding to each two-dimensional original texture layer as a virtual scene background in response to the original coordinate position remaining unchanged.
[0147] Optionally, the generation unit 1304 includes: a second construction module, used to construct special effect data between each adjacent target texture layer in multiple target texture layers, and the target texture layer corresponding to each two-dimensional original texture layer, into a virtual scene background, wherein the special effect data is used to generate special effects in the virtual scene background.
[0148] Optionally, the original size includes the original width of the two-dimensional original texture layer and the original height of the two-dimensional original texture layer, the size of the clipping plane in the clipping space includes the target width of the clipping plane in the clipping space and the target height of the clipping plane in the clipping space, and the ratio between the original width and the original height is greater than the ratio between the target width and the target height.
[0149] In the display device for the three-dimensional model of a game character in this embodiment, a determination unit is used to determine a target three-dimensional model and multiple preset two-dimensional original texture layers, wherein the multiple two-dimensional original texture layers are generated by superimposed rendering to generate a three-dimensional virtual scene background for displaying the target three-dimensional model, and the original sizes of the multiple two-dimensional original texture layers are the same and are located in the coordinate system of the virtual camera's viewing frustum; an acquisition unit is used to obtain a size adjustment parameter of the two-dimensional original texture layer within the viewing frustum based on the relative position between the two-dimensional original texture layer and the virtual camera; an adjustment unit is used to adjust the original size of the two-dimensional original texture layer to a target size based on the size adjustment parameter to obtain a target texture layer, wherein the target texture layer matches the size of a clipping plane in a clipping space, and the clipping space is determined based on the viewing frustum; a generation unit is used to generate a three-dimensional virtual scene background based on the target texture layer, and display the target three-dimensional model in the three-dimensional virtual scene background, thereby solving the technical problem that the generated virtual scene background lacks three-dimensional sense and achieving the technical effect of enhancing the three-dimensional sense of the virtual scene background.
[0150] It should be noted that the above-mentioned units and modules can be implemented through software or hardware. For the latter, it can be implemented in the following ways, but not limited to this: the above-mentioned units and modules are all located in the same processor; or the above-mentioned units and modules are located in different processors in any combination.
[0151] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored. The computer program is configured to execute the steps of any of the above method embodiments when run.
[0152] Optionally, in this embodiment, the above-mentioned computer-readable storage medium may include but is not limited to: a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and other media that can store computer programs.
[0153] Optionally, in this embodiment, the computer-readable storage medium may be located in any computer terminal in a computer terminal group in a computer network, or in any terminal device in a terminal device group.
[0154] Optionally, in this embodiment, the computer-readable storage medium may be configured to store a computer program for performing the following steps:
[0155] S1, determining a target 3D model and a plurality of preset 2D original texture layers, wherein the plurality of 2D original texture layers are overlaid and rendered to generate a 3D virtual scene background for displaying the target 3D model, wherein the plurality of 2D original texture layers have the same original size and are located in a coordinate system where a viewing frustum of a virtual camera is located;
[0156] S2, obtaining a size adjustment parameter of the two-dimensional original texture layer within the viewing frustum based on the relative position between the two-dimensional original texture layer and the virtual camera;
[0157] S3, based on the size adjustment parameter, adjusting the original size of the two-dimensional original texture layer to a target size to obtain a target texture layer, wherein the target texture layer matches the size of a clipping plane in a clipping space, and the clipping space is determined based on a viewing frustum;
[0158] S4, generating a three-dimensional virtual scene background based on the target texture layer, and displaying the target three-dimensional model in the three-dimensional virtual scene background.
[0159] Optionally, the computer-readable storage medium is further configured to store program code for executing the following steps: obtaining a size adjustment parameter based on an original coordinate position of the center of the two-dimensional original texture layer on a coordinate axis, wherein the relative position includes the original coordinate position.
[0160] Optionally, the computer-readable storage medium is further configured to store program code for executing the following steps: determining the size of a target clipping plane corresponding to the original coordinate position in the clipping space; and determining a size adjustment parameter based on the size of the target clipping plane and the original size.
[0161] Optionally, the above-mentioned computer-readable storage medium is also configured to store program code for performing the following steps: determining a first predetermined clipping plane and a second predetermined clipping plane in the clipping space, wherein the distance between the first predetermined clipping plane and the virtual camera is smaller than the distance between the second predetermined clipping plane and the virtual camera; determining the size of the target clipping plane based on the size of the first predetermined clipping plane, the size of the second predetermined clipping plane, the first coordinate position of the center of the first predetermined clipping plane on the coordinate axis, the second coordinate position of the center of the second predetermined clipping plane on the coordinate axis, and the original coordinate position.
[0162] Optionally, the computer-readable storage medium is further configured to store program codes for executing the following steps: determining a size of a first predetermined clipping plane based on a field of view angle of the virtual camera and a first coordinate position.
[0163] Optionally, the computer-readable storage medium is further configured to store program codes for executing the following steps: determining a size of a second predetermined clipping plane based on the field of view angle of the virtual camera and the second coordinate position.
[0164] Optionally, the computer-readable storage medium is further configured to store program code for performing the following steps: adjusting the original size according to the size adjustment parameter to obtain a target size that is the same as the size of the target clipping plane, wherein the target size is positively correlated with the distance between the original coordinate position and the virtual camera.
[0165] Optionally, the computer-readable storage medium is further configured to store program codes for executing the following steps: in response to the original coordinate position remaining unchanged, constructing a target texture layer corresponding to each two-dimensional original texture layer as a virtual scene background.
[0166] Optionally, the computer-readable storage medium is further configured to store program code for executing the following steps: constructing special effect data between each adjacent target texture layer in multiple target texture layers, and the target texture layer corresponding to each two-dimensional original texture layer into a virtual scene background, wherein the special effect data is used to generate special effects in the virtual scene background.
[0167] Optionally, the original size includes the original width of the two-dimensional original texture layer and the original height of the two-dimensional original texture layer, the size of the clipping plane in the clipping space includes the target width of the clipping plane in the clipping space and the target height of the clipping plane in the clipping space, and the ratio between the original width and the original height is greater than the ratio between the target width and the target height.
[0168] In the computer-readable storage medium of this embodiment, a target three-dimensional model and multiple preset original texture layers are determined; a viewing cone model is established based on the construction parameters of a virtual camera; and then, based on the relative position between the two-dimensional original texture layer and the virtual camera, a size adjustment parameter of the two-dimensional original texture layer within the viewing cone is obtained; based on the size adjustment parameter, the original size of the two-dimensional original texture layer is adjusted to the target size to obtain the target texture layer; and a virtual scene is generated based on the target texture layer corresponding to each two-dimensional original texture layer. In other words, the embodiment of the present application can automatically adjust the original size of each two-dimensional original texture layer using the preset size adjustment parameter of the two-dimensional original texture layer within the viewing cone to obtain the target texture layer, and finally generate a three-dimensional virtual scene background based on the target texture layer corresponding to the two-dimensional original texture layer, thereby solving the technical problem of the virtual scene background lacking a three-dimensional sense and achieving the technical effect of enhancing the three-dimensional sense of the virtual scene background.
[0169] Through the description of the above embodiments, it is easy for those skilled in the art to understand that the example embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solution according to the embodiments of the present application can be embodied in the form of a software product, which can be stored in a computer-readable storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which can be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the embodiments of the present application.
[0170] In an exemplary embodiment of the present application, a computer-readable storage medium stores a program product capable of implementing the above-described method of the present embodiment. In some possible implementations, various aspects of the present embodiment can also be implemented in the form of a program product, which includes program code. When the program product is executed on a terminal device, the program code is used to cause the terminal device to execute the steps described in the "Exemplary Method" section of the present embodiment according to various exemplary implementations of the present application.
[0171] According to the program product for implementing the above method according to the embodiment of the present application, it can adopt a portable compact disc read-only memory (CD-ROM) and include program code, and can be run on a terminal device, such as a personal computer. However, the program product of the embodiment of the present application is not limited thereto. In the embodiment of the present application, the computer-readable storage medium can be any tangible medium containing or storing a program, and the program can be used by or in combination with an instruction execution system, apparatus, or device.
[0172] The program product may be implemented in any combination of one or more computer-readable media. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or any combination thereof. More specific examples (non-exhaustive) of computer-readable storage media include: an electrical connection having one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof.
[0173] It should be noted that the program code contained in the computer-readable storage medium can be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any appropriate combination of the above.
[0174] An embodiment of the present application further provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0175] Optionally, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.
[0176] Optionally, in this embodiment, the processor may be configured to execute the following steps through a computer program:
[0177] S1, determining a target 3D model and a plurality of preset 2D original texture layers, wherein the plurality of 2D original texture layers are overlaid and rendered to generate a 3D virtual scene background for displaying the target 3D model, wherein the plurality of 2D original texture layers have the same original size and are located in a coordinate system where a viewing frustum of a virtual camera is located;
[0178] S2, obtaining a size adjustment parameter of the two-dimensional original texture layer within the viewing frustum based on the relative position between the two-dimensional original texture layer and the virtual camera;
[0179] S3, based on the size adjustment parameter, adjusting the original size of the two-dimensional original texture layer to a target size to obtain a target texture layer, wherein the target texture layer matches the size of a clipping plane in a clipping space, and the clipping space is determined based on a viewing frustum;
[0180] S4, generating a three-dimensional virtual scene background based on the target texture layer, and displaying the target three-dimensional model in the three-dimensional virtual scene background.
[0181] Optionally, the processor may be further configured to perform the following steps through a computer program: obtaining a size adjustment parameter based on an original coordinate position of the center of the two-dimensional original texture layer on a coordinate axis, wherein the relative position includes the original coordinate position.
[0182] Optionally, the processor may be configured to execute the following steps through a computer program: determining the size of a target clipping plane corresponding to the original coordinate position in the clipping space; and determining a size adjustment parameter based on the size of the target clipping plane and the original size.
[0183] Optionally, the above-mentioned processor can also be configured to perform the following steps through a computer program: determining a first predetermined clipping plane and a second predetermined clipping plane in the clipping space, wherein the distance between the first predetermined clipping plane and the virtual camera is smaller than the distance between the second predetermined clipping plane and the virtual camera; determining the size of the target clipping plane based on the size of the first predetermined clipping plane, the size of the second predetermined clipping plane, the first coordinate position of the center of the first predetermined clipping plane on the coordinate axis, the second coordinate position of the center of the second predetermined clipping plane on the coordinate axis, and the original coordinate position.
[0184] Optionally, the processor may be further configured to perform the following steps through a computer program: determining a size of a first predetermined clipping plane based on a field of view angle of the virtual camera and a first coordinate position.
[0185] Optionally, the processor may be further configured to execute the following steps through a computer program: determining a size of the second predetermined clipping plane based on the field of view angle of the virtual camera and the second coordinate position.
[0186] Optionally, the above-mentioned processor can also be configured to perform the following steps through a computer program: adjust the original size according to the size adjustment parameter to obtain a target size that is the same as the size of the target clipping plane, wherein the target size is positively correlated with the distance between the original coordinate position and the virtual camera.
[0187] Optionally, the processor may be further configured to execute the following steps through a computer program: in response to the original coordinate position being unchanged, constructing a target texture layer corresponding to each two-dimensional original texture layer as a virtual scene background.
[0188] Optionally, the above-mentioned processor can also be configured to perform the following steps through a computer program: constructing special effects data between each adjacent target texture layer in multiple target texture layers, and the target texture layer corresponding to each two-dimensional original texture layer into a virtual scene background, wherein the special effects data is used to generate special effects in the virtual scene background.
[0189] Optionally, the original size includes the original width of the two-dimensional original texture layer and the original height of the two-dimensional original texture layer, the size of the clipping plane in the clipping space includes the target width of the clipping plane in the clipping space and the target height of the clipping plane in the clipping space, and the ratio between the original width and the original height is greater than the ratio between the target width and the target height.
[0190] In the electronic device of this embodiment, a target three-dimensional model and multiple preset original texture layers are determined; a viewing cone model is established based on the construction parameters of a virtual camera; and then, based on the relative position between the two-dimensional original texture layer and the virtual camera, a size adjustment parameter of the two-dimensional original texture layer within the viewing cone is obtained; based on the size adjustment parameter, the original size of the two-dimensional original texture layer is adjusted to the target size to obtain the target texture layer; and a virtual scene is generated based on the target texture layer corresponding to each two-dimensional original texture layer. In other words, the embodiment of the present application can automatically adjust the original size of each two-dimensional original texture layer using the preset size adjustment parameter of the two-dimensional original texture layer within the viewing cone to obtain the target texture layer, and finally generate a three-dimensional virtual scene background based on the target texture layer corresponding to the two-dimensional original texture layer, thereby solving the technical problem of the virtual scene background lacking a three-dimensional sense and achieving the technical effect of enhancing the three-dimensional sense of the virtual scene background.
[0191] Figure 14 Schematic diagram of an electronic device according to an embodiment of the present application. Figure 14 As shown, the electronic device 1400 is merely an example and should not limit the functions and scope of use of the embodiments of the present application.
[0192] like Figure 14 As shown, electronic device 1400 is implemented as a general-purpose computing device. Components of electronic device 1400 may include, but are not limited to, at least one processor 1410, at least one memory 1420, a bus 1430 connecting various system components (including memory 1420 and processor 1410), and a display 1440.
[0193] The memory 1420 stores program code, which can be executed by the processor 1410, so that the processor 1410 executes the steps described in the method section of the embodiment of the present application according to various exemplary embodiments of the present application.
[0194] The memory 1420 may include a readable medium in the form of a volatile storage unit, such as a random access memory unit (RAM) 14201 and / or a cache memory unit 14202, and may further include a read-only memory unit (ROM) 14203, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory.
[0195] In some examples, memory 1420 may also include a program / utility 14204 having a set (at least one) of program modules 14205. Such program modules 14205 include, but are not limited to, an operating system, one or more application programs, other program modules, and program data. Each or some combination of these examples may include an implementation of a network environment. Memory 1420 may further include memory remotely located relative to processor 1410. These remote memories may be connected to electronic device 1400 via a network. Examples of such networks include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0196] The bus 1430 may represent one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a local bus to the processor 1410, or any of a variety of bus architectures.
[0197] The display 1440 may be, for example, a touch screen liquid crystal display (LCD) that enables a user to interact with a user interface of the electronic device 1400 .
[0198] Optionally, the electronic device 1400 may also communicate with one or more external devices 1400 (e.g., a keyboard, a pointing device, a Bluetooth device, etc.), one or more devices that enable a user to interact with the electronic device 1400, and / or any device that enables the electronic device 1400 to communicate with one or more other computing devices (e.g., a router, a modem, etc.). Such communication may be performed through an input / output (I / O) interface 1450. Furthermore, the electronic device 1400 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) through a network adapter 1460. Figure 14 As shown, the network adapter 1460 communicates with other modules of the electronic device 1400 via the bus 1430. Figure 14 Not shown, other hardware and / or software modules may be used in conjunction with electronic device 1400, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0199] The electronic device 1400 may further include: a keyboard, a cursor control device (such as a mouse), an input / output interface (I / O interface), a network interface, a power supply and / or a camera.
[0200] It can be understood by those skilled in the art that Figure 14The structure shown is only for illustration and does not limit the structure of the above electronic device. Figure 14 More or fewer components than shown, or with Figure 1 The memory 1420 may be used to store computer programs and corresponding data, such as the computer programs and corresponding data corresponding to the methods in the embodiments of the present application. The processor 1410 executes the computer programs stored in the memory 1420 to perform various functional applications and data processing, thereby implementing the above-mentioned methods.
[0201] The serial numbers of the above embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0202] In the above embodiments of the present application, the description of each embodiment has its own focus. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.
[0203] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only exemplary. For example, the division of the units can be a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0204] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0205] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0206] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for enabling a computer device (which can be a personal computer, a server or a network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.
[0207] The above is only a preferred embodiment of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A method for displaying a three-dimensional model of a game character, characterized in that: include: Determining a target three-dimensional model and a plurality of preset two-dimensional original texture layers, wherein the plurality of two-dimensional original texture layers are overlaid and rendered to generate a three-dimensional virtual scene background for displaying the target three-dimensional model, wherein the plurality of two-dimensional original texture layers have the same original size and are located in a coordinate system where a viewing frustum of a virtual camera is located; Based on the relative position between the two-dimensional original texture layer and the virtual camera, obtaining a size adjustment parameter of the two-dimensional original texture layer within the viewing frustum; resizing the original size of the two-dimensional original texture layer to a target size based on the size adjustment parameter to obtain a target texture layer, wherein the target texture layer matches a size of a clipping plane in a clipping space determined based on the viewing frustum; generating the three-dimensional virtual scene background based on the target texture layer, and displaying the target three-dimensional model in the three-dimensional virtual scene background; The centers of the plurality of two-dimensional original texture layers are located on the same coordinate axis of the coordinate system, and the virtual camera is located at the origin of the coordinate axis; The acquiring, based on the relative position between the two-dimensional original texture layer and the virtual camera, a size adjustment parameter of the two-dimensional original texture layer within the viewing frustum includes: acquiring the size adjustment parameter based on an original coordinate position of a center of the two-dimensional original texture layer on the coordinate axis, wherein the relative position includes the original coordinate position.
2. The method according to claim 1, characterized in that Acquiring a size adjustment parameter of the two-dimensional original texture layer within the visual frustum based on the original coordinate position of the center of the two-dimensional original texture layer on the coordinate axis includes: Determining, within the clipping space, the size of the target clipping plane corresponding to the original coordinate position; The resizing parameter is determined based on the size of the target clipping plane and the original size.
3. The method according to claim 2, characterized in that Determining, within the clipping space, a size of a target clipping plane corresponding to the original coordinate position, comprising: Determining a first predetermined clipping plane and a second predetermined clipping plane in the clipping space, wherein a distance between the first predetermined clipping plane and the virtual camera is smaller than a distance between the second predetermined clipping plane and the virtual camera; Determine the size of the target clipping plane based on the size of the first predetermined clipping plane, the size of the second predetermined clipping plane, the first coordinate position of the center of the first predetermined clipping plane on the coordinate axis, the second coordinate position of the center of the second predetermined clipping plane on the coordinate axis, and the original coordinate position.
4. The method according to claim 3, characterized in that The method further comprises: The size of the first predetermined clipping plane is determined based on the field of view angle of the virtual camera and the first coordinate position.
5. The method according to claim 3, characterized in that The method further comprises: The size of the second predetermined clipping plane is determined based on the field of view angle of the virtual camera and the second coordinate position.
6. The method according to claim 2, characterized in that Adjusting the original size of the two-dimensional original texture layer to a target size based on the size adjustment parameter includes: The original size is adjusted according to the size adjustment parameter to obtain the target size that is the same as the size of the target clipping plane, wherein the target size is positively correlated with the distance between the original coordinate position and the virtual camera.
7. The method according to claim 1, characterized in that Generating the three-dimensional virtual scene background based on the target texture layer includes: In response to the original coordinate position being unchanged, the target texture layers respectively corresponding to the plurality of two-dimensional original texture layers are constructed as the three-dimensional virtual scene background.
8. The method according to claim 1, characterized in that The plurality of two-dimensional original texture layers correspond to the plurality of target texture layers, wherein generating the three-dimensional virtual scene background based on the target texture layers includes: The special effect data between each adjacent target texture layer in the plurality of target texture layers and the target texture layer corresponding to each two-dimensional original texture layer are constructed into the three-dimensional virtual scene background, wherein the special effect data is used to generate the special effects in the three-dimensional virtual scene background.
9. The method according to any one of claims 1 to 8, characterized in that The original size includes the original width of the two-dimensional original texture layer and the original height of the two-dimensional original texture layer, the size of the clipping plane in the clipping space includes the target width of the clipping plane in the clipping space and the target height of the clipping plane in the clipping space, and the ratio between the original width and the original height is greater than the ratio between the target width and the target height.
10. A display device for a three-dimensional model of a game character, characterized in that: include: a determining unit, configured to determine a target three-dimensional model and a plurality of preset two-dimensional original texture layers, wherein the plurality of two-dimensional original texture layers are used to generate a three-dimensional virtual scene background for displaying the target three-dimensional model through overlay rendering, and the plurality of two-dimensional original texture layers have the same original size and are located in a coordinate system where a viewing frustum of a virtual camera is located; An acquiring unit, configured to acquire a size adjustment parameter of the two-dimensional original texture layer within the viewing frustum based on a relative position between the two-dimensional original texture layer and the virtual camera; an adjusting unit, configured to adjust an original size of the two-dimensional original texture layer to a target size based on the size adjustment parameter, to obtain a target texture layer, wherein the target texture layer matches a size of a clipping plane in a clipping space determined based on the viewing frustum; a generating unit, configured to generate the three-dimensional virtual scene background based on the target texture layer, and display the target three-dimensional model in the three-dimensional virtual scene background; The centers of the plurality of two-dimensional original texture layers are located on the same coordinate axis of the coordinate system, and the virtual camera is located at the origin of the coordinate axis; The acquisition unit is used to acquire a size adjustment parameter of the two-dimensional original texture layer within the viewing frustum based on the relative position between the two-dimensional original texture layer and the virtual camera through the following steps: acquiring the size adjustment parameter based on the original coordinate position of the center of the two-dimensional original texture layer on the coordinate axis, wherein the relative position includes the original coordinate position.
11. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, wherein the computer program is configured to execute the method according to any one of claims 1 to 9 when executed by a processor.
12. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to run the computer program to perform the method according to any one of claims 1 to 9.