Model rendering method and apparatus, storage medium, and electronic device
By setting the center point of the target model and determining the direction and angle of the rotation axis, the problem of cumbersome operation in closely fitting the animation model to the terrain is solved, and the model rendering efficiency is improved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-08
- Publication Date
- 2026-03-17
AI Technical Summary
In existing technologies, the process of closely integrating the animation model with the terrain is cumbersome, resulting in low model rendering efficiency.
The target model's pivot point is set by presetting height parameters, and the rotation axis direction and rotation angle are determined based on the first axis direction vector of the target model within the offset range and the normal vector of the scene terrain. Finally, the target model is rendered based on the rotation axis direction, rotation angle, and pivot point position.
It achieves a close adaptive fit between the target model and the scene terrain, improves model rendering efficiency, simplifies the operation process, and reduces the workload of model production.
Smart Images

Figure CN116309976B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and more specifically, to a model rendering method, apparatus, storage medium, and electronic device. Background Technology
[0002] Inverse Kinematics (IK) is a program used in 3D computer graphics animation. In IK, when the last node moves, the parameters of the nodes in the kinetic chain connected to it are automatically calculated to reach the desired position. Figure 1 This is a schematic diagram of a reverse motion in a related technology, such as... Figure 1 As shown, when a child node moves, its connected parent node is affected, resulting in displacement or rotation. IK technology can be widely used in the interaction between animated characters with animated skeletons and terrain, enabling the feet and legs of the animated character to interact correctly or dynamically with the terrain.
[0003] In related technologies, using IK functionality requires the creation of an animation skeleton, which necessitates setting a series of parameters for the animation model's actuators to ensure correct collision and positional relationships between the animation model and the terrain. However, the process of pre-creating animation skeletons and setting corresponding parameters for each animation model is cumbersome, and the workload of creating animation models is enormous, resulting in low model rendering efficiency.
[0004] There is currently no effective solution to the above problems.
[0005] It should be noted that the information disclosed in the background section above is only used to enhance the understanding of the background of this disclosure, and therefore may include information that does not constitute prior art known to those skilled in the art. Summary of the Invention
[0006] At least some embodiments of this application provide a model rendering method, apparatus, storage medium, and electronic device to at least solve the technical problem in the related art where the operation process for achieving close integration between the model and different terrains is cumbersome, resulting in low model rendering efficiency.
[0007] According to one embodiment of this application, a model rendering method is provided. The method includes: setting the pivot point position of a target model according to a preset height parameter, wherein the preset height parameter is used to determine the offset range of the target model; obtaining a first vector and a second vector, wherein the first vector is the first axis direction vector of the target model within the offset range, and the second vector is the normal vector of the scene terrain where the target model is located; determining the rotation axis direction and rotation angle of the target model based on the first vector and the second vector; and rendering the target model based on the rotation axis direction, rotation angle, and pivot point position.
[0008] According to one embodiment of this application, a model rendering apparatus is also provided. The apparatus includes: a setting module, configured to set the pivot point position of a target model according to a preset height parameter, wherein the preset height parameter is used to determine the offset range of the target model; an acquisition module, configured to acquire a first vector and a second vector, wherein the first vector is a first axis direction vector of the target model within the offset range, and the second vector is a normal vector of the terrain of the scene where the target model is located; a determination module, configured to determine the rotation axis direction and rotation angle of the target model based on the first vector and the second vector; and a rendering module, configured to render the target model based on the rotation axis direction, rotation angle, and pivot point position.
[0009] According to one embodiment of this application, a computer-readable storage medium is also provided, which stores a computer program, wherein the computer program is configured to execute the model rendering method described in any of the preceding claims at runtime.
[0010] According to one embodiment of this application, an electronic device is also provided, including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to perform the model rendering method of any of the above claims.
[0011] In at least some embodiments of this application, the pivot point position of the target model is set by a preset height parameter, and the rotation axis direction and rotation angle of the target model are determined based on the first axis direction vector of the target model within the offset range and the normal vector of the scene terrain where the target model is located. Finally, the target model is rendered based on the rotation axis direction, rotation angle and pivot point position, so as to make the target model adaptively and closely fit the scene terrain. This achieves the technical effect of improving the model rendering efficiency, and solves the technical problem of low model rendering efficiency caused by the cumbersome operation process of achieving close fit between the model and different terrains in related technologies. Attached Figure Description
[0012] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:
[0013] Figure 1 This is a schematic diagram of a reverse motion in a related technology;
[0014] Figure 2 This is a hardware structure block diagram of a mobile terminal for a model rendering method according to an embodiment of this application;
[0015] Figure 3 This is a flowchart of a model rendering method according to one embodiment of this application;
[0016] Figure 4 This is a schematic diagram of a target model offset according to one embodiment of this application;
[0017] Figure 5 This is a schematic diagram of a vector cross product operation according to one embodiment of this application;
[0018] Figure 6 This is a schematic diagram of a rendering result according to one embodiment of this application;
[0019] Figure 7 This is a schematic diagram of another rendering result according to one embodiment of this application;
[0020] Figure 8 This is a structural block diagram of a model rendering apparatus according to one embodiment of the present application;
[0021] Figure 9 This is a schematic diagram of an electronic device according to an embodiment of this application. Detailed Implementation
[0022] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.
[0023] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0024] In related technologies, when using the IK function, it is first necessary to create an animation skeleton, and then to set a series of parameters for the actuators of the animation model to ensure that the animation model has the correct collision and positional relationship with the terrain. Specifically, after creating the animation skeleton, the settings required may include: settings for actuator position, settings for the Blueprint event graph, and settings for dual-bone IK nodes. Among these, the character Blueprint construction script mainly involves the setting of two key parameters: a scale variable representing the character's Z-axis height; and the IK trance distance variable. The Blueprint event graph is mainly used to handle tracking operations, which are projected downwards from the feet of the animated character. When an obstacle is encountered, the tracking distance between the character and the obstacle is stored so that the tracking distance can be used in the animation Blueprint to move the IK actuators. The tracking operation can use a custom function called the IK Foot trance function to obtain the offset position of the IK actuator. However, if the model does not have an animation skeleton, it is impossible to track the character's feet and obstacles using the IK blueprint executor, and thus it is impossible to achieve the effect of adaptive fitting between the animation model and the terrain.
[0025] In one possible implementation, the method for adaptively fitting animated models to terrain, commonly used in game backgrounds, still suffers from the technical problem of cumbersome operation and low model rendering efficiency, despite the inventors' practical experience and careful research. Therefore, this application proposes a model rendering method. This method sets the pivot point position of the target model using preset height parameters, determines the rotation axis direction and rotation angle of the target model based on the first axis direction vector of the target model within the offset range and the normal vector of the scene terrain where the target model is located, and finally renders the target model based on the rotation axis direction, rotation angle, and pivot point position. This achieves the goal of rendering the target model based on the rotation axis direction, rotation angle, and pivot point position, enabling the target model to adaptively and closely fit the scene terrain, thereby improving model rendering efficiency and solving the technical problem of cumbersome operation process leading to low model rendering efficiency in related technologies.
[0026] The methods and embodiments described above in this disclosure can be executed on mobile terminals, computer terminals, or similar computing devices. Taking a mobile terminal as an example, the mobile terminal can be a smartphone, tablet computer, PDA, mobile internet device, PAD, game console, or other terminal device. Figure 2 This is a hardware structure block diagram of a mobile terminal for a model rendering method according to an embodiment of this application. For example... Figure 2 As shown, a mobile terminal may include one or more ( Figure 2 Only one is shown in the image. Processor 202 (processor 202 may include, but is not limited to, a central processing unit (CPU), graphics processing unit (GPU), digital signal processing (DSP) chip, microprocessor (MCU), programmable logic device (FPGA), neural network processor (NPU), tensor processor (TPU), artificial intelligence (AI) type processor, etc.) and memory 204 for storing data. In one embodiment of this application, it may also include: input / output device 208 and display device 210.
[0027] In some optional embodiments primarily focused on gaming scenarios, the aforementioned device may also provide a human-computer interaction interface with a touch-sensitive surface. This interface can sense finger contact and / or gestures to interact with a graphical user interface (GUI). The human-computer interaction functions may include the following: creating web pages, drawing, word processing, creating electronic documents, playing games, video conferencing, instant messaging, sending and receiving emails, call interfaces, playing digital videos, playing digital music, and / or web browsing, etc. Executable instructions for performing the aforementioned human-computer interaction functions are configured / stored in one or more processor-executable computer program products or readable storage media.
[0028] Those skilled in the art will understand that Figure 2 The structure shown is for illustrative purposes only and does not limit the structure of the mobile terminal described above. For example, the mobile terminal may also include components that are more... Figure 2 The more or fewer components shown, or having the same Figure 2 The different configurations shown.
[0029] According to one embodiment of this application, an embodiment of a model rendering method is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0030] In one possible implementation, this application provides a model rendering method that can be applied to a terminal device, which may be the aforementioned local terminal device. Figure 3 This is a flowchart of a model rendering method according to one embodiment of this application, such as... Figure 3 As shown, the method includes the following steps:
[0031] Step S31: Set the position of the axis point of the target model according to the preset height parameter, wherein the preset height parameter is used to determine the offset range of the target model;
[0032] Step S32: Obtain the first vector and the second vector, wherein the first vector is the first axis direction vector of the target model within the offset range, and the second vector is the normal vector of the scene terrain where the target model is located;
[0033] Step S33: Determine the rotation axis direction and rotation angle of the target model based on the first vector and the second vector;
[0034] Step S34: Render the target model based on the rotation axis direction, rotation angle, and axis center position.
[0035] Specifically, the rendering method for the above model can be executed in a real-time rendering engine, such as Unreal Engine (UE). The target model can be any virtual model in the game scene that interacts with the scene terrain; for example, the target model can be a tree or vegetation model in the game scene that needs to conform to the ground.
[0036] The aforementioned preset height parameter can be used to set the center point of the target model, and the offset range of the target model can be determined based on the position of the center point. Figure 4 This is a schematic diagram of a target model offset according to one embodiment of this application, such as... Figure 4As shown, the pivot point of the tree model is determined as point A based on preset height parameters. The offset range of the tree model is then determined based on the position of point A. Figure 4 The dashed line range of the tree model in the middle.
[0037] Furthermore, the first axis direction vector of the target model within the offset range and the normal vector of the terrain surrounding the target model are obtained. Then, the rotation axis direction and rotation angle of the target model are determined based on these first axis direction vectors and normal vectors. The first axis direction vector can be any selected axis direction vector, specifically determined according to the deployment requirements of the target model. For example, when the target model is a tree model, since trees generally grow upwards in the real world, to make the deployment effect of the tree model in the game world more realistic, the upward-facing Z-axis vector of the tree model can be determined as the first axis direction vector; that is, the first axis direction vector can be the upward axis direction vector (UpVector).
[0038] Specifically, the rotation axis direction refers to the axial vector when offsetting the target model within the offset range, and the aforementioned rotation angle is the angle at which the first axis direction vector is offset. The rotation axis direction, rotation angle, and axis position can be stored in the material function and can be used as the values of the World Position Offset (WPO) node. These values can be directly used when rendering the target model without deforming the mesh of the individual target model itself. The WPO parameters can be used to make target models of arbitrary shapes autonomously conform to terrain undulations.
[0039] Rendering the target model based on the rotation axis direction, rotation angle, and pivot point position yields an offset target model. This offset target model can autonomously adapt to the undulations of the scene terrain. For example... Figure 4 As shown, the offset tree model can fit closely to the surface of the sloping terrain.
[0040] Based on steps S31 to S34 above, the pivot point position of the target model is set by preset height parameters, and the rotation axis direction and rotation angle of the target model are determined based on the first axis direction vector of the target model within the offset range and the normal vector of the scene terrain where the target model is located. Finally, the target model is rendered based on the rotation axis direction, rotation angle and pivot point position, so as to achieve the purpose of rendering the target model based on the rotation axis direction, rotation angle and pivot point position, so as to make the target model adaptively and closely fit the scene terrain. This achieves the technical effect of improving the model rendering efficiency, and solves the technical problem of low model rendering efficiency caused by the cumbersome operation process of achieving close fit between the model and different terrains in related technologies.
[0041] The model rendering method proposed in the embodiments of this application will be further described below.
[0042] Optionally, in step S32, obtaining the second vector includes:
[0043] Step S321: Perform ray detection on the scene terrain based on preset detection parameters to obtain detection results. The preset detection parameters are used to determine the terrain detection range, and the detection results are used to determine the normal direction of the scene terrain.
[0044] Step S322: Perform coordinate transformation on the detection result to obtain the second vector.
[0045] Specifically, before performing raycasting, the target model can be pre-defined using the `setstatic mesh` node in Unreal Engine. During this setting process, the material maps constituting the target model are imported using the `create dynamic material instance` node. (Continuing with...) Figure 4 Taking the tree model shown as an example, the tree model includes two material textures: leaves and trunk. When setting up the tree model, the leaf texture and trunk texture are imported into the Unreal Engine slots. By normally replacing the material textures, the shape of the target model can be changed, thereby enabling target models of any shape to autonomously adapt to terrain undulations through the model rendering scheme proposed in this application embodiment.
[0046] Ray detection of scene terrain based on preset detection parameters can detect the changes in normals and slope of the terrain where the target model is located. The terrain detection range during ray detection can be flexibly adjusted by preset detection parameters.
[0047] Furthermore, the detection results are transformed using the Transform Vector node in Unreal Engine, thereby transforming the detection results from the local space coordinate system to the second vector in the world space coordinate system.
[0048] Based on the above optional embodiments, ray detection is performed on the scene terrain based on preset detection parameters to obtain the detection results. Then, coordinate transformation is performed on the detection results to quickly obtain the normal vector of the scene terrain, which can be used to determine the rotation axis direction and rotation angle of the target model to be offset, thereby further improving the model rendering efficiency.
[0049] Optionally, in step S33, determining the rotation axis direction of the target model based on the first vector and the second vector includes:
[0050] Step S331: Perform a cross product operation based on the first and second vectors to obtain the third vector;
[0051] Step S332: Normalize the third vector to obtain the normalization result;
[0052] Step S333: Determine the direction of the rotation axis based on the normalization result.
[0053] Specifically, Figure 5 This is a schematic diagram of a vector cross product operation according to one embodiment of this application, such as... Figure 5 As shown, the first vector With the second vector The third vector is obtained after performing the cross product operation. The third vector is a vector perpendicular to the plane formed by the first and second vectors. The third vector is further normalized using a normalization node to obtain the normalization result. Based on the normalization result, the rotation axis direction is determined, thus controlling the rotation axis method within the correct orientation range. This rotation axis direction is used to determine the rotation axis for rotating and offsetting the target model within the offset range.
[0054] Based on the above optional embodiments, the cross product operation is performed on the first vector and the second vector to obtain the third vector, which is then normalized. Finally, the accurate rotation axis direction can be quickly determined based on the normalization result.
[0055] Optionally, in step S33, determining the rotation angle of the target model based on the first vector and the second vector includes:
[0056] Step S334: Remap the range to be offset to a preset constraint range to obtain the remapping result, wherein the remapping result is used to represent the mixed weights of the target model;
[0057] Step S335: Determine the rotation angle based on the vector angle between the first vector and the second vector and the remapping result.
[0058] Specifically, before remapping, the first and second vectors are processed using the Mask node in Unreal Engine to obtain vector components perpendicular to the ground direction. That is, the X-axis and Y-axis channels are hidden using the Mask node, only displaying the Z-axis channel that requires offset control. Further, the Remap node is used to remap the range to be offset to a preset constraint range. After obtaining an intermediate result, the Saturate node is used to constrain the intermediate result, thus obtaining the remapping result. The preset constraint range is between 0 and 1. For example, if the intermediate result is less than 0, its value is increased to 0 using the Saturate node; if the intermediate result is greater than 1, its value is decreased to 1 using the Saturate node; when the intermediate result is within the closed interval of 0 to 1, its value remains unchanged. Finally, the rotation angle is obtained by multiplying the vector angle between the first and second vectors with the remapping result. The vector angle between the first and second vectors can be calculated using the Angle Between Vectors node.
[0059] Based on the above optional implementation, by remapping the range to be offset to a preset constraint range, the remapping result is obtained, and then the rotation angle can be quickly determined based on the vector angle between the first vector and the second vector and the remapping result.
[0060] Optionally, the model rendering method in this application embodiment further includes:
[0061] Step S336: Compare the preset angle with the rotation angle to obtain a comparison result, wherein the comparison result is used to determine the positional relationship between the first vector and the second vector;
[0062] Step S337: Adjust the rendering result of the target model based on the comparison result.
[0063] Specifically, the rotation angle is determined using the `if` node in Unreal Engine, and the rendering result of the target model is adjusted based on the result. Since a small angle between vectors can easily lead to visual errors and potentially cause materials to disappear, if the rotation angle is determined to be too small, the first and second vectors can be considered perpendicular. For example, if a preset angle of 1 degree is set, and the rotation angle is less than 1 degree, the rotation angle is directly set to 0 degrees, meaning the first and second vectors are perpendicular.
[0064] Based on the above optional embodiments, by comparing the preset angle with the rotation angle, a comparison result is obtained, and then the rendering result of the target model is adjusted based on the comparison result, which can further improve the rendering effect of the model.
[0065] Optionally, in step S34, rendering the target model based on the rotation axis direction, rotation angle, and axis center position includes:
[0066] Step S341: Determine the target position corresponding to the target model within the offset range based on the first vector, the second vector, and the preset height parameter;
[0067] Step S342: Utilize the target engine to render the target model in real time based on the rotation axis direction, rotation angle, axis position, and target position.
[0068] Specifically, the coordinates of the contact point between the target model and the scene terrain after offset are pre-configured as P. The target position G corresponding to the target model within the offset range is determined according to the first vector U, the second vector N, and the preset height parameter H using the following formula 1:
[0069] G = N × H + P + U × (-1) × H Formula 1
[0070] In Formula 1, -1 can be used to obtain the position of the point opposite to the first vector.
[0071] Figure 6 This is a schematic diagram of a rendering result according to one embodiment of this application, such as... Figure 6 As shown, the target engine uses the rotation axis direction, rotation angle, pivot point position and target position to render the target model in real time. It can rotate and offset the Z-axis vector of the tree model within the offset range, so that the lower part of the tree model can adaptively fit the scene terrain.
[0072] Optionally, before determining the target position based on the first vector, the second vector, and the preset height parameter, the model rendering method of this application embodiment further includes:
[0073] S35, set the offset parameter of the target model, where the offset parameter is used to control the contact distance between the target model and the scene terrain.
[0074] Specifically, the offset parameters corresponding to the target model are obtained at the offset node, thereby controlling the contact distance between the target model and the scene terrain. Figure 7 This is a schematic diagram of another rendering result according to one embodiment of this application, such as... Figure 7 As shown, the lower part of the tree model can be offset according to the above model rendering method, but there is still a certain gap between it and the terrain. By reducing the offset parameter of the target model, the contact distance between the target model and the scene terrain can be reduced, so that the lower part of the tree model can adaptively fit the scene terrain.
[0075] In the model rendering method provided in this application embodiment, unlike animation skeletons or existing IK technology, any mesh model can correctly fit the terrain even without a skeleton, without the need for skeleton retargeting or IK settings, thus simplifying the model rendering process. Furthermore, the model rendering method of this application does not require adjustments to the appearance of each target model to match the scene terrain, effectively reducing the workload of model creation and further improving rendering efficiency.
[0076] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they 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 this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0077] This embodiment also provides a model rendering apparatus for implementing the above embodiments and preferred embodiments; details already described will not be repeated. As used below, the term "module" can refer to a combination of software and / or hardware that performs a predetermined function. Although the apparatus described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.
[0078] Figure 8 This is a structural block diagram of a model rendering apparatus according to one embodiment of this application, such as... Figure 8 As shown, the model rendering device 800 includes:
[0079] Setting module 801 is used to set the position of the axis point of the target model according to the preset height parameter, wherein the preset height parameter is used to determine the offset range of the target model;
[0080] The acquisition module 802 is used to acquire a first vector and a second vector, wherein the first vector is the first axis direction vector of the target model within the range to be offset, and the second vector is the normal vector of the scene terrain where the target model is located;
[0081] The determination module 803 is used to determine the rotation axis direction and rotation angle of the target model based on the first vector and the second vector;
[0082] Rendering module 804 is used to render the target model based on the rotation axis direction, rotation angle, and axis position.
[0083] Optionally, the acquisition module 802 is further configured to: perform ray detection on the scene terrain based on preset detection parameters to obtain detection results, wherein the preset detection parameters are used to determine the terrain detection range and the detection results are used to determine the normal direction of the scene terrain; and perform coordinate transformation on the detection results to obtain a second vector.
[0084] Optionally, the determining module 803 is further configured to: perform a cross product operation based on the first vector and the second vector to obtain a third vector; normalize the third vector to obtain a normalized result; and determine the direction of the rotation axis based on the normalized result.
[0085] Optionally, the determining module 803 is further configured to: remap the range to be offset to a preset constraint range to obtain a remapping result, wherein the remapping result is used to represent the mixed weights of the target model; and determine the rotation angle based on the vector angle between the first vector and the second vector and the remapping result.
[0086] Optionally, the model rendering device 800 further includes: a comparison module 805, used to compare a preset angle with a rotation angle to obtain a comparison result, wherein the comparison result is used to determine the positional relationship between the first vector and the second vector; and an adjustment module 806, used to adjust the rendering result of the target model based on the comparison result.
[0087] Optionally, the rendering module 804 is also used to: determine the target position corresponding to the target model within the offset range based on the first vector, the second vector and the preset height parameter; and use the target engine to render the target model in real time based on the rotation axis direction, rotation angle, axis point position and target position.
[0088] Optionally, the model rendering apparatus 800 further includes a setting module 807 for setting offset parameters of the target model, wherein the offset parameters are used to control the contact distance between the target model and the scene terrain.
[0089] It should be noted that the above modules can be implemented by software or hardware. For the latter, they can be implemented in the following ways, but are not limited to: all the above modules are located in the same processor; or, the above modules are located in different processors in any combination.
[0090] Embodiments of this application also provide a computer-readable storage medium storing a computer program, wherein the computer program is configured to execute the steps in any of the above method embodiments when run.
[0091] Optionally, in this embodiment, the computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.
[0092] Optionally, in this embodiment, the computer-readable storage medium may be located in any computer terminal in a group of computer terminals in a computer network, or in any mobile terminal in a group of mobile terminals.
[0093] Optionally, in this embodiment, the computer-readable storage medium may be configured to store a computer program for performing the following steps:
[0094] S1, Set the position of the axis point of the target model according to the preset height parameter, wherein the preset height parameter is used to determine the offset range of the target model;
[0095] S2, obtain the first vector and the second vector, where the first vector is the first axis direction vector of the target model within the offset range, and the second vector is the normal vector of the scene terrain where the target model is located;
[0096] S3, determine the rotation axis direction and rotation angle of the target model based on the first vector and the second vector;
[0097] S4 renders the target model based on the rotation axis direction, rotation angle, and axis center position.
[0098] Optionally, the aforementioned computer-readable storage medium is further configured to store program code for performing the following steps: performing ray detection on the scene terrain based on preset detection parameters to obtain detection results, wherein the preset detection parameters are used to determine the terrain detection range, and the detection results are used to determine the normal direction of the scene terrain; performing coordinate transformation on the detection results to obtain a second vector.
[0099] Optionally, the aforementioned computer-readable storage medium is further configured to store program code for performing the following steps: performing a cross product operation based on the first vector and the second vector to obtain a third vector; normalizing the third vector to obtain a normalized result; and determining the direction of the rotation axis based on the normalized result.
[0100] Optionally, the aforementioned computer-readable storage medium is further configured to store program code for performing the following steps: remapping the range to be offset to a preset constraint range to obtain a remapping result, wherein the remapping result is used to represent the mixed weights of the target model; and determining a rotation angle based on the vector angle between the first vector and the second vector and the remapping result.
[0101] Optionally, the aforementioned computer-readable storage medium is further configured to store program code for performing the following steps: comparing a preset angle with a rotation angle to obtain a comparison result, wherein the comparison result is used to determine the positional relationship between the first vector and the second vector; and adjusting the rendering result of the target model based on the comparison result.
[0102] Optionally, the aforementioned computer-readable storage medium is further configured to store program code for performing the following steps: determining the target position corresponding to the target model within the offset range based on the first vector, the second vector, and the preset height parameter; and rendering the target model in real time using the target engine based on the rotation axis direction, rotation angle, axis point position, and target position.
[0103] Optionally, the aforementioned computer-readable storage medium is further configured to store program code for performing the following steps: setting offset parameters of the target model, wherein the offset parameters are used to control the contact distance between the target model and the scene terrain.
[0104] In the computer-readable storage medium of this embodiment, a model rendering method is provided. The method sets the pivot point position of the target model by setting a preset height parameter, and determines the rotation axis direction and rotation angle of the target model based on the first axis direction vector of the target model within the offset range and the normal vector of the scene terrain where the target model is located. Finally, the target model is rendered based on the rotation axis direction, rotation angle and pivot point position. This achieves the purpose of rendering the target model based on the rotation axis direction, rotation angle and pivot point position, so that the target model adapts and fits closely with the scene terrain. This improves the model rendering efficiency and solves the technical problem of low model rendering efficiency caused by the cumbersome operation process of achieving close fitting between the model and different terrains in related technologies.
[0105] Through the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions according to the embodiments of this application can be embodied in the form of a software product, which can be stored in a computer-readable storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, terminal device, or network device, etc.) to execute the methods according to the embodiments of this application.
[0106] In exemplary embodiments of this application, a computer-readable storage medium stores a program product capable of implementing the methods described above in this embodiment. In some possible implementations, various aspects of the embodiments of this application may also be implemented as a program product including program code, which, when the program product is run on a terminal device, causes the terminal device to perform the steps described in the "Exemplary Methods" section of this embodiment according to various exemplary embodiments of this application.
[0107] The program product for implementing the above-described method according to embodiments of this application may employ a portable compact disc read-only memory (CD-ROM) and include program code, and may run on a terminal device, such as a personal computer. However, the program product of the embodiments of this application is not limited thereto. In the embodiments of this application, the computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in conjunction with an instruction execution system, apparatus, or device.
[0108] The aforementioned program product may take the form of any combination of one or more computer-readable media. Such computer-readable storage media may be, for example, but not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatuses, or devices, or any combination thereof. More specific examples (not exhaustive) of computer-readable storage media include: electrical connections having one or more wires, portable disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0109] It should be noted that the program code contained on the computer-readable storage medium can be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, etc., or any suitable combination thereof.
[0110] Embodiments of this application also provide an electronic device including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to perform the steps in any of the above method embodiments.
[0111] 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.
[0112] Optionally, in this embodiment, the processor can be configured to perform the following steps via a computer program:
[0113] S1, Set the position of the axis point of the target model according to the preset height parameter, wherein the preset height parameter is used to determine the offset range of the target model;
[0114] S2, obtain the first vector and the second vector, where the first vector is the first axis direction vector of the target model within the offset range, and the second vector is the normal vector of the scene terrain where the target model is located;
[0115] S3, determine the rotation axis direction and rotation angle of the target model based on the first vector and the second vector;
[0116] S4 renders the target model based on the rotation axis direction, rotation angle, and axis center position.
[0117] Optionally, the processor may also be configured to perform the following steps via a computer program: perform ray detection on the scene terrain based on preset detection parameters to obtain detection results, wherein the preset detection parameters are used to determine the terrain detection range and the detection results are used to determine the normal direction of the scene terrain; and perform coordinate transformation on the detection results to obtain a second vector.
[0118] Optionally, the processor may also be configured to perform the following steps via a computer program: perform a cross product operation based on the first vector and the second vector to obtain a third vector; normalize the third vector to obtain a normalization result; and determine the direction of the rotation axis based on the normalization result.
[0119] Optionally, the processor may also be configured to perform the following steps via a computer program: remapping the range to be offset to a preset constraint range to obtain a remapping result, wherein the remapping result is used to represent the mixed weights of the target model; and determining the rotation angle based on the vector angle between the first vector and the second vector and the remapping result.
[0120] Optionally, the processor may also be configured to perform the following steps via a computer program: comparing a preset angle with a rotation angle to obtain a comparison result, wherein the comparison result is used to determine the positional relationship between the first vector and the second vector; and adjusting the rendering result of the target model based on the comparison result.
[0121] Optionally, the processor may also be configured to perform the following steps via a computer program: determine the target position corresponding to the target model within the offset range based on the first vector, the second vector, and the preset height parameter; and render the target model in real time using the target engine based on the rotation axis direction, rotation angle, axis point position, and target position.
[0122] Optionally, the processor described above can also be configured to perform the following steps via a computer program: setting the offset parameters of the target model, wherein the offset parameters are used to control the contact distance between the target model and the scene terrain.
[0123] In the electronic device of this embodiment, a model rendering method is provided. The pivot point position of the target model is set by a preset height parameter, and the rotation axis direction and rotation angle of the target model are determined based on the first axis direction vector of the target model within the offset range and the normal vector of the scene terrain where the target model is located. Finally, the target model is rendered based on the rotation axis direction, rotation angle and pivot point position. This achieves the purpose of rendering the target model based on the rotation axis direction, rotation angle and pivot point position, so that the target model adapts and fits closely with the scene terrain. This improves the model rendering efficiency and solves the technical problem of low model rendering efficiency caused by the cumbersome operation process of achieving close fitting between the model and different terrains in related technologies.
[0124] Figure 9 This is a schematic diagram of an electronic device according to an embodiment of this application. Figure 9 As shown, the electronic device 900 is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.
[0125] like Figure 9 As shown, the electronic device 900 is presented in the form of a general-purpose computing device. The components of the electronic device 900 may include, but are not limited to: at least one processor 910, at least one memory 920, a bus 930 connecting different system components (including memory 920 and processor 910), and a display 940.
[0126] The memory 920 stores program code that can be executed by the processor 910, causing the processor 910 to perform the steps described in the method section of the embodiments of this application according to various exemplary implementations of this application.
[0127] The memory 920 may include a readable medium in the form of volatile memory cells, such as random access memory (RAM) 9201 and / or cache memory 9202, and may further include read-only memory (ROM) 9203, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory.
[0128] In some instances, memory 920 may also include a program / utility 9204 having a set (at least one) of program modules 9205, including but 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 920 may further include memory remotely located relative to processor 910, which can be connected to electronic device 900 via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
[0129] Bus 930 can represent one or more of several types of bus structures, including a memory cell bus or memory cell controller, peripheral bus, graphics acceleration port, processor 910, or a local bus using any of the various bus structures.
[0130] The display 940 may be, for example, a touchscreen liquid crystal display (LCD) that allows a user to interact with the user interface of the electronic device 900.
[0131] Optionally, the electronic device 900 can also communicate with one or more external devices 1000 (e.g., keyboard, pointing device, Bluetooth device, etc.), one or more devices that enable a user to interact with the electronic device 900, and / or any device that enables the electronic device 900 to communicate with one or more other computing devices (e.g., router, modem, etc.). This communication can be performed via the input / output (I / O) interface 950. Furthermore, the electronic device 900 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via the network adapter 960. Figure 9 As shown, network adapter 960 communicates with other modules of electronic device 900 via bus 930. It should be understood that, although... Figure 9 As not shown, other hardware and / or software modules may be used in conjunction with electronic device 900, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0132] The aforementioned electronic device 900 may also 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.
[0133] Those skilled in the art will understand that Figure 9 The structure shown is for illustrative purposes only and does not limit the structure of the electronic device described above. For example, the electronic device 900 may also include components that are more... Figure 9 The more or fewer components shown, or having the same Figure 9 Different configurations are shown. The memory 920 can be used to store computer programs and corresponding data, such as the computer program and corresponding data corresponding to the model rendering method in this embodiment. The processor 910 executes various functional applications and data processing by running the computer program stored in the memory 920, thereby implementing the aforementioned model rendering method.
[0134] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0135] In the above embodiments of this application, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0136] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units can be a logical functional division, and in actual implementation, there may be other division methods. For instance, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual coupling, direct coupling, or communication connection may be through some interfaces; the indirect coupling or communication connection between units or modules may be electrical or other forms.
[0137] The units described as separate components may or may not be physically separate. 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 can be selected to achieve the purpose of this embodiment according to actual needs.
[0138] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0139] If the integrated unit is implemented as 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 this application, in essence, 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. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard drive, magnetic disk, or optical disk.
[0140] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. A model rendering method, characterized by, The method comprises: setting an axis center point position of a target model according to a preset height parameter, wherein the preset height parameter is used to determine a range to be offset of the target model; obtaining a first vector and a second vector, wherein the first vector is a first axis direction vector of the target model in the range to be offset, and the second vector is a normal vector of a scene terrain where the target model is located; determining a rotation axis direction and a rotation angle of the target model based on the first vector and the second vector; rendering the target model based on the rotation axis direction, the rotation angle and the axis center point position; wherein obtaining the second vector comprises: performing ray detection on the scene terrain based on a preset detection parameter to obtain a detection result, wherein the preset detection parameter is used to determine a terrain detection range, and the detection result is used to determine a normal direction of the scene terrain; and performing coordinate conversion on the detection result to obtain the second vector.
2. The model rendering method of claim 1, wherein, determining the rotation axis direction of the target model based on the first vector and the second vector comprises: performing cross product operation based on the first vector and the second vector to obtain a third vector; performing normalization processing on the third vector to obtain a normalization processing result; determining the rotation axis direction based on the normalization processing result.
3. The model rendering method of claim 1, wherein, determining the rotation angle of the target model based on the first vector and the second vector comprises: remapping the range to be offset to a preset constraint range to obtain a remapping result, wherein the remapping result is used to represent a mixing weight of the target model; determining the rotation angle based on a vector included angle between the first vector and the second vector and the remapping result.
4. The model rendering method of claim 1, wherein, The method further comprises: comparing a preset angle with the rotation angle to obtain a comparison result, wherein the comparison result is used to determine a positional relationship of the first vector and the second vector; adjusting a rendering result of the target model based on the comparison result.
5. The model rendering method of claim 1, wherein, rendering the target model based on the rotation axis direction, the rotation angle and the axis center point position comprises: determining a target position corresponding to the target model in the range to be offset according to the first vector, the second vector and the preset height parameter; performing real-time rendering on the target model based on the rotation axis direction, the rotation angle, the axis center point position and the target position by using a target engine.
6. The model rendering method of claim 5, wherein, Before determining the target position according to the first vector, the second vector and the preset height parameter, the method further comprises: setting an offset parameter of the target model, wherein the offset parameter is used to control a contact distance between the target model and the scene terrain.
7. A model rendering apparatus, characterized by comprising: The device comprises: a setting module configured to set an axis center point position of a target model according to a preset height parameter, wherein the preset height parameter is used to determine a range to be offset of the target model; an obtaining module configured to obtain a first vector and a second vector, wherein the first vector is a first axis direction vector of the target model in the range to be offset, and the second vector is a normal vector of a scene terrain where the target model is located; determining a rotation axis direction and a rotation angle of the target model based on the first vector and the second vector; rendering the target model based on the rotation axis direction, the rotation angle and the position of the axis center point; wherein the obtaining module is further configured to: perform ray detection on the scene terrain based on preset detection parameters to obtain a detection result, wherein the preset detection parameters are used to determine a terrain detection range, and the detection result is used to determine a normal direction of the scene terrain; and perform coordinate conversion on the detection result to obtain the second vector.
8. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, wherein the computer program is configured to be run by the processor to execute the model rendering method in any one of claims 1 to 6. 9.An electronic device comprising a memory and a processor, the electronic device characterized by, The memory stores a computer program, and the processor is configured to run the computer program to execute the model rendering method in any one of claims 1 to 6.
Citation Information
Patent Citations
Method and device of rendering 3D (three dimensional) model in any orientation
CN103810746A
Image generation method and device, equipment and storage medium
CN115018967A