Method, device, storage medium and electronic device for processing target virtual object
By mapping the target point information of the target virtual object to the target map, the map coordinates are obtained and the rotation information is determined based on the map coordinates, the stretching problem of the virtual object during movement is solved, and the natural movement of the virtual object is realized.
Patent Information
- Application Number
- CN202110950916.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-08-18
- Publication Date
- 2025-02-25
- Estimated Expiration
- 2041-08-18
AI Technical Summary
The prior art cannot effectively reduce the stretching feeling of virtual objects during movement, resulting in stretching during movement.
By obtaining the target point information of the target virtual object, mapping it to the target map associated with the target virtual object, obtaining the map coordinates, and determining the rotation information of the target virtual object based on the map coordinates to control its rotation in the game scene .
It effectively reduces the stretching feeling of virtual objects during movement, solves the stretching problem when virtual objects rotate, and makes the movement of virtual objects more natural.
Smart Images

Figure CN113838170B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computers, and in particular to a method, device, storage medium and electronic device for processing a target virtual object. Background Art
[0002] Currently, in a game scene, when processing a virtual object, the offset strength and frequency of the vertices of the virtual object may be controlled by noise, but the accuracy of the noise map causes the virtual object to be stretched more severely when moving.
[0003] In another related technology, a virtual and non-baked solution is used to rotate the virtual object around the rotation center to realize the processing of the virtual object, but the true rotation center of the virtual object is not solved, so it still cannot effectively eliminate the stretching feeling of the virtual object when it moves.
[0004] With respect to the technical problem in the prior art that the stretching sensation during the movement of virtual objects cannot be effectively reduced, no effective solution has been proposed so far. Summary of the invention
[0005] The main purpose of the present invention is to provide a method, device, storage medium and electronic device for processing a target virtual object, so as to at least solve the technical problem that the stretching feeling when the virtual object moves cannot be effectively reduced.
[0006] In order to achieve the above-mentioned purpose, according to one aspect of the present invention, a method for processing a target virtual object is provided. The method may include: obtaining target point information of the target virtual object, wherein the target point information is used to represent the target point around which the target virtual object rotates; mapping the target point information to a target map associated with the target virtual object to obtain the map coordinates of the target point; determining the rotation information of the target virtual object based on the map coordinates, wherein the rotation information is used to control the rotation of the target virtual object in the game scene.
[0007] Optionally, obtaining target point information of the target virtual object includes: obtaining a vertex of the target virtual object; determining the vertex as the target point, and determining position information of the vertex as the target point information.
[0008] Optionally, the method further includes: obtaining a target number of vertices; mapping the target point information to a target map associated with the target virtual object to obtain map coordinates of the target point, including: mapping the position information of the vertex to the target map based on the target number to obtain map coordinates.
[0009] Optionally, determining the rotation information of the target virtual object based on the mapping coordinates includes: determining the rotation information of the target virtual object based on the mapping coordinates in the target engine.
[0010] Optionally, in the target engine, determining the rotation information of the target virtual object based on the mapping coordinates includes: in the target engine, acquiring an offset corresponding to the target virtual object based on the mapping coordinates; and determining the rotation information based on the offset.
[0011] Optionally, obtaining an offset corresponding to a target virtual object based on map coordinates comprises: determining a first offset of a target wind field of a game scene to the target virtual object based on the map coordinates, and / or determining a second offset of a virtual game character in the game scene to the target virtual object based on the map coordinates; determining rotation information based on the offset comprises: determining rotation information based on the first offset and / or the second offset, wherein the rotation information comprises at least a rotation direction and a rotation axis of the virtual object, and the rotation axis is used to indicate a direction of the target wind field.
[0012] Optionally, determining a first offset of a target wind field in a game scene to a target virtual object based on map coordinates includes: obtaining a wind field map corresponding to a global wind field, wherein the target wind field includes the global wind field, and the wind field map is used to represent a wind field change state in the game scene; based on the wind field map and the map coordinates, determining a wind and wave fluctuation offset of the target wind field to the target virtual object in at least one direction, wherein the first offset includes a wind and wave fluctuation offset.
[0013] Optionally, determining a first offset of a target wind field of a game scene to a target virtual object based on map coordinates includes: determining a periodic function under a local wind field, wherein the target wind field includes a local wind field; determining a periodic offset of the target virtual object based on the periodic function and the map coordinates, wherein the first offset includes a periodic offset.
[0014] Optionally, determining a second offset of a virtual game character in a game scene to a target virtual object based on mapping coordinates includes: obtaining a target distance between the virtual game character and the target virtual object; determining that the target distance is within a preset threshold range, and determining positions of vertices of the target virtual object based on the mapping coordinates; determining a target vector based on the position of the virtual game character and the positions of vertices of the target virtual object; and determining the second offset based on the target vector.
[0015] Optionally, determining the rotation information of the target virtual object based on the mapping coordinates includes: determining the rotation information of multiple target virtual objects based on the mapping coordinates of the multiple target virtual objects.
[0016] In order to achieve the above-mentioned purpose, according to another aspect of the present invention, a processing device for a target virtual object is also provided. The device may include: an acquisition unit, used to acquire target point information of the target virtual object, wherein the target point information is used to represent the target point around which the target virtual object rotates; a mapping unit, used to map the target point information to a target map associated with the target virtual object to obtain the map coordinates of the target point; and a determination unit, used to determine the rotation information of the target virtual object based on the map coordinates, wherein the rotation information is used to control the rotation of the target virtual object in the game scene.
[0017] To achieve the above object, according to another aspect of the present invention, a computer-readable storage medium is provided. The computer-readable storage medium stores a computer program, wherein when the computer program is executed by a processor, the device where the computer-readable storage medium is located is controlled to execute the method for processing a target virtual object according to an embodiment of the present invention.
[0018] To achieve the above objective, according to another aspect of the present invention, an electronic device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to execute the computer program to execute the method for processing a target virtual object according to an embodiment of the present invention.
[0019] In this embodiment, the target point information of the target virtual object is obtained, wherein the target point information is used to represent the target point around which the target virtual object rotates; the target point information is mapped to the target map associated with the target virtual object to obtain the map coordinates of the target point; the rotation information of the target virtual object is determined based on the map coordinates, wherein the rotation information is used to control the rotation of the target virtual object in the game scene. In other words, the present application maps the target point information of the target virtual object to the target map associated with the target virtual object to obtain the map coordinates, thereby solving the true rotation center around which the virtual object rotates, calculating the obtained map coordinates, and determining the rotation information of the target virtual object to achieve the purpose of controlling the rotation of the target virtual object, which makes the stretching degree of the target virtual object relatively low, solves the technical problem of being unable to effectively reduce the stretching feeling when the virtual object moves, thereby achieving the technical problem of effectively reducing the stretching feeling when the virtual object moves. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] The drawings constituting a part of this application are used to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0021] Figure 1 It is a hardware structure block diagram of a mobile terminal of a method for processing a target virtual object according to an embodiment of the present invention;
[0022] Figure 2 is a flow chart of a method for processing a target virtual object according to an embodiment of the present invention;
[0023] Figure 3 is a schematic diagram of a vegetation model according to an embodiment of the present invention;
[0024] Figure 4 is a schematic diagram of a vegetation wind farm system based on hub point information according to an embodiment of the present invention;
[0025] Figure 5 is a schematic diagram of baking pivot point information in 3DSMax according to an embodiment of the present invention;
[0026] Figure 6 is a schematic diagram of adding pivot point information of a vegetation model to a UV3 channel according to an embodiment of the present invention;
[0027] Figure 7 is a schematic diagram of a Shader art user interface according to an embodiment of the present invention;
[0028] Figure 8 is a schematic diagram of parameters of a global wind field according to an embodiment of the present invention;
[0029] Fig. 9 is a schematic diagram of a device for processing a target virtual object according to an embodiment of the present invention. DETAILED DESCRIPTION
[0030] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present invention will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0031] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.
[0032] 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 interchanged where appropriate, so that the embodiments of the present application described here. 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.
[0033] The method embodiments provided in the embodiments of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Taking running on a mobile terminal as an example, Figure 1 FIG. 1 is a hardware structure block diagram of a mobile terminal of a method for processing a target virtual object according to an embodiment of the present invention. Figure 1 As shown, the mobile terminal may include one or more ( Figure 1 Only one is shown in the figure) a processor 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data. Optionally, the mobile terminal may also include a transmission device 106 for communication functions and an input and output device 108. It can be understood by those skilled in the art that Figure 1 The structure shown is for illustration only and does not limit the structure of the mobile terminal. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown.
[0034] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as a computer program corresponding to a data processing method in an embodiment of the present invention. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, to implement the above method. The memory 104 may include a high-speed random access memory, 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. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the mobile terminal 10 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof.
[0035] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the mobile terminal. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0036] In this embodiment, a method for processing a target virtual object running on the above-mentioned mobile terminal is provided. Figure 2 FIG. 1 is a flow chart of a method for processing a target virtual object according to an embodiment of the present invention. Figure 2 As shown, the method may include the following steps:
[0037] Step S202: acquiring target point information of the target virtual object, wherein the target point information is used to represent the target point around which the target virtual object rotates.
[0038] In the technical solution provided in the above step S202 of the present invention, the target virtual object is an object model that needs to be processed in the game scene, for example, an object model whose rotation needs to be controlled, which can be a vegetation model. Obtaining the target point information of the target virtual object can be to calculate the target virtual object to obtain the target point information, which is used to represent the target point around which the target virtual object rotates, and the target point is also the center of rotation, which can be the origin of the rotation axis, which can be called the pivot point, and thus the rotation axis can also be called the pivot axis. Obtaining the target point information of the target virtual object can also be to obtain the pivot point information (model information) of the target virtual object, which can include the pivot point (PivotPoint) and rotation information.
[0039] Step S204 , mapping the target point information to a target map associated with the target virtual object to obtain the map coordinates of the target point.
[0040] In the technical solution provided in the above step S204 of the present invention, after acquiring the target point information of the target virtual object, the target point information is mapped to a target map associated with the target virtual object to obtain the map coordinates of the target point.
[0041] In this embodiment, the target point information is mapped to a target map associated with the target virtual object to obtain the mapping coordinates (UV coordinates, texture mapping coordinates, pivot point coordinates) of the target point. The target map may be one or more maps, that is, the target point information is baked (Bake), and the target point information can be mapped to the third channel (called UV3 channel, or 3U) of the texture coordinates of the target virtual object to obtain mapping coordinates for recording. The above-mentioned mapping coordinates can be called the coordinates of the pivot point or the pivot point coordinates, and the corresponding point is the real pivot point of the target virtual object.
[0042] Optionally, the wind farm system includes a 3DSMax model. This embodiment may bake target point information in the 3DSMax model to obtain mapping coordinates.
[0043] Optionally, this embodiment may set up a preprocessing model in the wind farm system, which may be to place a rectangular model, keep the pivot axis for rotating the target virtual object consistent with the vertical coordinate axis of the rectangular model, merge the rectangular model with the target virtual object, and then perform the subsequent processing on the target virtual object.
[0044] Step S206, determining rotation information of the target virtual object based on the mapping coordinates, wherein the rotation information is used to control the rotation of the target virtual object in the game scene.
[0045] In the technical solution provided in the above step S206 of the present invention, after mapping the target point information to the target map associated with the target virtual object and obtaining the map coordinates of the target point, the rotation information of the target virtual object can be determined based on the map coordinates. Optionally, the embodiment can determine the offset when the target virtual object rotates through wind field information, wherein the wind field information can be the world wind direction and magnitude possessed by the world attribute, and the rotation information can at least include the direction in which the target virtual object rotates around the axis. Optionally, the embodiment can customize the rotation axis to represent the wind field direction.
[0046] Through the above steps S202 to S206 of the present application, the target point information of the target virtual object is obtained, wherein the target point information is used to represent the target point around which the target virtual object rotates; the target point information is mapped to the target map associated with the target virtual object to obtain the map coordinates of the target point; the rotation information of the target virtual object is determined based on the map coordinates, wherein the rotation information is used to control the rotation of the target virtual object in the game scene. In other words, the present application maps the target point information of the target virtual object to the target map associated with the target virtual object to obtain the map coordinates, thereby solving the true rotation center around which the virtual object rotates, calculating the obtained map coordinates, and determining the rotation information of the target virtual object to achieve the purpose of controlling the rotation of the target virtual object, which makes the stretching degree of the target virtual object relatively low, solves the technical problem of being unable to effectively reduce the stretching feeling when the virtual object moves, thereby achieving the technical problem of effectively reducing the stretching feeling when the virtual object moves.
[0047] The above method of this embodiment is further introduced below.
[0048] As an optional implementation, step S202, obtaining target point information of the target virtual object, includes: obtaining a vertex of the target virtual object; determining the vertex as the target point, and determining the position information of the vertex as the target point information.
[0049] In this embodiment, when obtaining the target point information of the target virtual object, the vertex of the target virtual object may be obtained first, and the vertex may be determined as the target point, that is, the vertex may be determined as the pivot point for the rotation of the target virtual object. The position information of the vertex is obtained, and the position information is used to indicate the position of the vertex of the target virtual object, and the position information may be determined as the above-mentioned target point information.
[0050] As an optional implementation, the method also includes: obtaining the target number of vertices; mapping the target point information to a target map associated with the target virtual object to obtain the map coordinates of the target point, including: mapping the position information of the vertex to the target map based on the target number to obtain the map coordinates.
[0051] In this embodiment, the target number of vertices of the target virtual object can be calculated, and the target number is the number of all vertices of the target virtual object. Optionally, since the format of the default mapping coordinates (UV information) in 3DSMAX is recorded in the form of fixed-point colors, the position transformation coefficient corresponding to the fixed-point color is 255, and thus the embodiment can first multiply the position information of the above-mentioned vertices by 255 to obtain the model fixed-point color, which can also be called fixed-point color information, which can be recorded as invcpos, and then the target number can be used as the number of loops (getNumVerts obj), and in each loop, the product of the position information of each vertex and 255 is mapped to the target map in the loop body to realize mapping the fixed-point color information of all vertices to the target map, that is, to realize writing the fixed-point color information of all vertices into the above-mentioned UV3 channel to obtain the mapping coordinates.
[0052] Optionally, the embodiment can respond to an operation instruction acting on the target function control and map the position information of the vertex to the target texture based on the target quantity to obtain the texture coordinates. That is, the embodiment can add a target function control to facilitate the use of artists, so that the position information of the vertex can be written into the UV3 channel with one click.
[0053] As an optional implementation, step S206, determining the rotation information of the target virtual object based on the mapping coordinates, includes: determining the rotation information of the target virtual object based on the mapping coordinates in the target engine.
[0054] In this embodiment, the wind farm system may include a game engine. When determining the rotation information of the target virtual object based on the map coordinates, the map coordinates may be substituted into the target engine for calculation. Optionally, in the target engine, the rotation information of the target virtual object is calculated based on the map coordinates. The target engine may be a NeoX engine. The map coordinates may be calculated in a renderer (Shader) of the target engine to obtain the rotation information of the target virtual object. The map coordinates may be processed by the world wind direction and magnitude possessed by the world attributes of the game engine to determine the direction in which the target virtual object rotates around the axis.
[0055] Optionally, in this embodiment, an algorithm for rotating the target virtual object around an axis can be implemented in the target engine. Optionally, the function of rotating about an axis (RotateAboutAxis) can input a three-channel vector (x, y, z) related to the rotation given the rotation axis, a point on the rotation axis, and the rotation angle, and the function is suitable for using the global position offset (WorldPositionOffset) to produce animations with better quality than simple shearing; this embodiment can also receive a normalized (0 to 1) vector through the normalized rotation axis and angle (NormalizedRotationAxisAndAngle) function, which can be used to represent the rotation axis and rotation angle of the target virtual object, wherein the value 1 is used to represent a full 360-degree rotation; the function of the position on the axis (PositionOnAxis) is used to represent the reception of a three-channel vector representing a pivot point, around which the target virtual object will rotate; the position (Position) function is used to receive a three-channel vector representing the position of the target virtual object. Optionally, when creating a function for rotating about an axis (RotateAboutAxis), this embodiment can automatically create a world position (WorldPosition) function and use it as the input of the function for rotating about an axis; this embodiment can obtain the vertex coordinates of the target virtual object after rotating about the axis by converting the angle of the target virtual object in polar coordinates to plane coordinates through cosine (cos) and sine (sine).
[0056] As an optional implementation, in the target engine, the rotation information of the target virtual object is determined based on the mapping coordinates, including: in the target engine, obtaining an offset corresponding to the target virtual object based on the mapping coordinates; and determining the rotation information based on the offset.
[0057] In this embodiment, in the target engine, the offset corresponding to the target virtual object can be obtained based on the map coordinates. The offset of the target virtual object under the global wind field, the offset under the local wind field, and the outward offset of the target virtual object applied to the surrounding areas with the position of the virtual game character as the center can be obtained based on the map coordinates. The above offset can be a world coordinate offset, and all world coordinate offsets can be added to obtain the final offset of the target virtual object, and then the rotation information of the target virtual object can be determined based on the offset.
[0058] As an optional implementation, obtaining an offset corresponding to a target virtual object based on map coordinates comprises: determining a first offset of a target wind field of a game scene to the target virtual object based on the map coordinates, and / or determining a second offset of a virtual game character in the game scene to the target virtual object based on the map coordinates; determining rotation information based on the offset comprises: determining rotation information based on the first offset and / or the second offset, wherein the rotation information comprises at least a rotation direction and a rotation axis of the virtual object, and the rotation axis is used to indicate the direction of the target wind field.
[0059] In this embodiment, the renderer in the target engine may include a target wind field, and may determine a first offset of the target wind field of the game scene to the target virtual object based on the mapping coordinates. Optionally, the embodiment may determine the first offset caused by the influence of the target wind field on the mapping coordinates of the target virtual object, and the first offset may be referred to as a wind field offset. The embodiment may also determine a second offset of the virtual game character in the game scene to the target virtual object based on the mapping coordinates, which may be an outward offset of the mapping coordinates of the target virtual object applied to all sides with the position of the virtual game character as the center.
[0060] As an optional implementation, determining a first offset of a target wind field in a game scene to a target virtual object based on map coordinates includes: obtaining a wind field map corresponding to a global wind field, wherein the target wind field includes the global wind field, and the wind field map is used to represent a wind field change state in the game scene; based on the wind field map and the map coordinates, determining a wind and wave fluctuation offset of the target wind field to the target virtual object in at least one direction, wherein the first offset includes a wind and wave fluctuation offset.
[0061] In this embodiment, the renderer of the target engine includes a global wind field, and the public variables in the editor environment can be used to affect the wind field strength, frequency and direction of the global wind field. This embodiment can sample a wind field map corresponding to the global wind field, which can be called a wind wave map, which is used to represent the wind field change state in the game scene, for example, to determine the wind field frequency change in the world space. Optionally, the above-mentioned wind wave map is a noise map with a brightness gradient. Optionally, this embodiment can perform a spatial transformation on the texture coordinates, for example, perform a spatial transformation on the vertex coordinates to transfer the position (local) space of the target virtual object to the world space, and then define the wind wave fluctuation offset (wind field offset) in the horizontal (U) direction and the vertical (V) direction in combination with the wind field map, thereby achieving the purpose of generating different wind wave fluctuation offsets for the target virtual object in different directions by sampling the wind field map.
[0062] Optionally, this embodiment may substitute the wind wave fluctuation offset into the above-mentioned axis rotation function for calculation, so as to convert it into the offset of the world position vertex.
[0063] As an optional implementation, determining a first offset of a target wind field of a game scene to a target virtual object based on map coordinates includes: determining a periodic function under a local wind field, wherein the target wind field includes a local wind field; determining a periodic offset of the target virtual object based on the periodic function and the map coordinates, wherein the first offset includes a periodic offset.
[0064] In this embodiment, the renderer in the target engine may also include a local wind field, and a periodic function under the local wind field may be determined first. The periodic function may be a cosine function. In this way, when realizing the local swing of the target virtual object in the game scene, the periodic offset of the target virtual object may be produced for the local coordinates in the texture coordinates through the periodic function. The periodic offset is also the offset of the periodic swing.
[0065] Optionally, this embodiment may substitute the periodic offset into the above-mentioned axis rotation function for calculation, so as to convert it into the offset of the world position vertex.
[0066] As an optional implementation, determining a second offset of a virtual game character in a game scene to a target virtual object based on mapping coordinates includes: obtaining a target distance between the virtual game character and the target virtual object; determining that the target distance is within a preset threshold range, and determining the position of the vertices of the target virtual object based on the mapping coordinates; determining a target vector based on the position of the virtual game character and the position of the vertices of the target virtual object; and determining the second offset based on the target vector.
[0067] This embodiment adds an interaction function of the virtual game character for the target virtual object. When realizing the second offset of the virtual game character in the game scene to the target virtual object based on the map coordinates, the target distance between the virtual game character and the target virtual object can be obtained first, and then it is determined whether it is within a preset threshold range, wherein the preset threshold range is a set interaction range. If it is determined that the target distance is within the preset threshold range, it is determined that an interaction occurs between the virtual game character and the target virtual object. The position of the vertex of the target virtual object can be determined based on the map coordinates first, and then a target vector is made toward the position of the above vertex with the position of the target virtual object as the center. The second offset is determined based on the target offset. It can be determined as the above second offset based on the product of the target vector and the offset strength, which is an outward offset applied to the target virtual object in all directions with the position of the virtual game character as the center, and it can be converted into a world coordinate offset.
[0068] Optionally, this embodiment may add the world coordinate offset of the wind and wave fluctuation offset, the periodic offset, and the second offset to obtain a final offset of the target virtual object, and then determine the rotation information of the target virtual object based on the final offset.
[0069] As an optional implementation manner, determining the rotation information of the target virtual object based on the mapping coordinates includes: determining the rotation information of multiple target virtual objects based on the mapping coordinates of the multiple target virtual objects.
[0070] In this embodiment, the rotation information of multiple target virtual objects can be determined based on the mapping coordinates of multiple target virtual objects through the graphical user interface instance (GPUInstance) technology used to improve the efficiency of rendering a large number of objects, thereby realizing dynamic batching of multiple target virtual objects. Optionally, this embodiment can obtain the correct instance (Instance) matrix space by rewriting the world matrix, and use GPU Instance to dynamically batch all target virtual objects using the renderer (dynamic batching), so that the number of calls (drawcall) of the central processing unit (Central Processing Unit, referred to as CPU) to the underlying graphics drawing interface is reduced, thereby improving the game frame rate.
[0071] When dynamic batching of multiple target virtual objects is not enabled, the world coordinate transformation matrix can be represented by the World matrix, otherwise, it is represented by the variable synthesized World Ins matrix, which is used to enable hardware batching of multiple target virtual objects.
[0072] This embodiment introduces a wind field system based on target point information (hub point information), maps the target point information into a target map associated with a target virtual object for recording, substitutes the obtained map coordinates into a renderer of a target engine for calculation, and then determines the rotation information of the target virtual object based on the map coordinates to control the target virtual object. Compared with the wind field system solution in the related art, the stretching degree of the target virtual object is very low, the wind and wave animation is normal, and future expansion can construct multiple layers of wind influence by solving the index information of the target point. For example, vegetation has a trunk, the trunk has branches, and the branches have branches, and the wind influence it is subject to is represented by an index.
[0073] The above method of the embodiment of the present invention is further illustrated below in combination with a preferred implementation manner. Specifically, an example is given in which the target virtual object is a vegetation model and the target point is a pivot point.
[0074] In the related technology, skeletal animation can be used to create vegetation models. For example, skeletal animation can be used to create high-quality vegetation wind field effects. However, since skeletal animation is calculated in skeletal space, each bone has a relative space with its parent bone. Therefore, this method has a huge amount of calculation and is not suitable for processing vegetation models on mobile terminals.
[0075] Related technologies also usually use 3D plant and tree growth modeling software (SpeedTree) to output animation to process vegetation models, but the files output by this method are too large and are not suitable for virtual objects without trunks.
[0076] Related technologies also usually use noise to sample and control the vertex offset in world space. Although it can show the wind and wave effects, it is not refined enough and the motion details are too low. In addition, according to the accuracy of the noise map, the related model is severely stretched when moving.
[0077] Related technologies also usually use virtual, non-baked pivot points to realize the rotation of the vegetation model around the pivot point. Although the pivot point rotation method can reduce the stretching, it cannot be effectively eliminated unless the real pivot point of the vegetation model is solved.
[0078] MAXScript (3ds Max built-in scripting language) can store pivot point and rotation information in the texture of the vegetation model. The material renderer (Shader) of the NeoX game engine can use the above textures including pivot point and rotation information to access and decode the pivot point information stored by the MAXScript baked by the pivot point. Each texture output by MAXScript can be directly referenced in the material, but if the appropriate steps are not applied after sampling the texture, the referenced value will be incorrect.
[0079] Creating animations in the manner described above has its advantages. Vegetation models processed using this technique use only one more UV channel than Static Meshes, but their animations are much cheaper than skeletal animations because they are all calculated in real time. Vertex shaders are generally not as prone to performance issues as pixel shaders in terms of graphics processing units (GPUs) because the number of vertices on a vegetation model is usually significantly less than the number of pixels drawn for that vegetation model.
[0080] This embodiment solves the pivot point information for the vegetation model, and then maps the pivot point information to the attribute of the vegetation model itself (UV third channel). The coordinates of the pivot point can be substituted into the shader of the game engine for calculation, and the direction of the vegetation model's rotation around the axis can be controlled by the world wind direction and magnitude of the NeoX engine world attribute. The method of this embodiment is further described below.
[0081] Figure 3 FIG. 1 is a schematic diagram of a vegetation model according to an embodiment of the present invention. Figure 3 As shown, the initial position of the vegetation model needs to be at the origin of the coordinate system, that is, its coordinates (X, Y, Z) are (0.0, 0.0, 0.0).
[0082] Figure 4 FIG. 1 is a schematic diagram of a vegetation wind farm system based on hub point information according to an embodiment of the present invention. Figure 4 As shown, the wind farm system of this embodiment is mainly divided into a 3DSMax model information part and a shader part in the NeoX engine. The 3DSMax model information part includes: pre-processing model (placing a rectangular model to align the pivot axis with the vertical coordinate axis and merging it with the vegetation model); baking pivot point information (Bake Pivot information).
[0083] The shader in the NeoX engine of this embodiment may include: global wind field and local wind field. The global wind field can sample the wind map, and use the public variables in the editor environment to affect the global wind field strength, frequency and direction. The local wind field can use the sine function to create a periodic function to create a swinging wind field of the vegetation model in the local coordinate system; the customized interaction radius and intensity refers to applying an outward offset to the vegetation around the position of the virtual game character (Get PlaverPos) as the center).
[0084] After obtaining the world coordinate offsets of vegetation under the global wind field, local wind field and interaction, all world coordinate offsets can be added together to obtain the final offset (WorldPos Offset) of the vegetation, thereby controlling the rotation of the vegetation model.
[0085] The above technical solution of this embodiment is further introduced below.
[0086] Figure 5 FIG. 1 is a schematic diagram of baking pivot point information in 3DSMax according to an embodiment of the present invention. Figure 5 As shown, you can first record the position of the vertex of the vegetation model (X, Y, Z)*255 as invcpos to get the model fixed-point color. Calculate the number of all vertices of the vegetation model and use it as the number of loops (getNumVerts obj). In the loop body, write invcpos to the UV3 channel of the vegetation model to get the UV coordinates, for example, U is 0.87 and V is 0.25, so as to write the fixed-point color information of all vertices into 3U. It should be noted that in 3DSMAX, the default UV information format is recorded in the form of fixed-point color, so the position of the vertex of the vegetation model needs to be multiplied by 255.
[0087] Figure 6 FIG. 1 is a schematic diagram of adding pivot point information of a vegetation model to a UV3 channel according to an embodiment of the present invention. Figure 6 As shown, add a function button (BakeUV3) and make it easy for artists to use the function button to add the pivot point information of the vegetation model to the UV3 channel.
[0088] The axis rotation algorithm of this embodiment is introduced below.
[0089] The RotateAboutAxis function takes as input a three-channel vector related to the rotation given an axis, a point on that axis, and the angle of rotation. This expression is suitable for using WorldPositionOffset to produce animations of better quality than simple shearing.
[0090] NormalizedRotationAxisAndAngle accepts a normalized (0-1) vector representing the rotation axis and angle of the object, where a value of 1 can be used to represent a full 360-degree rotation.
[0091] The PositionOnAxis function is used to represent a three-channel vector that receives a pivot point around which the vegetation model can be rotated.
[0092] The Position function receives a three-channel vector representing the position of the vegetation model.
[0093] When you create an expression for a RotateAboutAxis function, a WorldPosition function is automatically created and used as input to the RotateAboutAxis function.
[0094] In this embodiment, the angle in polar coordinates can be converted into plane coordinates through cosine and sine, so as to obtain the vertex coordinates of the vegetation model after rotation around the axis.
[0095] This embodiment samples a wind field map and uses it as the wind field frequency change of the vegetation model in the world space. The local swing of the vegetation model can be periodically swung through a sine function, and the player's interactive function for the vegetation model is also added.
[0096] This embodiment can perform spatial transformation on the vertex coordinates of the vegetation model, transfer the position (local) space of the vegetation model to the world space, define the wind field offset of the vegetation model in the U direction and the V direction, and then generate different wind wave fluctuation offsets in different directions based on the sampling of the wind field map.
[0097] For the local coordinates of the vegetation model in this embodiment, the sine function can be combined to realize the periodic swing offset of the vegetation model, which can be brought into the above-mentioned RotateAboutAxis function to calculate the offset in the world position.
[0098] This embodiment can determine the distance between the virtual game character and the vegetation model. If the distance is within the set interaction range, it is determined that the virtual game character interacts with the vegetation model. In the case where the strength and interaction range are publicly exposed variables, a vector can be drawn from the virtual game character to the vertex position of the vegetation model, and the offset is the product of the above vector and the offset strength.
[0099] Finally, all the offsets obtained above are added together to obtain the final offset of the vegetation model.
[0100] Optionally, the embodiment can obtain the correct instance matrix space by rewriting the world matrix. The embodiment can use GPU Instance to dynamically batch all vegetation models using the shader, so that the number of drawcalls is reduced and the game frame rate is improved.
[0101] In this embodiment, when dynamic batching is not enabled, the world coordinate transformation matrix of the GPU Instace can be represented by the World matrix, otherwise, it is a World Ins matrix synthesized by variables, which can be used to enable hardware batching. Among them, dynamic batching is to calculate multiple parameters through GPU batch operation, which can be a batch operation for parameters of objects with simple models, the same materials, but in motion, and can occur when the program is running. Before each dynamic batching, multiple parameters that can be batched are sorted together, and then merged. Then, only one command is sent to the GPU to complete their overall operation calculation, so that the number of drawcalls is reduced and the game frame rate is increased. For example, wind wave maps, textures (Texture), wind field noise index, normalized wind field, local random bending change rate, local random change influence intensity, initialization deflection angle, interaction range, interaction smoothness and interaction bending intensity are calculated through GPU batch operation. Figure 7 shown.
[0102] Figure 7It is a schematic diagram of a Shader art user interface according to an embodiment of the present invention. In the Shader art user interface, multiple parameters for dynamic batch processing can be set. Optionally, the embodiment can set a wind wave map, which is a grayscale map and can be used to describe the change in wind field intensity; the texture can be set; the wind field noise value can be set, the larger the value, the smaller the noise transformation of each hub point; the wind field noise index can be set; the deviation of each hub point can be controlled; the wind field can be normalized to control the wind direction; the local random bending change rate can be set, which is a swaying speed parameter. When the vegetation model sways too chaotically, it can be used to unify the bending approximation of the vegetation model; the local random change influence intensity can be set; the initialization deflection angle can be set to control the deflection angle of the model in the initial state; the interaction range can be set, and the interaction range is the distance range within which the virtual game character and the vegetation model interact; the smoothness of the interaction and the interaction bending strength can be set.
[0103] Optionally, the dynamic batch processing of this embodiment can also be a batch operation calculation of multiple parameters of the global wind field, such as Figure 8 As shown. Among them, Figure 8 It is a schematic diagram of a parameter of a global wind field according to an embodiment of the present invention. The parameters of the global wind field may include: direction, intensity, and speed. The direction, intensity, and speed may be calculated in batches, thereby achieving the purpose of performing batch calculations on the direction, intensity, and speed. The direction is the direction of the global wind field, the intensity is the intensity of the global wind field, and the speed is the speed of the global wind field, so as to achieve the setting of the environment of the game scene.
[0104] For game scenes that are all automatically generated, a large number of vegetation models require a wind field system to control the shaking direction. The methods of related technologies have the problem of high consumption or low quality. However, the method of this embodiment can be applied to a large number of vegetation wind field systems on mobile terminals, and GPU Instance can be used to further reduce DrawCall, reduce performance consumption and optimize frame rate.
[0105] This embodiment can calculate the pivot point information of the vegetation; map the pivot point information of the vegetation to the third UV channel of the model for recording; substitute the coordinates of the pivot point into the Shader of the game engine for calculation, and control the direction of the model's rotation around the axis through the world wind direction and size possessed by the world attributes of the NeoX engine. In this way, the model is stretched to a very low degree and the wind and wave animation is normal, which solves the technical problem of being unable to effectively reduce the stretching feeling of the virtual object when it moves, thereby achieving the technical problem of effectively reducing the stretching feeling of the virtual object when it moves.
[0106] In this embodiment, in 3DSMAX, the pivot point information is baked into the 3U (UV third channel) of the vegetation model for recording. In the game engine NeoX, the pivot point is used as the rotation center, and the custom rotation axis can represent the wind field direction. A noise map with a brightness gradient can be sampled as the wind field and wave changes. In this way, a wind field system based on pivot point information is added to the NeoX engine.
[0107] Compared with the wind farm system solutions in related technologies, this embodiment is based on the hub point solution, the stretching degree of the virtual object is very low, the wind and wave animation is normal, and future expansion can construct multi-layer wind influence by solving the hub point Index information.
[0108] The embodiment of the present invention further provides a device for processing a target virtual object. It should be noted that the device for processing a target virtual object in this embodiment can be used to execute the embodiment of the present invention. Figure 2 The processing method of the target virtual object shown.
[0109] Fig. 9 is a schematic diagram of a target virtual object processing device according to an embodiment of the present invention. Fig. 9 As shown, the target virtual object processing device 90 includes: an acquisition unit 91, a mapping unit 92 and a determination unit 93.
[0110] The acquisition unit 91 is used to acquire target point information of the target virtual object, wherein the target point information is used to represent the target point around which the target virtual object rotates.
[0111] The mapping unit 92 is used to map the target point information to a target map associated with the target virtual object to obtain the map coordinates of the target point.
[0112] The determination unit 93 is used to determine the rotation information of the target virtual object based on the mapping coordinates, wherein the rotation information is used to control the rotation of the target virtual object in the game scene.
[0113] Optionally, the acquisition unit 91 includes: a first acquisition module, used to acquire the vertex of the target virtual object; a first determination module, used to determine the vertex as the target point, and determine the position information of the vertex as the target point information.
[0114] Optionally, the device further includes: a first acquisition unit, configured to acquire a target number of vertices; and the mapping unit 82 includes: a mapping module, configured to map the position information of the vertices to a target map based on the target number to obtain map coordinates.
[0115] Optionally, the determination unit 93 includes: a second determination module, configured to determine, in the target engine, rotation information of the target virtual object based on the mapping coordinates.
[0116] Optionally, the determination unit 93 includes: a second acquisition module, used to acquire, in the target engine, an offset corresponding to the target virtual object based on the mapping coordinates; and a third determination module, used to determine the rotation information based on the offset.
[0117] Optionally, the second acquisition module includes: a first determination submodule, used to determine a first offset of a target wind field of a game scene to a target virtual object based on map coordinates, and / or a second determination submodule, used to determine a second offset of a virtual game character in the game scene to a target virtual object based on map coordinates; the third determination module includes: a third determination submodule, used to determine rotation information based on the first offset and / or the second offset, wherein the rotation information includes at least a rotation direction and a rotation axis of the virtual object, and the rotation axis is used to indicate the direction of the target wind field.
[0118] Optionally, the first determination submodule is used to determine a first offset of a target wind field in a game scene to a target virtual object through the following steps: obtaining a wind field map corresponding to a global wind field, wherein the target wind field includes the global wind field, and the wind field map is used to represent a wind field change state in the game scene; based on the wind field map and the map coordinates, determining a wind and wave fluctuation offset of the target wind field to the target virtual object in at least one direction, wherein the first offset includes a wind and wave fluctuation offset.
[0119] Optionally, the first determination submodule is also used to determine a first offset of the target wind field of the game scene to the target virtual object based on the mapping coordinates through the following steps: determining a periodic function under the local wind field, wherein the target wind field includes the local wind field; determining a periodic offset of the target virtual object based on the periodic function and the mapping coordinates, wherein the first offset includes a periodic offset.
[0120] Optionally, the second determination submodule is also used to determine a second offset of a virtual game character in a game scene to a target virtual object based on the mapping coordinates through the following steps: obtaining a target distance between the virtual game character and the target virtual object; determining that the target distance is within a preset threshold range, and the mapping coordinates determine the position of the vertices of the target virtual object; determining a target vector based on the position of the virtual game character and the position of the vertices of the target virtual object; and determining a second offset based on the target vector.
[0121] Optionally, the determining unit 93 includes: a fourth determining module, configured to determine rotation information of the multiple target virtual objects based on the mapping coordinates of the multiple target virtual objects.
[0122] In the processing device of the target virtual object of this embodiment, the target point information of the target virtual object is mapped to the target map associated with the target virtual object to obtain the map coordinates, thereby solving the true rotation center around which the virtual object rotates, and calculating the obtained map coordinates to determine the rotation information of the target virtual object, so as to achieve the purpose of controlling the rotation of the target virtual object. This makes the stretching degree of the target virtual object relatively low, solves the technical problem of not being able to effectively reduce the stretching feeling when the virtual object moves, thereby achieving the technical problem of effectively reducing the stretching feeling when the virtual object moves.
[0123] The embodiment of the present invention further provides a computer-readable storage medium. The computer-readable storage medium stores a computer program, wherein when the computer program is executed by a processor, the device where the computer-readable storage medium is located is controlled to execute the virtual object processing method of the embodiment of the present invention.
[0124] An embodiment of the present invention further provides an electronic device, which may include a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to execute the computer program to execute the virtual object processing method of the embodiment of the present invention.
[0125] Optionally, in this embodiment, the above-mentioned 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.
[0126] An embodiment of the present invention further provides an electronic device, 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 the steps in any one of the above method embodiments.
[0127] 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.
[0128] Obviously, those skilled in the art should understand that the above modules or steps of the present invention can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, and optionally, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order than here, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present invention is not limited to any specific combination of hardware and software.
[0129] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for processing a target virtual object, characterized in that: include: Acquire target point information of a target virtual object, wherein the target point information is used to represent a target point around which the target virtual object rotates; Mapping the target point information to a target map associated with the target virtual object to obtain the map coordinates of the target point; Determining rotation information of the target virtual object based on the mapping coordinates, wherein the rotation information is used to control the rotation of the target virtual object in the game scene; Wherein, determining the rotation information of the target virtual object based on the map coordinates includes: determining a first offset of the target wind field of the game scene to the target virtual object based on the map coordinates, and / or determining a second offset of the virtual game character in the game scene to the target virtual object based on the map coordinates; determining the rotation information based on the first offset and / or the second offset.
2. The method according to claim 1, characterized in that: Get the target point information of the target virtual object, including: Obtaining vertices of the target virtual object; The vertex is determined as the target point, and the position information of the vertex is determined as the target point information.
3. The method according to claim 2, characterized in that The method further comprises: obtaining a target number of vertices; Mapping the target point information to a target map associated with the target virtual object to obtain the map coordinates of the target point includes: mapping the position information of the vertex to the target map based on the target quantity to obtain the map coordinates.
4. The method according to claim 1, characterized in that The method of determining a first offset of a target wind field of the game scene to the target virtual object based on the mapping coordinates, and / or determining a second offset of a virtual game character in the game scene to the target virtual object based on the mapping coordinates, comprises: In the target engine, the first offset and / or the second offset are determined based on the texture coordinates.
5. The method according to claim 1, characterized in that The rotation information includes at least a rotation direction and a rotation axis of the virtual object, and the rotation axis is used to indicate a direction of the target wind field.
6. The method according to claim 1, characterized in that Determining a first offset of a target wind field of the game scene to the target virtual object based on the mapping coordinates includes: Acquire a wind field map corresponding to a global wind field, wherein the target wind field includes the global wind field, and the wind field map is used to represent a wind field change state in the game scene; Based on the wind field map and the map coordinates, a wind wave fluctuation offset of the target wind field to the target virtual object in at least one direction is determined, wherein the first offset includes the wind wave fluctuation offset.
7. The method according to claim 1 or 6, characterized in that: Determining a first offset of a target wind field of the game scene to the target virtual object based on the mapping coordinates includes: Determining a periodic function under a local wind field, wherein the target wind field includes the local wind field; A periodic offset of the target virtual object is determined based on the periodic function and the mapping coordinates, wherein the first offset includes the periodic offset.
8. The method according to claim 1, characterized in that: Determining a second offset of the virtual game character in the game scene to the target virtual object based on the mapping coordinates includes: Acquire a target distance between the virtual game character and the target virtual object; Determining that the target distance is within a preset threshold range, and determining the position of the vertex of the target virtual object based on the mapping coordinates; Determine a target vector based on the position of the virtual game character and the positions of the vertices of the target virtual object; The second offset is determined based on the target vector.
9. The method according to claim 1, characterized in that: Determining the rotation information of the target virtual object based on the mapping coordinates includes: Based on the mapping coordinates of the plurality of target virtual objects, rotation information of the plurality of target virtual objects is determined.
10. A processing device for a target virtual object, characterized in that: include: An acquisition unit, used to acquire target point information of a target virtual object, wherein the target point information is used to represent a target point around which the target virtual object rotates; A mapping unit, used for mapping the target point information to a target map associated with the target virtual object to obtain the map coordinates of the target point; A determination unit, configured to determine rotation information of the target virtual object based on the mapping coordinates, wherein the rotation information is used to control the rotation of the target virtual object in the game scene; Wherein, the determination unit is used to determine the rotation information of the target virtual object based on the map coordinates through the following steps: determining a first offset of the target wind field of the game scene to the target virtual object based on the map coordinates, and / or determining a second offset of the virtual game character in the game scene to the target virtual object based on the map coordinates; determining the rotation information based on the first offset and / or the second offset.
11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein when the computer program is executed by a processor, the device where the computer-readable storage medium is located is controlled to execute the method described in any one of claims 1 to 9.
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 execute the computer program to perform the method according to any one of claims 1 to 9.
Citation Information
Patent Citations
Game image processing method and device, storage medium and electronic equipment
CN112827169A
Game data processing method and device and storage medium
CN112870704A