Method, device, electronic device and storage medium for processing drop of virtual objects
By constructing the object coordinate system and motion parameters of virtual objects on the game client, the problem of single motion trajectory and high computational pressure in virtual object drop processing is solved, and a more realistic item drop effect and synchronous motion trajectory are achieved.
Patent Information
- Application Number
- CN202210994336.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-17
- Publication Date
- 2025-08-22
- Estimated Expiration
- 2042-08-17
AI Technical Summary
In the prior art, the drop processing of virtual objects has problems such as single motion trajectory, poor performance and high server-side computing pressure.
In the game client responds to the item drop command, determines the item parameters of the virtual object, builds the vertex coordinates under the object coordinate system and creates a virtual object model, obtains the drop points and motion parameters of the server, and controls the virtual object model to perform drop motion.
It improves the authenticity and performance of item drops, reduces the computing pressure on the server, and ensures the consistency of the drop process in different clients.
Smart Images

Figure CN115337646B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of game technology, and in particular to a method for processing the drop of a virtual object, a device for processing the drop of a virtual object, an electronic device, and a computer-readable storage medium. Background Art
[0002] With the development of gaming technology and the widespread adoption of smart devices, gaming has become an important form of entertainment in people's daily lives. In some games, when players defeat a boss or enemy character, or collect resources within a game scene, virtual objects may drop from them. By manipulating the drop trajectory of virtual objects to more closely resemble the way objects drop in the real world, the player's gaming experience can be effectively enhanced. For these drop scenarios, either the virtual object is dropped along a fixed trajectory, or the server calculates the trajectory and sends it to the client. Fixed trajectories result in a fixed drop trajectory, lacking dynamic performance and resulting in poor performance. Dynamically calculating the trajectory on the server relies on server-side computation, significantly increasing the server's computational burden, cost, and performance overhead. Summary of the Invention
[0003] An embodiment of the present invention provides a method, device, electronic device and computer-readable storage medium for processing the drop of virtual objects in games, so as to solve or partially solve the problems of single motion trajectory, poor performance and high computing pressure on the server side during the drop processing of virtual objects in games.
[0004] An embodiment of the present invention discloses a method for processing a drop of a virtual object, comprising:
[0005] In response to an item drop instruction, determining a virtual object corresponding to the item drop instruction, and obtaining item parameters corresponding to the virtual object, wherein the virtual object corresponds to an object coordinate system, and the item parameters are parameters determined based on the object coordinate system;
[0006] determining, based on the object parameters, vertex coordinates of each vertex in the virtual object in the object coordinate system, and constructing a virtual object model corresponding to the vertex coordinates;
[0007] Obtaining the drop point of the virtual object in the game scene sent by the server, and determining the motion parameters corresponding to the drop point;
[0008] The virtual object model is controlled according to the motion parameters to perform a corresponding falling motion with the falling point as a starting point.
[0009] Optionally, the item parameters include at least the coordinates of an origin in an object coordinate system constructed based on the origin of the virtual object, a vertex distance between each vertex and the origin in the object coordinate system, and an angle between each vertex and a coordinate axis in the object coordinate system. Determining, based on the item parameters, the vertex coordinates of each vertex in the virtual object in the object coordinate system includes:
[0010] The vertex distance and the coordinate axis angle are used to calculate the vertex coordinates of each vertex in the virtual object in the object coordinate system.
[0011] Optionally, the coordinate axis angle includes a y-axis angle between a line connecting the vertex and the origin and the y-axis, and a z-axis angle between a line connecting a projection point of the vertex onto a plane formed by the x-axis and the z-axis and the origin and the z-axis, and calculating the vertex coordinates of each vertex in the virtual object in the object coordinate system using the vertex distance and the coordinate axis angle includes:
[0012] Obtain a first sine value and a first cosine value corresponding to the y-axis angle, and a second sine value and a second cosine value corresponding to the z-axis angle;
[0013] Calculate the x-axis coordinate of the vertex in the object coordinate system using the vertex distance, the first sine value, and the second sine value;
[0014] Calculate the y-axis coordinate of the vertex in the object coordinate system using the vertex distance and the first cosine value;
[0015] The z-axis coordinate of the vertex in the object coordinate system is calculated using the vertex distance, the first sine value, and the second cosine value.
[0016] Optionally, the game scene corresponds to a scene coordinate system, the drop point corresponds to target coordinates in the scene coordinate system, and determining the motion parameter corresponding to the drop point includes:
[0017] Calculating a random seed value for the virtual object using the target coordinates;
[0018] Acquiring a motion parameter range corresponding to the virtual object;
[0019] The random seed value is used to calculate motion parameters within the motion parameter range.
[0020] Optionally, the motion parameter range includes at least a force value range, a horizontal angle range, and a rotation speed range, and the using the random seed value to calculate the motion parameter within the motion parameter range includes:
[0021] The random seed value is used to calculate the ejection force value, the ejection angle within the horizontal angle range, and the rotation speed within the rotation speed range.
[0022] Optionally, controlling the virtual object model to perform a corresponding dropping motion with the dropping point as a starting point according to the motion parameter includes:
[0023] The virtual object model is controlled along the throwing angle according to the rotation speed and the throwing force value to perform a corresponding dropping motion with the dropping point as a starting point.
[0024] Optionally, obtaining a motion parameter range corresponding to the virtual object includes:
[0025] Volume information of the virtual object and a target motion parameter range corresponding to the volume information are obtained, where different volume information corresponds to different motion parameter ranges.
[0026] The embodiment of the present invention further discloses a device for processing a drop of a virtual object, comprising:
[0027] an item parameter acquisition module, configured to, in response to an item drop instruction, determine a virtual object corresponding to the item drop instruction and acquire item parameters corresponding to the virtual object, wherein the virtual object corresponds to an object coordinate system, and the item parameters are parameters determined based on the object coordinate system;
[0028] a model building module, configured to determine, based on the object parameters, vertex coordinates of each vertex in the virtual object in the object coordinate system, and to build a virtual object model corresponding to the vertex coordinates;
[0029] A motion parameter determination module, configured to obtain a drop point of the virtual object in the game scene sent by the server, and determine motion parameters corresponding to the drop point;
[0030] The falling motion execution module is used to control the virtual object model to execute the corresponding falling motion with the falling point as the starting point according to the motion parameters.
[0031] Optionally, the item parameters include at least the coordinates of the origin in an object coordinate system constructed based on the origin of the virtual object, the vertex distance between each vertex and the origin in the object coordinate system, and the angle between each vertex and a coordinate axis in the object coordinate system. The model construction module is specifically configured to:
[0032] The vertex distance and the coordinate axis angle are used to calculate the vertex coordinates of each vertex in the virtual object in the object coordinate system.
[0033] Optionally, the coordinate axis angle includes a y-axis angle between a line connecting the vertex and the origin and the y-axis, and a z-axis angle between a line connecting a projection point of the vertex onto a plane formed by the x-axis and the z-axis and the origin and the z-axis, and the model building module is specifically configured to:
[0034] Obtain a first sine value and a first cosine value corresponding to the y-axis angle, and a second sine value and a second cosine value corresponding to the z-axis angle;
[0035] Calculate the x-axis coordinate of the vertex in the object coordinate system using the vertex distance, the first sine value, and the second sine value;
[0036] Calculate the y-axis coordinate of the vertex in the object coordinate system using the vertex distance and the first cosine value;
[0037] The z-axis coordinate of the vertex in the object coordinate system is calculated using the vertex distance, the first sine value, and the second cosine value.
[0038] Optionally, the game scene corresponds to a scene coordinate system, and the motion parameter determination module is specifically configured to:
[0039] Calculating a random seed value for the virtual object using the target coordinates;
[0040] Acquiring a motion parameter range corresponding to the virtual object;
[0041] The random seed value is used to calculate motion parameters within the motion parameter range.
[0042] Optionally, the motion parameter range includes at least a force value range, a horizontal angle range, and a rotation speed range, and the motion parameter determination module is specifically configured to:
[0043] The random seed value is used to calculate the ejection force value, the ejection angle within the horizontal angle range, and the rotation speed within the rotation speed range.
[0044] Optionally, the falling motion execution module is specifically configured to:
[0045] The virtual object model is controlled along the throwing angle according to the rotation speed and the throwing force value to perform a corresponding dropping motion with the dropping point as a starting point.
[0046] Optionally, the motion parameter determination module is specifically configured to:
[0047] Volume information of the virtual object and a target motion parameter range corresponding to the volume information are obtained, where different volume information corresponds to different motion parameter ranges.
[0048] An embodiment of the present invention further discloses an electronic device, comprising a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other via the communication bus;
[0049] The memory is used to store computer programs;
[0050] The processor is configured to implement the method described in the embodiment of the present invention when executing the program stored in the memory.
[0051] An embodiment of the present invention further discloses a computer-readable storage medium having instructions stored thereon. When executed by one or more processors, the processors are enabled to execute the method according to the embodiment of the present invention.
[0052] The embodiments of the present invention include the following advantages:
[0053] In an embodiment of the present invention, in a game, in an item drop scene, a game client can respond to an item drop instruction, determine a virtual object corresponding to the item drop instruction, and obtain item parameters corresponding to the virtual object. The virtual object corresponds to an object coordinate system, and the item parameters are parameters determined based on the object coordinate system. Then, based on the item parameters, the vertex coordinates of each vertex in the virtual object in the object coordinate system are determined, and a virtual object model corresponding to the vertex coordinates is constructed. By creating a model that fits the virtual object, it is possible to avoid the model from sinking, penetrating, floating, etc. when a collision occurs during the item drop process in the game, thereby improving the realism of the item drop. At the same time, the game client can obtain the drop point of the virtual object sent by the server in the game scene, determine the motion parameters corresponding to the drop point, and then control the virtual object model according to the motion parameters to perform the corresponding drop motion with the drop point as the starting point. On the one hand, the client performs the motion trajectory calculation, which can effectively reduce the computing pressure of the server. On the other hand, based on the motion parameters determined by the same drop point, the motion trajectory calculated by each client is the same, thereby ensuring that the drop process of the same item in different clients is the same, and ensuring the synchronization of the item drop motion trajectory in the game. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] Figure 1 This is a flowchart of a method for handling a drop of a virtual object provided in an embodiment of the present invention;
[0055] Figure 2 is a schematic diagram of an object coordinate system provided in an embodiment of the present invention;
[0056] Figure 3 is a schematic diagram of a virtual object provided in an embodiment of the present invention;
[0057] Figure 4 is a structural block diagram of a virtual object drop processing device provided in an embodiment of the present invention;
[0058] Figure 5 This is a block diagram of an electronic device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0059] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0060] As an example, in-game item drops can typically be implemented in the following ways: 1. Dropped items are generated directly on the ground, and a fixed trajectory effect is played between the boss's death and the item's spawning to create a transition; 2. The server performs a unified motion trajectory simulation. When the boss dies, the server calculates the item's trajectory and then synchronizes the item's current position to each client in real time, ensuring that each client sees the same trajectory and position as the dropped item. However, the first solution has the advantage of being simple to implement, as the dropped items are stationary, and the directly generated positions of each client are guaranteed to be synchronized. However, its disadvantage is also obvious: it lacks the physical motion trajectory of the item in the air and after it lands. Even if trajectory effects are used to compensate for this, the trajectory effects are fixed and cannot be dynamically expressed, resulting in poor performance. For the second solution, although it can simulate the motion trajectory of dropped objects, it can only simulate simple motion trajectories, such as vertical drop, upward throw, horizontal throw, etc., and for some fine and complex motion trajectories: for example, after landing, the dropped objects hit the slope and need to bounce back, the kinetic energy decays, and roll until they stop, the fine performance is relatively weak, and it also relies on the server's calculations, which easily increases the server's computing pressure.
[0061] In this regard, one of the core inventive aspects of the present invention lies in its application to game clients. During gameplay, when an item is dropped, the game client can respond to the item drop command and determine the virtual object corresponding to the item drop command. Then, based on the item parameters corresponding to the virtual object, a matching virtual object model is created. This virtual object model can be a model visible and operable by the player in the game scene. By creating a model that fits the virtual object, it is possible to avoid situations such as the model sinking, clipping, or floating in the air during collisions during the game item drop, thereby improving the realism of the item drop and optimizing the performance. Simultaneously, while creating the virtual object model, the game client can obtain the drop point corresponding to the virtual object sent by the server. Based on this drop point, the game client then determines the motion parameters of the model in the game scene. Based on the motion parameters, the game client controls the virtual object model to execute the corresponding drop motion starting from the drop point. This allows the client to calculate the motion trajectory, effectively reducing the computational burden on the server. Furthermore, based on the motion parameters determined at the same drop point, the motion trajectory calculated by each client is identical, ensuring that the drop process of the same item on different clients is identical and ensuring the synchronization of the item drop motion trajectories in the game.
[0062] In order to enable those skilled in the art to better understand the technical solutions of the embodiments of the present invention, some technical features involved in the embodiments of the present invention are explained and illustrated below:
[0063] Virtual objects can be virtual items in the game, such as art models designed by artists that are associated with the game scene and gameplay. These art models are invisible and inoperable to the player in the game. To address this, during the item drop process, the desired item is first determined, and then a physical rigid body corresponding to the item is created, i.e., the virtual object model. This model is visible and operable to the player in the game scene.
[0064] Each virtual object has an origin in the object coordinate system. This origin can be used to establish an object coordinate system for the virtual object. Different virtual objects can correspond to different object coordinate systems. Correspondingly, the scene coordinate system can be the spatial coordinate system corresponding to the game scene. A game scene only corresponds to one spatial coordinate system.
[0065] Specifically, refer to Figure 1 , shows a flowchart of a method for handling a drop of a virtual object provided in an embodiment of the present invention, which may specifically include the following steps:
[0066] Step 101: In response to an item drop instruction, determine a virtual object corresponding to the item drop instruction, and obtain item parameters corresponding to the virtual object, wherein the virtual object corresponds to an object coordinate system, and the item parameters are parameters determined based on the object coordinate system;
[0067] In an embodiment of the present invention, it can be applied to a game client (hereinafter referred to as the client), which can be an application running on an electronic device. During the game, the client can implement corresponding game content by performing corresponding data interaction with the server.
[0068] In the game, item drops may include items dropped in the game scene when the player kills the corresponding game boss or enemy player character, collects a resource object (such as ore, trees, etc.) in the game scene, opens a treasure chest, etc. The item drop instructions may include resource object drop instructions and loot drop instructions, etc., which correspond to different item drop scenarios in the game.
[0069] In a specific implementation, when an item drops in the game, the server can send an item drop command to the client. The client can then determine the virtual object corresponding to the item drop command and obtain the item parameters corresponding to the virtual object. This virtual object is not yet a model displayed to the player in the game scene, but rather determines what item will be dropped in the game scene. Therefore, in order to display the corresponding model in the game scene so that the player can pick up the model and other operations, it is necessary to build an appropriate virtual object model based on the corresponding item parameters of the virtual object.
[0070] Step 102: determining the vertex coordinates of each vertex in the virtual object in the object coordinate system according to the object parameters, and constructing a virtual object model corresponding to the vertex coordinates;
[0071] For virtual objects, which are invisible and inoperable to players in the game, in order to make the virtual objects visible and operable (i.e., have physical collisions in the game scene), it is necessary to add corresponding physical rigid bodies to the virtual objects so that they can be supported by the ground in the game scene. The shape of the physical rigid body can include basic geometric shapes, such as cubes, spheres, capsules, or custom polygons. For example, assuming that the virtual object is a tetrahedron crystal, a basic geometric shape body, such as a sphere, can be added to the tetrahedron crystal, so that the tetrahedron crystal can have collisions in the game scene and can stop when it falls to the ground of the game scene.
[0072] It should be noted that for virtual objects, they can be art models designed by artists. After adding the corresponding physical rigid body to the art model, a virtual object model with the appearance corresponding to the art model and collision effect can be obtained in the game scene. Players can operate the virtual object model in the game, such as picking it up.
[0073] Among them, in the process of adding a physical rigid body, if the physical rigid body and the virtual object are not well fitted, when the volume of the physical rigid body is smaller than the volume of the virtual object, when the constructed virtual object model falls to the ground of the game scene, although the physical rigid body is supported by the game ground, a part of the virtual object model will sink into the ground. Moreover, considering that the virtual object model will collide and bounce continuously until it stops on the ground, and the collision is based on the physical rigid body, each collision will cause the virtual object model to sink into the wall or the ground, seriously affecting the performance of the virtual object in the game; when the volume of the physical rigid body is larger than the volume of the virtual object, when the constructed virtual object model falls to the ground of the game scene, the virtual object model will float, which also affects the performance of the virtual object in the game. To this end, it is necessary to ensure that the physical rigid body and the virtual object fit together to ensure the performance of the virtual object in the game.
[0074] For virtual objects, when constructing virtual objects (the art model), artists can use an origin as a reference point for construction. Different virtual objects can correspond to different origins, and different virtual objects can correspond to different object coordinate systems. The present invention does not impose any restrictions on this.
[0075] In a specific implementation, the item parameters include at least the origin coordinates in the object coordinate system constructed based on the origin of the virtual object, the vertex distance between each vertex and the origin in the object coordinate system, and the coordinate axis angle between each vertex and the coordinate axis in the object coordinate system. The client can use the vertex distance and the coordinate axis angle to calculate the vertex coordinates of each vertex in the virtual object in the object coordinate system, and then create a physical rigid body that fits the virtual object based on the vertex coordinates, and combine the physical rigid body with the virtual object to obtain the corresponding virtual object model, so that the player can operate the virtual object model in the game.
[0076] It should be noted that for each virtual object, it corresponds to an origin and includes several vertices. Then, in the object coordinate system corresponding to the virtual object, the vertex distance between each vertex and the origin can be obtained in turn, and a line can be connected between the vertex and the origin to obtain the coordinate axis angle between the connecting line and the coordinate axis, so as to calculate the vertex coordinates of each vertex in the object coordinate system based on the vertex distance and the coordinate axis angle.
[0077] In a specific implementation, the coordinate axis angle may include the y-axis angle between the line between the vertex and the origin and the y-axis, and the z-axis angle between the line between the projection point of the vertex projected onto the plane formed by the x-axis and z-axis and the origin and the z-axis. For each vertex, the client may first obtain the first sine value and first cosine value corresponding to the y-axis angle corresponding to the vertex, as well as the second sine value and second cosine value corresponding to the z-axis angle, and then use the vertex distance, the first sine value and the second sine value to calculate the x-axis coordinate of the vertex in the object coordinate system, use the vertex distance and the first cosine value to calculate the y-axis coordinate of the vertex in the object coordinate system, and use the vertex distance, the first sine value and the second cosine value to calculate the z-axis coordinate of the vertex in the object coordinate system, thereby obtaining the vertex coordinates of the vertex in the object coordinate system.
[0078] In one example, referring to Figure 2 , shows a schematic diagram of the object coordinate system provided in an embodiment of the present invention, wherein the distance between the vertex and the origin o of the coordinate system can be defined as r, the angle between the vertex and the y-axis is defined as θ, and the angle between the projection point of the vertex onto the xoz plane and the z-axis is defined as ψ. According to the calculation formula of the three-dimensional coordinates, the coordinates of any vertex P on the virtual object can be obtained as: x = r sinθsinψ, y = r cosθ, z = r sinθcosψ.
[0079] After obtaining the vertex coordinates corresponding to each vertex on the virtual object, the vertex coordinates corresponding to each vertex can be passed into the physics engine corresponding to the game client to create an interface for a physical rigid body. The physics engine can then create an irregular polyhedron physical rigid body that fits the virtual object based on the vertex coordinates corresponding to each vertex. The physical rigid body can then be combined with the virtual object (using the virtual object as the appearance and the physical rigid body as the "filler content" to obtain a virtual object model that can be displayed in the game scene and supports player operations). By creating a model that fits the virtual object, it is possible to avoid situations such as the model sinking, penetrating, or floating in the air when collisions occur during the falling of items in the game, thereby improving the realism of the falling items and optimizing the performance effect.
[0080] Step 103: Obtain the drop point of the virtual object in the game scene sent by the server, and determine the motion parameters corresponding to the drop point;
[0081] While constructing the virtual object model corresponding to the virtual object, the client can also obtain the drop point of the virtual object in the game scene sent by the server and determine the motion parameters corresponding to the drop point, so as to control the virtual object model to perform the corresponding movement in the game scene according to the motion parameters. Optionally, for different drop points, different drop scenes have different corresponding drop points. For example, when it is a resource drop, the drop point can be the coordinates of the resource object in the game scene; when it is to kill the game boss or enemy player character, the drop point can be the coordinates of the game boss or enemy player character when they die in the game, etc. The above coordinates are based on the coordinates in the scene coordinate system corresponding to the game scene.
[0082] In a specific implementation, different clients receive the same drop point, which can be the target coordinate in the scene coordinate system. The client can use the target coordinate to calculate the random seed value for the virtual object, obtain the range of motion parameters corresponding to the virtual object, and then use the random seed value to calculate the motion parameters within the range of motion parameters. For the random seed value, different coordinates can generate different values. Since the drop point received by each client is the same, the generated random seed value is also the same. Specifically, considering that the movement of the virtual object model in the game scene involves the throwing force value, throwing direction and rotation speed, in the process of determining the throwing force value, throwing direction and rotation speed based on the random seed value, the range of the throwing force value, the angle of the throwing direction and the upper and lower limits of the rotation speed can be constrained, so that the client can use the random seed value to calculate the throwing force value, the throwing angle within the horizontal angle range and the rotation speed within the rotation speed range.
[0083] Among them, the throwing force value can be the force (unit: N) when the virtual object model is thrown from the drop point, the throwing direction can be the horizontal direction interval [0, 360°], and the rotation speed can be the rotation speed of the virtual object model when it is thrown, etc. For these motion parameter ranges, on the one hand, they can be set based on different virtual objects, and on the other hand, they can also be set according to actual needs in the game. Optionally, in order to improve the authenticity of the falling movement of the virtual object model, the client can obtain the corresponding motion parameter range based on the volume information of the virtual object. For example, the larger the volume, the greater the throwing force value, the lower the throwing direction, and the lower the rotation speed; the smaller the volume, the smaller the throwing force value, the higher the throwing direction, and the higher the rotation speed, etc. The present invention does not impose any restrictions on this.
[0084] In one example, in order to make the motion rules of the virtual object models of each client consistent, it is necessary to ensure that the input parameters of the projectile motion of the virtual object model: throwing force, throwing direction, rotation speed, etc. are consistent, and each input parameter is as random as possible. To this end, after obtaining the target coordinates corresponding to the drop point, the corresponding random seed value can be calculated based on the target coordinates. The random seed calculation formula is as follows: random seed seed = exit point pos.x*100 + exit point pos.y*10 + exit point pos.z. Since the drop point obtained by each client is consistent, the calculated random seed value is also consistent. Based on this calculated consistent random seed, the random force, throwing direction, and rotation speed are all consistent.
[0085] It should be noted that in addition to the throwing force value, the corresponding gravity value can also be obtained for the above-mentioned process of calculating motion parameters. The gravity value can ensure that the virtual object model's falling motion in the game scene is always downward and eventually comes to rest on the ground of the game scene. Specifically, the gravity value can be a fixed value that is greater than the throwing force value. Its corresponding direction is downward, that is, the negative direction of the y-axis in the scene coordinate system, while the throwing force value corresponds to the positive direction of the y-axis. When the projectile motion is triggered, the two forces are superimposed to ensure that the final acceleration in the vertical direction is a negative value, causing the dropped object to fall vertically. Without the guarantee of gravity, if the acceleration in the vertical direction is a positive value, the dropped object will not appear to be falling, but will instead fly upward, flying out of the scene faster and faster, which is inconsistent with the dropping of virtual items in the game.
[0086] Step 104 : Control the virtual object model to perform a corresponding falling motion with the falling point as a starting point according to the motion parameters.
[0087] In the specific implementation, after the client calculates the throwing force value, throwing direction and rotation speed corresponding to the virtual object, the client can control the virtual object model along the throwing angle according to the rotation speed and throwing force value to perform the corresponding dropping motion with the dropping point as the starting point. On the one hand, the client performs the motion trajectory calculation, which can effectively reduce the computing pressure of the server. On the other hand, based on the motion parameters determined based on the same drop point, the motion trajectory calculated by each client is the same, thereby ensuring that the dropping process of the same item in different clients is the same, and ensuring the synchronization of the item dropping motion trajectory in the game.
[0088] Based on the same projectile motion input parameters, each client achieves the same trajectory. After the virtual object model hits the ground or an inclined surface, the output of the physics engine simulation is consistent across all clients, ensuring consistent rebound motion input. This ensures a consistent trajectory in the next round of oblique projectile motion. This cycle repeats until the object stops, maintaining a consistent trajectory. This ensures that the irregular polyhedron falls with the same trajectory and position across all clients.
[0089] In an embodiment of the present invention, in a game, in an item drop scene, a game client can respond to an item drop instruction, determine a virtual object corresponding to the item drop instruction, and obtain item parameters corresponding to the virtual object. The virtual object corresponds to an object coordinate system, and the item parameters are parameters determined based on the object coordinate system. Then, based on the item parameters, the vertex coordinates of each vertex in the virtual object in the object coordinate system are determined, and a virtual object model corresponding to the vertex coordinates is constructed. By creating a model that fits the virtual object, it is possible to avoid the model from sinking, penetrating, floating, etc. when a collision occurs during the item drop process in the game, thereby improving the realism of the item drop. At the same time, the game client can obtain the drop point of the virtual object sent by the server in the game scene, determine the motion parameters corresponding to the drop point, and then control the virtual object model according to the motion parameters to perform the corresponding drop motion with the drop point as the starting point. On the one hand, the client performs the motion trajectory calculation, which can effectively reduce the computing pressure of the server. On the other hand, based on the motion parameters determined by the same drop point, the motion trajectory calculated by each client is the same, thereby ensuring that the drop process of the same item in different clients is the same, and ensuring the synchronization of the item drop motion trajectory in the game.
[0090] In order to help those skilled in the art better understand the technical solutions of the embodiments of the present invention, an example is given below to illustrate:
[0091] Assuming that the virtual object is a tetrahedron crystal, in order to make the tetrahedron crystal visible and operable in the game, and to have corresponding physical collisions, it is necessary to add a corresponding physical rigid body to the tetrahedron crystal so that it can be supported by the ground of the game scene.
[0092] In practice, when an item drop is triggered, the server can notify each participating client to create a drop item. At the same time, the server can also generate the drop's launch point (pos), which is a three-dimensional vector (x, y, z). This launch point is also synchronized to each client along with the signal to create the drop item.
[0093] For the client, it can first build the object rigid body corresponding to the dropped object, refer to Figure 3, shows a schematic diagram of a virtual object provided in an embodiment of the present invention. When the dropped object is a tetrahedron crystal, and the origin of the tetrahedron crystal is located at the bottom surface and there is exactly one vertex located on the y-axis, assuming that the edge length is a, the coordinates of one of the vertices can be obtained as (0, 0), then for the three vertices on the xoz plane, since the base is an equilateral triangle, that is, the angle is 60 degrees, then the remaining three points are obtained:
[0094]
[0095]
[0096]
[0097] Then the corresponding vertex data is:
[0098]
[0099] By replacing the edge length with the actual triangle block data, we can get a perfectly fitting tetrahedron crystal physical rigid body:
[0100]
[0101] After obtaining the vertex coordinates corresponding to each vertex of the virtual object through the above process, the vertex coordinates can be input into the physics engine corresponding to the game to generate a physical rigid body, and the physical rigid body can be combined with the dropped object to obtain the corresponding dropped object model (i.e., tetrahedral crystal model).
[0102] Once the tetrahedron model is constructed, it is positioned at the exit point, ready to execute the corresponding projectile motion according to the input parameters, such as force, direction of throw, and speed. Regarding the motion parameters, to ensure consistent motion rules for all dropped objects across clients, the input parameters for the projectile motion—force, direction of throw, and speed—must be consistent. Each input parameter must be as random as possible. The random seed calculation formula is: random seed = exit point pos.x * 100 + exit point pos.y * 10 + exit point pos.z. Since each client receives the same exit point, the calculated random seed value is also consistent. Based on this consistent calculated random seed, the random force, direction of throw, and speed are all consistent.
[0103] Specifically, you can first define the ranges for force, direction, and speed. For example, the force range is [0, 10] Newtons, the direction is defined as the horizontal range [0, 360] degrees, and the speed range is [0, 5] m / s. The resulting random force, direction, and speed are all guaranteed to fall within the corresponding ranges. The values obtained vary depending on the random seed value. For example, if the random seed value is 13674, then according to the algorithm's mapping, the resulting force is 5.73 Newtons, the angle is 132 degrees, and the speed is 2.81 m / s.
[0104] After the client calculates the throwing force value, throwing direction and rotation speed corresponding to the virtual object, the client can control the virtual object model along the throwing angle according to the rotation speed and throwing force value to perform the corresponding dropping motion with the dropping point as the starting point. On the one hand, the client performs the motion trajectory calculation, which can effectively reduce the computing pressure of the server. On the other hand, based on the motion parameters determined by the same drop point, the motion trajectory calculated by each client is the same, thereby ensuring that the dropping process of the same item in different clients is the same, and ensuring the synchronization of the item dropping motion trajectory in the game.
[0105] It should be noted that for the sake of simplicity, the method embodiments are described as a series of actions. However, those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in this specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.
[0106] Reference Figure 4 , shows a structural block diagram of a virtual object drop processing device provided in an embodiment of the present invention, which may specifically include the following modules:
[0107] The item parameter acquisition module 401 is configured to, in response to an item drop instruction, determine a virtual object corresponding to the item drop instruction and obtain item parameters corresponding to the virtual object, wherein the virtual object corresponds to an object coordinate system, and the item parameters are parameters determined based on the object coordinate system;
[0108] A model building module 402 is configured to determine, based on the object parameters, vertex coordinates of each vertex in the virtual object in the object coordinate system, and to build a virtual object model corresponding to the vertex coordinates;
[0109] The motion parameter determination module 403 is used to obtain the drop point of the virtual object in the game scene sent by the server and determine the motion parameters corresponding to the drop point;
[0110] The falling motion execution module 404 is configured to control the virtual object model to execute a corresponding falling motion with the falling point as a starting point according to the motion parameters.
[0111] In an optional embodiment, the item parameters include at least the coordinates of the origin in an object coordinate system constructed based on the origin of the virtual object, the vertex distance between each vertex and the origin in the object coordinate system, and the angle between each vertex and a coordinate axis in the object coordinate system. The model construction module 402 is specifically configured to:
[0112] The vertex distance and the coordinate axis angle are used to calculate the vertex coordinates of each vertex in the virtual object in the object coordinate system.
[0113] In an optional embodiment, the coordinate axis angle includes a y-axis angle between a line connecting the vertex and the origin and the y-axis, and a z-axis angle between a line connecting a projection point of the vertex onto a plane formed by the x-axis and the z-axis and the origin and the z-axis. The model construction module 402 is specifically configured to:
[0114] Obtain a first sine value and a first cosine value corresponding to the y-axis angle, and a second sine value and a second cosine value corresponding to the z-axis angle;
[0115] Calculate the x-axis coordinate of the vertex in the object coordinate system using the vertex distance, the first sine value, and the second sine value;
[0116] Calculate the y-axis coordinate of the vertex in the object coordinate system using the vertex distance and the first cosine value;
[0117] The z-axis coordinate of the vertex in the object coordinate system is calculated using the vertex distance, the first sine value, and the second cosine value.
[0118] In an optional embodiment, the game scene corresponds to a scene coordinate system, and the motion parameter determination module 403 is specifically configured to:
[0119] Calculating a random seed value for the virtual object using the target coordinates;
[0120] Acquiring a motion parameter range corresponding to the virtual object;
[0121] The random seed value is used to calculate motion parameters within the motion parameter range.
[0122] In an optional embodiment, the motion parameter range includes at least a force value range, a horizontal angle range, and a rotation speed range, and the motion parameter determination module 403 is specifically configured to:
[0123] The random seed value is used to calculate the ejection force value, the ejection angle within the horizontal angle range, and the rotation speed within the rotation speed range.
[0124] In an optional embodiment, the dropping motion execution module 404 is specifically configured to:
[0125] The virtual object model is controlled along the throwing angle according to the rotation speed and the throwing force value to perform a corresponding dropping motion with the dropping point as a starting point.
[0126] In an optional embodiment, the motion parameter determination module 403 is specifically configured to:
[0127] Volume information of the virtual object and a target motion parameter range corresponding to the volume information are obtained, where different volume information corresponds to different motion parameter ranges.
[0128] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0129] In addition, an embodiment of the present invention also provides an electronic device, including: a processor, a memory, and a computer program stored in the memory and runnable on the processor. When the computer program is executed by the processor, the various processes of the above-mentioned virtual object drop processing method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0130] The present invention also provides a computer-readable storage medium having a computer program stored thereon. When executed by a processor, the computer program implements the various processes of the aforementioned embodiment of the method for handling the drop of a virtual object and achieves the same technical effect. To avoid repetition, the description thereof is omitted here. The computer-readable storage medium may be, for example, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0131] Figure 5 A schematic diagram of the hardware structure of an electronic device for implementing various embodiments of the present invention.
[0132] The electronic device 500 includes but is not limited to components such as a radio frequency unit 501, a network module 502, an audio output unit 503, an input unit 504, a sensor 505, a display unit 506, a user input unit 507, an interface unit 508, a memory 509, a processor 510, and a power supply 511. It will be understood by those skilled in the art that the electronic device structure involved in the embodiments of the present invention does not constitute a limitation on the electronic device, and the electronic device may include more or fewer components than shown, or combine certain components, or arrange the components differently. In the embodiments of the present invention, the electronic device includes but is not limited to a mobile phone, a tablet computer, a laptop computer, a PDA, a vehicle-mounted terminal, a wearable device, and a pedometer.
[0133] It should be understood that in this embodiment of the present invention, the RF unit 501 can be used to receive and transmit signals during information transmission or calls. Specifically, it receives downlink data from the base station and transmits it to the processor 510 for processing; in addition, it transmits uplink data to the base station. Typically, the RF unit 501 includes, but is not limited to, an antenna, at least one amplifier, a transceiver, a coupler, a low-noise amplifier, a duplexer, and the like. Furthermore, the RF unit 501 can communicate with the network and other devices via a wireless communication system.
[0134] The electronic device provides users with wireless broadband Internet access through the network module 502, such as helping users to send and receive emails, browse web pages, and access streaming media.
[0135] The audio output unit 503 can convert audio data received by the RF unit 501 or the network module 502 or stored in the memory 509 into an audio signal and output it as sound. In addition, the audio output unit 503 can also provide audio output related to a specific function performed by the electronic device 500 (for example, a call signal reception sound, a message reception sound, etc.). The audio output unit 503 includes a speaker, a buzzer, a receiver, etc.
[0136] The input unit 504 is used to receive audio or video signals. The input unit 504 may include a graphics processing unit (GPU) 5041 and a microphone 5042. The graphics processor 5041 processes image data of a still picture or video obtained by an image capture device (such as a camera) in a video capture mode or an image capture mode. The processed image frames can be displayed on the display unit 506. The image frames processed by the graphics processor 5041 can be stored in the memory 509 (or other storage medium) or transmitted via the radio frequency unit 501 or the network module 502. The microphone 5042 can receive sound and process such sound into audio data. The processed audio data can be converted into a format that can be sent to a mobile communication base station via the radio frequency unit 501 in the case of a telephone call mode.
[0137] The electronic device 500 also includes at least one sensor 505, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor includes an ambient light sensor and a proximity sensor, wherein the ambient light sensor can adjust the brightness of the display panel 5061 according to the brightness of the ambient light, and the proximity sensor can turn off the display panel 5061 and / or the backlight when the electronic device 500 is moved to the ear. As a type of motion sensor, the accelerometer sensor can detect the magnitude of acceleration in all directions (generally three axes), and can detect the magnitude and direction of gravity when stationary. It can be used to identify the posture of the electronic device (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer, tapping), etc.; the sensor 505 can also include a fingerprint sensor, a pressure sensor, an iris sensor, a molecular sensor, a gyroscope, a barometer, a hygrometer, a thermometer, an infrared sensor, etc., which will not be repeated here.
[0138] The display unit 506 is used to display information input by the user or information provided to the user. The display unit 506 may include a display panel 5061, which may be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), or the like.
[0139] The user input unit 507 can be used to receive input digital or character information, and to generate key signal input related to the user settings and function control of the electronic device. Specifically, the user input unit 507 includes a touch panel 5071 and other input devices 5072. The touch panel 5071, also known as a touch screen, can collect user touch operations on or near it (such as operations performed by the user using any suitable object or accessory such as a finger, stylus, etc. on or near the touch panel 5071). The touch panel 5071 may include two parts: a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch direction and detects the signal caused by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device and converts it into touch point coordinates, which are then sent to the processor 510, which receives and executes the command sent by the processor 510. In addition, the touch panel 5071 can be implemented using various types such as resistive, capacitive, infrared, and surface acoustic wave. In addition to the touch panel 5071, the user input unit 507 may also include other input devices 5072. Specifically, other input devices 5072 may include but are not limited to a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, and a joystick, which will not be described in detail here.
[0140] Furthermore, the touch panel 5071 may be overlaid on the display panel 5061. When the touch panel 5071 detects a touch operation on or near the touch panel 5071, the touch operation is transmitted to the processor 510 to determine the type of touch event. The processor 510 then provides a corresponding visual output on the display panel 5061 based on the type of touch event. It will be understood that in one embodiment, the touch panel 5071 and the display panel 5061 are two independent components to implement the input and output functions of the electronic device. However, in some embodiments, the touch panel 5071 and the display panel 5061 may be integrated to implement the input and output functions of the electronic device. The specific details are not limited here.
[0141] The interface unit 508 is an interface for connecting external devices to the electronic device 500. For example, the external devices may include a wired or wireless headset port, an external power supply (or battery charger) port, a wired or wireless data port, a memory card port, a port for connecting a device with an identification module, an audio input / output (I / O) port, a video I / O port, a headphone port, etc. The interface unit 508 may be used to receive input (e.g., data information, power, etc.) from the external device and transmit the received input to one or more elements within the electronic device 500, or may be used to transmit data between the electronic device 500 and the external device.
[0142] Memory 509 can be used to store software programs and various data. Memory 509 may primarily include a program storage area and a data storage area. The program storage area may store an operating system and at least one application required for a function (such as a sound playback function or an image playback function); the data storage area may store data generated based on the use of the mobile phone (such as audio data, a phone book, etc.). Furthermore, memory 509 may include high-speed random access memory and non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device.
[0143] The processor 510 is the control center of the electronic device. It connects the various components of the electronic device using various interfaces and circuits. By running or executing software programs and / or modules stored in the memory 509 and accessing data stored in the memory 509, it performs various functions of the electronic device and processes data, thereby monitoring the electronic device as a whole. The processor 510 may include one or more processing units; preferably, the processor 510 may integrate an application processor and a modem processor, wherein the application processor primarily processes the operating system, user interface, and application programs, while the modem processor primarily handles wireless communications. It is understood that the modem processor may not be integrated into the processor 510.
[0144] The electronic device 500 may also include a power supply 511 (such as a battery) to supply power to each component. Preferably, the power supply 511 may be logically connected to the processor 510 through a power management system, thereby managing functions such as charging, discharging, and power consumption through the power management system.
[0145] In addition, the electronic device 500 includes some functional modules not shown, which will not be described here.
[0146] It should be noted that, in this document, the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or apparatus comprising a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or apparatus comprising the element.
[0147] Through the description of the above embodiments, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus the necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better embodiment. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for enabling a terminal (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present invention.
[0148] The embodiments of the present invention are described above in conjunction with the accompanying drawings, but the present invention is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present invention, ordinary technicians in this field can also make many forms without departing from the scope of protection of the present invention and the claims, all of which are protected by the present invention.
[0149] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed in the embodiments of the present invention can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0150] Those skilled in the art will clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0151] In the embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of the units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0152] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0153] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0154] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, 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 for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes various media that can store program code, such as a USB flash drive, a mobile hard drive, ROM, RAM, a magnetic disk, or an optical disk.
[0155] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any modifications or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be based on the scope of protection of the claims.
Claims
1. A method for handling the drop of a virtual object, characterized in that: include: In response to an item drop instruction, determining a virtual object corresponding to the item drop instruction, and obtaining item parameters corresponding to the virtual object, wherein the virtual object corresponds to an object coordinate system, and the item parameters are parameters determined based on the object coordinate system; determining, based on the object parameters, vertex coordinates of each vertex in the virtual object in the object coordinate system, and constructing a virtual object model corresponding to the vertex coordinates; Obtaining the drop point of the virtual object in the game scene sent by the server; The game scene corresponds to a scene coordinate system, and the drop point corresponds to a target coordinate in the scene coordinate system; Calculating a random seed value for the virtual object using the target coordinates; Acquire volume information of the virtual object and a target motion parameter range corresponding to the volume information, where different volume information corresponds to different motion parameter ranges; Calculating motion parameters within the motion parameter range using the random seed value; The virtual object model is controlled according to the motion parameters to perform a corresponding falling motion with the falling point as a starting point.
2. The method according to claim 1, characterized in that The item parameters include at least the coordinates of an origin in an object coordinate system constructed based on the origin of the virtual object, a vertex distance between each vertex and the origin in the object coordinate system, and an angle between each vertex and a coordinate axis in the object coordinate system. Determining the vertex coordinates of each vertex in the virtual object in the object coordinate system based on the item parameters includes: The vertex distance and the coordinate axis angle are used to calculate the vertex coordinates of each vertex in the virtual object in the object coordinate system.
3. The method according to claim 2, characterized in that The coordinate axis angle includes the y-axis angle between the line connecting the vertex and the origin and the y-axis, and the z-axis angle between the line connecting the projection point of the vertex onto the plane formed by the x-axis and the z-axis and the origin and the z-axis. Calculating the vertex coordinates of each vertex in the virtual object in the object coordinate system using the vertex distance and the coordinate axis angle includes: Obtain a first sine value and a first cosine value corresponding to the y-axis angle, and a second sine value and a second cosine value corresponding to the z-axis angle; Calculate the x-axis coordinate of the vertex in the object coordinate system using the vertex distance, the first sine value, and the second sine value; Calculate the y-axis coordinate of the vertex in the object coordinate system using the vertex distance and the first cosine value; The z-axis coordinate of the vertex in the object coordinate system is calculated using the vertex distance, the first sine value, and the second cosine value.
4. The method according to claim 1, wherein The motion parameter range includes at least a throwing force value range, a horizontal angle range, and a rotation speed range, and the use of the random seed value to calculate the motion parameters within the motion parameter range includes: The random seed value is used to calculate a throwing force value within the throwing force value range, a throwing angle within the horizontal angle range, and a rotation speed within the rotation speed range.
5. The method according to claim 4, characterized in that The controlling the virtual object model to perform a corresponding dropping motion with the dropping point as a starting point according to the motion parameter includes: The virtual object model is controlled along the throwing angle according to the rotation speed and the throwing force value to perform a corresponding dropping motion with the dropping point as a starting point.
6. A virtual object drop processing device, characterized in that: include: an item parameter acquisition module, configured to, in response to an item drop instruction, determine a virtual object corresponding to the item drop instruction and acquire item parameters corresponding to the virtual object, wherein the virtual object corresponds to an object coordinate system, and the item parameters are parameters determined based on the object coordinate system; a model building module, configured to determine, based on the object parameters, vertex coordinates of each vertex in the virtual object in the object coordinate system, and to build a virtual object model corresponding to the vertex coordinates; A motion parameter determination module is configured to obtain a drop point of the virtual object in a game scene sent by a server; the game scene corresponds to a scene coordinate system, and the drop point corresponds to a target coordinate in the scene coordinate system; use the target coordinate to calculate a random seed value for the virtual object; obtain volume information of the virtual object and a target motion parameter range corresponding to the volume information, where different volume information corresponds to different motion parameter ranges; and use the random seed value to calculate motion parameters within the motion parameter range. The falling motion execution module is used to control the virtual object model to execute the corresponding falling motion with the falling point as the starting point according to the motion parameters.
7. An electronic device, characterized in that: comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; The memory is used to store computer programs; The processor is configured to implement the method according to any one of claims 1 to 5 when executing a program stored in the memory.
8. A computer-readable storage medium having instructions stored thereon, which, when executed by one or more processors, cause the processors to perform the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Climbing and jumping method and device, computer equipment and computer readable storage medium
CN111729311A
Game image processing method and device, storage medium and electronic equipment
CN112827169A