Data processing method and device, equipment and storage medium
By exponentially processing the rotation angular velocity of the rotating object between frames, the problem of data overflow in the calculation of the direction parameters of the rotating object in the game is solved, and the smoothness of the game and the accuracy of the direction parameters are improved.
Patent Information
- Application Number
- CN202310186576.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-21
- Publication Date
- 2024-08-23
AI Technical Summary
In game scenarios, data overflow is prone to occur when calculating the direction parameters of rotating objects, causing game interruption.
By obtaining the inter-frame interval between two frames of the rotating object, exponential processing is performed on the rotation angular velocity to obtain the target rotation angle, and the direction parameters of the rotating object are updated according to the initial direction parameters to ensure that they are within the numerical range controllable by the physics engine. Inside.
It avoids game interruption caused by data overflow and improves the smoothness of the game and the accuracy of the direction parameters.
Smart Images

Figure CN118537451A
Abstract
Description
Technical Field
[0001] The present application relates to fields such as Internet technologies, and in particular to a data processing method, device, equipment and storage medium. Background Art
[0002] There are usually rotating objects in the game scene. When rendering the game frame including the rotating object, it is necessary to calculate the direction parameters of the rotating object in real time, and render the rotating object according to the direction parameters to obtain the game frame. In practice, it is found that the current method of calculating the direction parameters of the rotating object is prone to data overflow, which in turn causes the game to be interrupted. Summary of the invention
[0003] The embodiments of the present application provide a data processing method, apparatus, device and storage medium to avoid data overflow and game interruption caused by data overflow.
[0004] An embodiment of the present application provides a data processing method, including:
[0005] Acquire a first direction parameter and a rotation angular velocity of the target object in a first game frame, and an inter-frame interval duration between the first game frame and a second game frame; the rendering order of the second game frame is after the rendering order of the first game frame;
[0006] Exponentially process the rotation angular velocity according to the inter-frame interval duration to obtain a target rotation angle of the target object;
[0007] A second direction parameter of the target object in the second game frame is determined according to the target rotation angle of the target object and the first direction parameter.
[0008] An embodiment of the present application provides a data processing device, including:
[0009] An acquisition module, used to acquire a first direction parameter and a rotation angular velocity of a target object in a game engine in a first game frame, and an inter-frame interval duration between the first game frame and a second game frame; the rendering order of the second game frame is after the rendering order of the first game frame;
[0010] A processing module, configured to perform exponential processing on the rotation angular velocity according to the inter-frame interval duration to obtain a target rotation angle of the target object;
[0011] A determination module is used to determine a second direction parameter of the target object in the second game frame according to the target rotation angle of the target object and the first direction parameter.
[0012] On one hand, an embodiment of the present application provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the above method when executing the computer program.
[0013] On one hand, an embodiment of the present application provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the above method are implemented.
[0014] On one hand, an embodiment of the present application provides a computer program product, including a computer program, which implements the steps of the above method when executed by a processor.
[0015] In the present application, in order for the physics engine to be able to represent the initial direction parameter (i.e., the first direction parameter of the rotating object in the first game frame), the inter-frame interval duration, and the rotational angular velocity of the rotating object (i.e., the target object), the initial direction parameter, the inter-frame interval duration, and the rotational angular velocity are all within the numerical range controllable by the physics engine. When it is necessary to update the initial direction parameter of the rotating object, the computer device can perform exponential processing on the rotational angular velocity of the rotating object by the inter-frame interval duration between every two game frames (the first game frame and the second game frame) to obtain the target rotation angle of the target object. Based on the exponential processing principle, it can be known that the exponential processing is equivalent to performing cosine, sine, etc. processing on the product of the rotational angular velocity and the inter-frame interval duration. It can be seen that by exponentially processing the rotation angular velocity through the inter-frame interval duration, the target rotation angle obtained by the exponential processing can be limited to a numerical range controllable by the physical engine. Furthermore, based on the target rotation angle and the initial direction parameter of the rotating object, it is determined that the updated direction parameter (i.e., the second direction parameter) of the rotating object also belongs to the numerical range controllable by the physical engine, that is, the updated direction parameter can be represented by the physical engine in the computer device, which can avoid data overflow and game interruption caused by data overflow, thereby improving the smoothness of the game. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0017] Figure 1 It is a schematic diagram of a direction parameter determination system provided by the present application;
[0018] Figure 2 It is a schematic diagram of an interactive scenario of a data processing method provided by this application;
[0019] Figure 3 It is a flowchart of a data processing method provided by this application;
[0020] Figure 4 It is a flowchart of a data processing method provided by this application;
[0021] Figure 5 is a structural schematic diagram of a data processing device provided in an embodiment of the present application;
[0022] Figure 6 It is a structural diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0023] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions 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 are within the scope of protection of this application.
[0024] In order to facilitate a clearer understanding of the present application, the direction parameter determination system implementing the present application is first introduced. Figure 1 As shown, the direction parameter determination system includes a server 10 and a terminal cluster, and the terminal cluster may include one or more terminals, and the number of terminals is not limited here. Figure 1 As shown, the terminal cluster may specifically include terminal 1, terminal 2, ..., terminal n; it can be understood that terminal 1, terminal 2, terminal 3, ..., terminal n can all be connected to the server 10 through a network connection, so that each terminal can exchange data with the server 10 through the network connection.
[0025] One or more target applications are installed in the terminal. The target application here may refer to a game application. For example, the target application may include an independent application program, a web application, a mini-program in a host application, and the like.
[0026] The server 10 refers to a device that provides backend services for a target application in a terminal. In one embodiment, the server can be used to obtain direction parameters of a rotating object, render a game frame according to the direction parameters, and return the game frame to the terminal.
[0027] It should be noted that the rotating object in this application may refer to a rigid body in a physics engine. A rigid body refers to an object that does not deform, can rotate, and can move. That is, a rotating object may refer to a game object that does not deform, can rotate, and can move in a game scene. For example, game objects may include game characters (such as virtual characters, virtual animals, virtual robots, etc.), game props (such as virtual Ferris wheels, virtual flying discs), etc. A physics engine may refer to a computer software development kit that calculates motion, rotation, and collision by giving rotating objects real physical properties. The physics engine may be deployed in a terminal or a server. The physics engine is a functional module in a game engine.
[0028] It should be noted that the physics engine can use a fixed-point number representation method or a floating-point number representation method to represent the direction parameters, rotation angles and other numerical values of a rotating object. The fixed-point number representation method: the position of the decimal point is agreed upon and fixed in the storage of the computer device. The integer part and the decimal part of a decimal are converted into binary representations respectively. The sum of the number of digits representing the decimal part and the number of digits representing the integer part cannot exceed the number of digits of the computer device. For example, in an 8-bit computer device, it is agreed that the first 5 digits represent the integer part of a decimal, and the last 3 digits represent the decimal part. The decimal point is by default located after the fifth digit. Then in an 8-bit computer device, the integer part 11111 can only represent 31 in decimal at most; the decimal part 0.111 can only represent 0.875 at most, that is, the numerical range that can be represented in an 8-bit computer device is [0, 31.875].
[0029] Representation method based on floating point numbers: refers to numbers with unfixed decimal point positions, which have both decimal and integer parts. In computer devices, floating point numbers are usually divided into two parts: exponent (also called index) and mantissa. The exponent is represented by a binary fixed-point integer, and the mantissa is represented by a binary fixed-point decimal. The length of the exponent determines the range of the value, and the length of the mantissa determines the precision of the value. For example, in a 16-bit computer device, the decimal 178.125 can be converted into binary as 10110010 001, where 10110010 represents the integer part of 178.125, and 001 represents the decimal part of 178.125; or, the decimal 178.125 can also be represented as: 10110010001 multiplied by 2 to the 111th power (111 is the binary representation of 7), 10110010001 is the mantissa of 178.125, and 111 is the exponent of 178.125.
[0030] It can be seen that the representation form of the representation method based on floating-point numbers is diversified, and the range of numerical values that can be represented is relatively wide; the representation form of the representation method based on fixed-point numbers is fixed, and can be applied to cross-platform data synchronization scenarios. The cross-platform data synchronization scenario refers to the scenario of data synchronization between game applications running in different operating systems. For example, game application a is running in the Android system of terminal a, and the game character a corresponding to terminal a, and game application a is running in the iOS system of terminal b. Terminal a can display game frame 1 including game character a, obtain the operation data of the game player for game character a, and synchronize the operation data to terminal b. Terminal a and terminal b can respectively determine the rotation angular velocity of the game character a according to the operation data, obtain the inter-frame interval duration between game frame 1 and game frame 2 and the first direction parameter of game character a in game frame 1, update the first direction parameter according to the rotation angular velocity and the inter-frame interval duration, and obtain the second direction parameter of game character a in game frame 2. Terminal a and terminal b both use a fixed-point number-based representation method to represent the second direction parameter of the game character in game frame 2. Since the representation form of the fixed-point number-based representation method is fixed, the second direction parameter obtained by terminal a and terminal b is the same, which ensures that the movement of the game character displayed by terminal a and terminal b can be consistent. At the same time, this can avoid synchronizing a large number of object states (such as direction parameters, rotation angular velocity, etc.) between different terminals, which can save traffic. In other words, the fixed-point number-based representation method can ensure the consistency of data in cross-platform data synchronization scenarios.
[0031] In other words, the computer device can select the numerical representation method in the physical engine according to whether there is a cross-platform data synchronization requirement in the game scene. For example, in a multiplayer online game application, corresponding terminal synchronization data between different game players is usually required. Therefore, it can be determined that there is a cross-platform data synchronization requirement in the multiplayer online game application. At this time, the computer device can determine the representation method based on fixed-point numbers as the numerical representation method of the physical engine. In a stand-alone game application, corresponding terminal synchronization data between game players is usually not required. Therefore, it can be determined that there is no cross-platform data synchronization requirement in the stand-alone game application. At this time, the computer device can determine the representation method based on fixed-point numbers or the representation method based on floating-point numbers as the numerical representation method of the physical engine.
[0032] The present application mainly relates to a game scene, which may refer to a cloud game scene or an ordinary game scene. A cloud game scene refers to a game scene based on cloud games. Cloud gaming, also known as gaming on demand, is an online game technology based on cloud computing technology. Cloud gaming technology enables thin clients with relatively limited graphics processing and data computing capabilities to run high-quality games. In a cloud gaming scenario, the game is not played on the player's game terminal, but on a cloud server (i.e., a game server), and the cloud server renders the game scene as a video and audio stream, which is transmitted to the player's game terminal (i.e., a terminal) through the network. The player's game terminal does not need to have powerful graphics computing and data processing capabilities, but only needs to have basic streaming media playback capabilities and the ability to obtain player input instructions and send them to the cloud server. An ordinary game scene may refer to a game scene in which a game is run in a terminal.
[0033] It is understandable that the server can be an independent physical server, or a server cluster or distributed system composed of at least two physical servers, or a cloud server that provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, Content Delivery Network (CDN), and big data and artificial intelligence platforms and other basic cloud computing services. The terminal can specifically refer to a vehicle-mounted terminal, a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a screen speaker, a smart watch, etc., but is not limited to this. Each terminal and server can be directly or indirectly connected via wired or wireless communication. At the same time, the number of terminals and servers can be one or at least two, and this application does not limit this.
[0034] Figure 1 The direction parameter determination system can be applied to determine the direction parameters of the rotating object in the game scene, specifically, Figure 2 As shown, Figure 2 The terminal 20a in may be Figure 1 Any terminal in the terminal cluster in Figure 2 The server 21a in may be Figure 1Server 10 in. The terminal 20a displays a game frame 22a, which includes an object 23a and an object 24a. The shapes of the objects 23a and 24a are both cuboids, and the objects 23a and 24a are both rotating objects. The rotation directions of the objects 23a and 24a are both from left to right. The terminal 22a can obtain the rotation angular velocity, the first direction parameter, and the inter-frame interval duration of the objects 23a and 24a respectively, and can send the rotation angular velocity, the first direction parameter, and the inter-frame interval duration corresponding to the objects 23a and 24a to the server 21a. The inter-frame interval duration is the interval duration between the game frame 22a and its next game frame 25a; the first direction parameter of the object 23a reflects the orientation of the object 23a in the game frame 22a, that is, the first direction parameter of the object 23a reflects the angles corresponding to the object 23a and the X-axis, the Y-axis, and the Z-axis at the first moment. The first direction parameter of object 24a reflects the orientation of object 24a in game frame 22a, that is, the first direction parameter of object 24a reflects the angles respectively corresponding to object 24a and the X-axis, Y-axis and Z-axis at the first moment, and the first moment is the display moment of game frame 22a.
[0035] Further, the server 21a can perform an exponential processing on the rotational angular velocity of the object 23a based on the inter-frame interval duration through the physical engine to obtain the target rotation angle of the object 23a, and perform an exponential processing on the rotational angular velocity of the object 24a based on the inter-frame interval duration through the physical engine to obtain the target rotation angle of the object 24a. It should be noted that, in order for the physical engine to be able to represent the rotational angular velocity, the first direction parameter, and the inter-frame interval duration corresponding to the objects 23a and 24a, respectively, the rotational angular velocity, the first direction parameter, and the inter-frame interval duration corresponding to the objects 23a and 24a, respectively, all belong to the controllable numerical range of the engine. Performing an exponential processing on the rotational angular velocity of the object 23a based on the inter-frame interval duration is equivalent to performing a cosine, a sine, and the like processing on the product between the inter-frame interval duration and the rotational angular velocity of the object 23a, that is, the target rotation angle of the object 23a obtained by the exponential processing belongs to the controllable numerical range of the physical engine. Similarly, exponential processing of the rotational angular velocity of object 24a based on the inter-frame interval duration is equivalent to performing cosine, sine, and other processing on the product of the inter-frame interval duration and the rotational angular velocity of object 24a, that is, the target rotation angle of object 24a obtained by the exponential processing belongs to the controllable numerical range of the physical engine. In other words, the intermediate value (i.e., the target rotation angle of object 23a and object 24a) in the process of obtaining the update direction parameters of object 23a and object 24a will not exceed the controllable numerical range of the physical engine, and the overflow of the intermediate value can be avoided.
[0036] Then, the server 21a can determine the second direction parameter of the object 23a in the game frame 25a through the physical engine according to the target rotation angle and the first direction parameter of the object 23a, and determine the second direction parameter of the object 24a in the game frame 25a through the physical engine according to the target rotation angle and the first direction parameter of the object 24a. The second direction parameter of the object 23a here reflects the orientation of the object 23a at the second moment, that is, the second direction parameter of the object 23a reflects the angles corresponding to the X-axis, Y-axis, and Z-axis of the object 23a at the second moment; the second direction parameter of the object 24a reflects the orientation of the object 24a at the second moment, that is, the second direction parameter of the object 24a reflects the angles corresponding to the X-axis, Y-axis, and Z-axis of the object 24a at the second moment, and the second moment is the display moment of the game frame 25a. After the server 21a obtains the second direction parameters corresponding to the objects 23a and 24a, respectively, the collision detection can be performed on the objects 23a and 24a according to the position information of the objects 23a and 24a at the second moment, that is, if the positions of the objects 23a and 24a at the second moment are the same, it is determined that the objects 23a and 24a will collide, then the second direction parameters corresponding to the objects 23a and 24a can be adjusted to obtain the third direction parameters corresponding to the objects 23a and 24a, respectively, and the object 23a is rendered according to the third direction parameters corresponding to the object 23a, and the object 24a is rendered according to the third direction parameters corresponding to the object 24a, to obtain the game frame 25a. If the positions of the objects 23a and 24a at the second moment are not the same, it is determined that the objects 23a and 24a will not collide, then the object 23a can be rendered according to the second direction parameters corresponding to the object 23a, and the object 24a can be rendered according to the second direction parameters corresponding to the object 24a, to obtain the game frame 25a. After acquiring the game frame 25a, the server 21a may send the game frame 25a to the terminal 20a, and the terminal 20a may update the game frame 22a displayed to the game frame 25a.
[0037] In summary, the target rotation angle and the first direction parameter of object 23a are both within the controllable numerical range of the physical engine, therefore, the second direction parameter of object 23a also belongs to the controllable numerical range of the physical engine. Since the target rotation angle and the first direction parameter of object 24a are both within the controllable numerical range of the physical engine, therefore, the second direction parameter of object 24a also belongs to the controllable numerical range of the physical engine. In other words, the intermediate values in the process of obtaining the updated direction parameters (i.e., the second direction parameters) of objects 23a and 24a, and the updated direction parameters finally obtained do not exceed the controllable numerical range of the physical engine, which can avoid data overflow and game interruption caused by data overflow, improve the fluency of the game, and also ensure the extremely high accuracy of the updated direction parameters.
[0038] For further information, see Figure 3 , is a flow chart of a data processing method provided in an embodiment of the present application. Figure 3 As shown, this method can be Figure 1 It can be executed by any terminal in the terminal cluster in Figure 1 The data processing method is executed by the server in the present application. The devices used to execute the data processing method in the present application can be collectively referred to as computer devices. The method may include the following steps:
[0039] S101, obtaining a first direction parameter and a rotational angular velocity of a target object in a first game frame, and an inter-frame interval duration between the first game frame and a second game frame; a rendering order of the second game frame is after a rendering order of the first game frame.
[0040] In the present application, the target object may refer to a rotating object in a game scene, and the computer device may obtain the first direction difference parameter and the rotational angular velocity of the target object in the first game frame, as well as the inter-frame interval duration between the first game frame and the second game frame; the first direction parameter is used to reflect the orientation of the target object in the first game frame, that is, the first direction parameter of the target object reflects the angle between the target object and the X-axis, Y-axis, and Z-axis at the first moment, the first moment is the display moment of the first game frame, and the X-axis, Y-axis, and Z-axis belong to the Cartesian coordinate system of the space where the target object is located. The rotational angular velocity may refer to the speed at which the target object rotates along a certain point in space, and the inter-frame interval duration may reflect how long it takes for the computer device to display the second game frame after displaying the first game frame, that is, the second game frame may refer to the next frame of the first game frame.
[0041] It should be noted that if the first game frame is the first game frame that includes the target object, the first direction parameter of the target object in the first game frame may refer to the initial direction parameter of the target object, which may be determined by the game rules of the game application to which the first game frame belongs, or the initial direction parameter of the target object may refer to the direction parameter of the target object when the computer device last closed the game application. The angular velocity of rotation of the target object may be determined based on the operation data of the game player corresponding to the computer device in the game application (such as the force applied to the target object), and the operation data may also be synchronized to the computer device by other devices; or, the angular velocity of rotation of the target object may be determined based on the game rules of the game application to which the first game frame belongs. The above-mentioned inter-frame interval duration may be determined based on the game rules of the game application to which the first game frame belongs.
[0042] It should be noted that in order for the physics engine corresponding to the first game frame to be able to represent the first direction parameter, the rotation angular velocity and the time interval between frames, the first direction parameter, the rotation angular velocity and the time interval duration all belong to a controllable numerical range, and the controllable numerical range can be determined according to the number of bits of the computer device and the numerical representation method of the physics engine. For example, assuming that the numerical representation method of the physics engine is a representation method based on fixed-point numbers, the number of bits of the computer device is 8 bits, and the physics engine agrees that the first 5 bits represent the integer part of a decimal, and the last 3 bits represent the decimal part, and the decimal point defaults to the position after the fifth bit, then the numerical range that can be represented in the 8-bit computer device is [0, 31.875], that is, the controllable numerical range here is [0, 31.875]. Of course, the physics engine can also agree that the first digit represents the integer part of a decimal, and the last 7 digits represent the decimal part of a decimal. In this case, the numerical range that can be represented in an 8-bit computer device is [0, 1.9921875], that is, the controllable numerical range at this time is [0, 1.9921875]. For another example, assuming that the numerical representation method of the physics engine is based on a floating-point representation method, the number of bits of the computer device is 8 bits, and the numerical range that can be represented in the 8-bit computer device is [-126, 127], that is, the controllable numerical range at this time is [-126, 127].
[0043] S102: performing exponential processing on the rotation angular velocity according to the inter-frame interval duration to obtain a target rotation angle of the target object.
[0044] In the present application, the computer device can perform exponential processing on the rotation angular velocity according to the inter-frame interval duration to obtain the target rotation angle of the target object. The exponential processing here can refer to performing exponentiation processing on the inter-frame interval duration and the rotation angular velocity. According to the Euler formula corresponding to the exponentiation processing (i.e., based on the exponential processing principle), the exponential processing is equivalent to performing cosine, sine, etc. processing on the product between the rotation angular velocity and the inter-frame interval duration. Since the results obtained by the cosine and spherical sine processing are all within [-1, -1], therefore, by performing exponential processing on the rotation angular velocity according to the inter-frame interval duration, the target rotation angle of the target object obtained also belongs to a controllable numerical range.
[0045] Optionally, the above-mentioned indexation processing of the rotation angular velocity according to the inter-frame interval duration is performed to obtain the target rotation angle of the target object, including: the rotation angular velocity of the target object includes the rotation angular velocities w1, w2, and w3 of the target object corresponding to the X-axis, Y-axis, and Z-axis, respectively; the X-axis, Y-axis, and Z-axis may belong to the Cartesian coordinate system of the space where the target object is located. The computer device may convert the rotation angular velocity of the target object into a three-dimensional angular velocity vector of the target object, that is, the three-dimensional angular velocity vector of the target object may be expressed as: The computer device can determine the three-dimensional rotation angle vector of the target object according to the product between the three-dimensional angular velocity vector and the time interval between frames, such as the computer device can determine half of the product between the three-dimensional angular velocity vector and the time interval as the three-dimensional rotation angle vector of the target object; or, determine the product between the three-dimensional angular velocity vector and the time interval as the three-dimensional rotation angle vector of the target object. Further, the computer device can perform index processing on the three-dimensional rotation angle vector of the target object to obtain the quaternion rotation angle vector of the target object, the quaternion rotation angle vector of the target object is a vector representing the rotation angle of the target object based on the quaternion method, and the quaternion rotation angle vector of the target object is determined as the target rotation angle of the target object. By representing the rotation angle of the target object (i.e., the target rotation angle) based on the quaternion method, the efficiency of determining the rotation angle of the target object can be improved, and storage space can be saved to avoid the universal joint lock phenomenon.
[0046] It should be noted that quaternions consist of a real number plus three imaginary units i, j and k, and they have the following relationship: i 2 =j 2 =k 2 =-1,i 0 =j 0 =k 0 =1, each quaternion is a linear combination of 1, i, j and k, that is, the quaternion can be expressed as a+bi+cj+dk, where a, b, c, d are real numbers. The geometric meaning of i, j and k themselves can be understood as a kind of rotation, where i rotation represents the rotation angle of the target object from the positive direction of the Z axis to the positive direction of the Y axis in the plane where the Z axis and the Y axis intersect, j rotation represents the rotation angle of the target object from the positive direction of the X axis to the positive direction of the Z axis in the plane where the X axis and the Z axis intersect, and k rotation represents the rotation angle of the target object from the positive direction of the Y axis to the positive direction of the X axis in the plane where the Y axis and the X axis intersect.
[0047] It should be noted that the representation methods of the rotation angle of the target object include quaternion-based method, matrix rotation method and Euler rotation method. If the rotation angle of the target object is represented by a quaternion-based method, only four elements (i.e., a, b, c, d) are needed to represent the rotation angle of the target object, and there is no need to limit the target object to rotate in a fixed coordinate axis rotation order, such as the fixed coordinate axis rotation order can be first X axis, then Y axis, and finally Y axis). In the process of calculating the rotation angle of the target object by the matrix rotation method, a 4*4 matrix is needed to represent the transformation matrix rotating around any axis (i.e., the transformation matrix has 16 elements), and the rotation angle of the target object is calculated based on the product between the transformation matrix and the rotation angular velocity. The Euler rotation method needs to limit the target object to rotate in a fixed coordinate axis rotation order. It can be seen that since the elements required by the quaternion-based method are relatively few, that is, by representing the rotation angle of the target object based on the quaternion method, the efficiency of determining the rotation angle of the target object can be improved and storage space can be saved. Since the quaternion method does not limit the target object to rotate according to a fixed coordinate axis rotation order, the gimbal lock phenomenon can be avoided by representing the rotation angle of the target object based on the quaternion method. The gimbal lock phenomenon here can refer to the process in which the target object rotates according to a fixed coordinate axis rotation order. If some coordinate axes are mistakenly overlapped, the target object will lose the ability to rotate in one direction. In other words, in this state, no matter how the target object is rotated (of course, the original coordinate axis rotation order must be followed), it is impossible to obtain some desired rotation effects, unless the original coordinate axis rotation order is broken or the three coordinate axes are rotated at the same time.
[0048] Optionally, the above-mentioned exponential processing of the three-dimensional rotation angle vector of the target object to obtain the quaternion rotation angle vector of the target object includes: the computer device can pad the three-dimensional rotation angle vector of the target object to obtain a four-dimensional rotation angle vector, such as adding zeros to the three-dimensional rotation angle vector of the target object to obtain the four-dimensional rotation angle vector. Further, the four-dimensional angle vector is used as an exponent and a natural constant is used as a base to obtain the quaternion rotation angle vector of the target object, where the natural constant may refer to e.
[0049] For example, the computer device may use the following formula (1) to represent the three-dimensional rotation angle vector of the target object:
[0050]
[0051] In formula (1), represents the three-dimensional rotational angular velocity of the target object, Δt represents the inter-frame interval between the first game frame and the second game frame, Represents the three-dimensional rotation angle vector of the target object. Add 0 to the three-dimensional rotation angle vector of the target object to obtain the four-dimensional rotation angle vector of the target object, which can be expressed as Furthermore, the four-dimensional angle vector is used as an exponent and the natural constant is used as a base to obtain the quaternion rotation angle vector of the target object. That is, the quaternion rotation angle vector of the target object can be expressed as exp represents the natural constant e.
[0052] Optionally, based on the Euler formula of the exponent, the above-mentioned four-dimensional angle vector is used as the exponent and the natural constant is used as the base for calculation processing to obtain the quaternion rotation angle vector of the target object, including: the computer device can perform modulus processing on the four-dimensional rotation angle vector to obtain the real angle of the target object, such as the computer device can calculate the square sum of each element in the four-dimensional rotation angle vector, and then perform square root operation on the square sum of each element to obtain the real angle of the target object, that is, the real angle can be expressed as Since 0 does not affect the size of the real angle, Can be equivalent to Further, the computer device may perform unitization processing on the four-dimensional rotation angle vector to obtain a unit four-dimensional rotation angle vector, such as determining the ratio between the four-dimensional rotation angle vector and the real angle as the unit four-dimensional rotation angle vector, that is, the unit four-dimensional rotation angle vector can be expressed as: The computer device may determine the product of the unit four-dimensional rotation angle vector and the sine value of the real angle as the candidate rotation angle of the target object, that is, the candidate rotation angle of the target object may be expressed as: Then, the sum of the candidate rotation angle of the target object and the cosine value of the real angle may be determined as the quaternion rotation angle vector of the target object.
[0053] For example, the quaternion rotation angle vector of the target object can be expressed by the following formula (2):
[0054]
[0055] in, The specific form of is the above-mentioned a+bi+cj+dk.
[0056] S103: Determine a second direction parameter of the target object in the second game frame according to the target rotation angle of the target object and the first direction parameter.
[0057] In the present application, after obtaining the target rotation angle and the first direction parameter of the target object, the computer device can determine the second direction parameter of the target object in the second game frame according to the target rotation angle and the first direction parameter of the target object. The second direction parameter may refer to the orientation of the target object in the second game frame, that is, the second direction parameter of the target object reflects the angle between the target object and the X-axis, Y-axis, and Z-axis at the second moment, and the second moment is the display moment of the second game frame. Since the target rotation angle and the first direction parameter both belong to a controllable numerical range, the second direction parameter obtained based on the target rotation angle and the first direction parameter also belongs to a controllable numerical range, which can avoid problems such as data overflow and game interruption, and improve the fluency of the game.
[0058] It should be noted that after the computer device calculates the second direction parameter, it renders the target object according to the second direction parameter to obtain a second game frame including the target object; further, when the game application to which the first game frame belongs is a multiplayer online game application, the computer device can synchronize the second direction parameter to other devices, and the other devices may include devices corresponding to game players belonging to the same game team as the target game player, and devices corresponding to game players belonging to the enemy team corresponding to the target game player. The target game player is the game player corresponding to the computer device.
[0059] Optionally, the above-mentioned determination of the second direction parameter of the target object in the second game frame based on the target rotation angle and the first direction parameter of the target object includes: generating a first quaternion direction vector reflecting the first direction parameter of the target object, that is, the first quaternion direction vector is a vector representing the first direction parameter of the target object based on the quaternion method. If the first direction parameter of the target object is a three-dimensional direction vector, a 0 is added to the three-dimensional direction vector for padding to obtain the first quaternion direction vector. Further, the product of the first quaternion direction vector and the quaternion rotation angle vector corresponding to the target rotation angle is determined as the second quaternion direction vector of the target object in the second game frame. The second quaternion direction vector may refer to a vector representing the direction parameter of the target object in the second game frame based on the quaternion method, and the second quaternion direction vector is determined as the second direction parameter of the target object in the second game frame.
[0060] For example, the computer device may use the following formula (3) to represent the second direction parameter of the target object in the second game frame:
[0061]
[0062] In formula (3), q0 represents the first quaternion direction vector, q represents the second quaternion direction vector, that is, the second direction parameter of the target object in the second game frame, Represents the product between two vectors. Based on the above formula (2), formula (3) can be equivalent to the following formula (4):
[0063]
[0064] It should be noted that, according to formula (4), when the quaternion-based method is used in a physical engine to represent the direction parameters of a target object, the quaternion-based direction parameters are all within the controllable value range of the physical engine, that is, each value in q0 is within the controllable value range of the physical engine. The size is determined by and Δt, The size limit is designed, such as is within the controllable value range of the physics engine. Assuming that the calculated It is the maximum value within the controllable value range of the physics engine. The results of these three calculations are all less than That is to say, The results of these three calculations will not exceed the controllable value range of the physics engine, that is, the physics engine can also These three calculations. Then The results obtained from these three calculations are all within [-2, 2); is a complex number addition calculation, and the result is also in [-2, 2). Since each value in q0 is within the controllable numerical range of the physics engine, It belongs to the controllable value range, that is, the second direction parameter of the target object will not exceed the controllable value range of the physical engine, and the intermediate value (i.e. ) will not exceed the controllable value range of the physics engine. In other words, this method of determining the second direction parameter of the target object can avoid data overflow, game interruption and other problems, while ensuring the great accuracy of the direction parameter.
[0065] For example, the controllable value range of the physical engine is [-2, 2) as an example for explanation. Therefore, the first direction parameter, the second direction parameter and the intermediate value (i.e. ) are all located in [-2, 2). In other words, since the integer parts of the first direction parameter, the second direction parameter and the intermediate value are relatively small, when the physical engine uses fixed-point numbers to represent values (such as direction parameters), fewer bits can be used to represent the integer part, and more bits can be used to represent the decimal part, thereby improving the accuracy of obtaining the direction parameters of the target object. For example, if the computer device is 32 bits, 1 bit can be used to represent the positive and negative of the value, 30 to represent the decimal part of the value, and 1 bit to represent the integer part of the value. In this way, more bits can be used to represent the decimal part of the value, thereby improving the accuracy of the value (the first direction parameter, the second direction parameter).
[0066] In the present application, in order for the physics engine to be able to represent the initial direction parameter (i.e., the first direction parameter of the rotating object in the first game frame), the inter-frame interval duration, and the rotational angular velocity of the rotating object (i.e., the target object), the initial direction parameter, the inter-frame interval duration, and the rotational angular velocity are all within the numerical range controllable by the physics engine. When it is necessary to update the initial direction parameter of the rotating object, the computer device can perform exponential processing on the rotational angular velocity of the rotating object by the inter-frame interval duration between every two game frames (the first game frame and the second game frame) to obtain the target rotation angle of the target object. Based on the exponential processing principle, it can be known that the exponential processing is equivalent to performing cosine, sine, etc. processing on the product of the rotational angular velocity and the inter-frame interval duration. It can be seen that by exponentially processing the rotation angular velocity through the inter-frame interval duration, the target rotation angle obtained by the exponential processing can be limited to a numerical range controllable by the physical engine. Furthermore, based on the target rotation angle and the initial direction parameter of the rotating object, it is determined that the updated direction parameter (i.e., the second direction parameter) of the rotating object also belongs to the numerical range controllable by the physical engine, that is, the updated direction parameter can be represented by the physical engine in the computer device, which can avoid data overflow and game interruption caused by data overflow, thereby improving the smoothness of the game.
[0067] For further information, see Figure 4 , is a flow chart of a data processing method provided in an embodiment of the present application. Figure 4 As shown, this method can be Figure 1 It can be executed by any terminal in the terminal cluster in Figure 1 The data processing method is executed by the server in the present application. The devices used to execute the data processing method in the present application can be collectively referred to as computer devices. The method may include the following steps:
[0068] S201, obtaining a first direction parameter and a rotational angular velocity of a target object in a first game frame, and an inter-frame interval duration between the first game frame and a second game frame; a rendering order of the second game frame is after a rendering order of the first game frame.
[0069] S202: performing exponential processing on the rotation angular velocity according to the inter-frame interval duration to obtain a target rotation angle of the target object.
[0070] S203: Determine a second direction parameter of the target object in the second game frame according to the target rotation angle of the target object and the first direction parameter.
[0071] It should be noted that the explanation of step S201 in this application can refer to the above explanation of step S101, the explanation of step S202 can refer to the above explanation of step S102, and the explanation of step S203 can refer to the above explanation of step S103. The repeated parts will not be repeated here.
[0072] S204: Obtain movement parameters of the target object and a first position of the target object in the first game frame.
[0073] S205: Determine a second position of the target object in the second game frame according to the movement parameter of the target object, the inter-frame interval duration, and the first position.
[0074] Optionally, the above-mentioned determination of the second position of the target object in the second game frame according to the movement parameters of the target object, the inter-frame interval duration and the first position includes: the computer device can determine the product between the movement speed in the movement parameters and the inter-frame interval duration as the movement distance of the target object, and determine the second position of the target object in the second game frame according to the movement direction in the movement parameters, the movement distance and the first position. For example, the first position is (x, y, z) cm, x, y, z represent the coordinate values of the target object in the X-axis, Y-axis and Z-axis respectively, if the movement direction of the target object is the positive direction of the X-axis, and the movement distance is 3 cm, then the second position of the target object in the game frame is (x+3, y, z) cm.
[0075] S206: Render the target object according to the second position and the second direction parameter to obtain a second game frame including the target object.
[0076] In steps S204-206, the computer device can obtain the movement parameters of the target object according to the game rules of the game application to which the first game frame belongs, or obtain the movement parameters of the target object based on the operation data of the game player corresponding to the computer device on the target object in the first game frame, and the movement parameters may include movement direction and movement speed, etc. The computer device can obtain the display position of the target object in the first game frame as the first position of the target object, and further, according to the movement parameters of the target object and the interval between the frames, and the first position, determine the display position of the target object in the second game frame, and determine the display position of the target object in the second game frame as the second position of the target object in the second game frame. The target object is rendered according to the second position and the second direction parameter to obtain a second game frame including the target object. In particular, the movement speed of the target object can be 0, and the target object does not move, that is, the first position of the target object in the first game frame is the same as the second position of the target object in the second game frame.
[0077] Optionally, the above-mentioned rendering of the target object according to the second position and the second direction parameter to obtain a second game frame including the target object includes: if the number of the target object is one, the computer device can directly render the target object according to the second position and the second direction parameter to obtain a second game frame including the target object. If the number of the target objects is at least two, the computer device can perform collision detection on the at least two target objects according to the second positions respectively corresponding to the at least two target objects to obtain a detection result; for example, the at least two target objects include a first target object and a second target object, and if the second positions respectively corresponding to the first target object and the second target object are the same, a detection result is generated that the first target object and the second target object will collide; if the second positions respectively corresponding to the first target object and the second target object are different, a detection result is generated that the first target object and the second target object will not collide. Further, according to the detection result, the second direction parameters respectively corresponding to the at least two target objects are adjusted to obtain the third direction parameters respectively corresponding to the at least two target objects, and according to the third direction parameters respectively corresponding to the at least two target objects and the second position, the at least two target objects are rendered to obtain a second game frame including the at least two target objects.
[0078] It is understandable that the above-mentioned adjusting the second direction parameters corresponding to the at least two target objects respectively according to the detection result to obtain the third direction parameters corresponding to the at least two target objects respectively includes: if the detection result indicates that there will be no collision between the first target object and the second target object of the at least two target objects, then the second direction parameter of the first target object is determined as the third direction parameter of the first target object, and the second direction parameter of the second target object is determined as the third direction parameter of the second target object. If the detection result indicates that there will be a collision between the first target object and the second target object of the at least two target objects, then the object category of the first target object and the object category of the second target object are obtained, and the object category includes a virtual person, a virtual prop, etc. According to the object category of the first target object and the object category of the second target object, the second direction parameter of the first target object is adjusted to obtain the third direction parameter of the first target object. For example, the game rules specify the adjustment rules for the direction parameters of the corresponding objects after the collision between different object categories. The computer device can query the adjustment rules for the direction parameters of the first target object from the game rules according to the object category of the first target object and the object category of the second target object, and adjust the second direction parameter of the first target object according to the adjustment rules for the direction parameters of the first target object to obtain the third direction parameter of the first target object. Similarly, the computer device can query the adjustment rules for the direction parameters of the second target object from the game rules according to the object category of the first target object and the object category of the second target object, and adjust the second direction parameter of the second target object according to the adjustment rules for the direction parameters of the second target object to obtain the third direction parameter of the second target object.
[0079] It should be noted that when the first target object and the second target object collide, whether the second positions of the first target object and the second target object change is determined according to the game rules. If the game rules stipulate that the second positions of the first target object and the second target object will change, the computer device can adjust the second positions corresponding to the first target object and the second target object according to the game rules, obtain the third positions corresponding to the first target object and the second target object respectively, and render the first target object and the second target object according to the third direction parameters and the third positions corresponding to the first target object and the second target object respectively, to obtain a second game frame including the first target object and the second target object. If the game rules stipulate that the second positions of the first target object and the second target object will not change, the computer device can render the first target object and the second target object according to the third direction parameters and the second positions corresponding to the first target object and the second target object respectively, to obtain a second game frame including the first target object and the second target object.
[0080] In the present application, after obtaining the second direction parameter of the target object, the computer device can obtain the position of the target object in the second game frame, and render the target object according to the second direction parameter of the target object and the position of the target object in the second game frame to obtain a second game frame including the target object; data overflow and game interruption caused by data overflow can be avoided, thereby improving the smoothness of the game.
[0081] See also Figure 5 , is a schematic diagram of the structure of a data processing device provided in an embodiment of the present application. Figure 5 As shown, the data processing device may include:
[0082] An acquisition module 511 is used to acquire a first direction parameter and a rotation angular velocity of a target object in a game engine in a first game frame, and an inter-frame interval duration between the first game frame and a second game frame; the rendering order of the second game frame is after the rendering order of the first game frame;
[0083] A processing module 512 is used to perform exponential processing on the rotation angular velocity according to the inter-frame interval duration to obtain a target rotation angle of the target object;
[0084] The determination module 513 is used to determine a second direction parameter of the target object in the second game frame according to the target rotation angle of the target object and the first direction parameter.
[0085] Optionally, the processing module 512 includes a first generating unit 51a, a first determining unit 52a, a processing unit 53a and a second determining unit 54a;
[0086] A first generating unit 51a, configured to generate a three-dimensional angular velocity vector of the target object according to the rotation angular velocity;
[0087] A first determining unit 52a, configured to determine a three-dimensional rotation angle vector of the target object according to a product of the three-dimensional angular velocity vector and the inter-frame interval duration;
[0088] The processing unit 53a is used to perform index processing on the three-dimensional rotation angle vector of the target object to obtain the quaternion rotation angle vector of the target object;
[0089] The second determining unit 54a is used to determine the quaternion rotation angle vector of the target object as the target rotation angle of the target object.
[0090] It is understandable that the processing unit 53a performs indexation processing on the three-dimensional rotation angle vector of the target object to obtain the quaternion rotation angle vector of the target object, including:
[0091] Converting the three-dimensional rotation angle vector of the target object into a four-dimensional rotation angle vector;
[0092] The four-dimensional angle vector is used as an exponent and the natural constant is used as a base for operation processing to obtain the quaternion rotation angle vector of the target object.
[0093] It is understandable that the processing unit 53a uses the four-dimensional angle vector as an exponent and the natural constant as a base for operation processing to obtain the quaternion rotation angle vector of the target object, including:
[0094] Performing modulo processing on the four-dimensional rotation angle vector to obtain a real angle of the target object;
[0095] Normalizing the four-dimensional rotation angle vector to obtain a unit four-dimensional rotation angle vector;
[0096] Determine the product of the unit four-dimensional rotation angle vector and the sine value of the real angle as the candidate rotation angle of the target object;
[0097] The sum of the candidate rotation angle of the target object and the cosine value of the real angle is determined as the quaternion rotation angle vector of the target object.
[0098] The determination module 513 includes a second generation unit 55a, a third determination unit 56a and a fourth determination unit 57a;
[0099] A second generating unit 55a, configured to generate a first quaternion direction vector reflecting the first direction parameter of the target object;
[0100] A third determining unit 56a is used to determine the product of the first quaternion direction vector and the quaternion rotation angle vector corresponding to the target rotation angle as the second quaternion direction vector of the target object in the second game frame;
[0101] The fourth determining unit 57a is used to determine the second quaternion direction vector as the second direction parameter of the target object in the second game frame.
[0102] An acquisition module 511, configured to acquire movement parameters of the target object and a first position of the target object in the first game frame;
[0103] The determination module 513 is further configured to determine a second position of the target object in the second game frame according to the movement parameter of the target object, the inter-frame interval duration, and the first position;
[0104] The above device also includes a rendering module 514;
[0105] The rendering module 514 is used to render the target object according to the second position and the second direction parameter to obtain a second game frame including the target object.
[0106] Optionally, the determination module 513 determines the second position of the target object in the second game frame according to the movement parameter of the target object, the inter-frame interval duration, and the first position of the target object in the first game frame, including:
[0107] The moving distance of the target object is determined by multiplying the moving speed in the moving parameter by the inter-frame interval time length;
[0108] The second position of the target object in the second game frame is determined according to the moving direction, the moving distance and the first position in the moving parameters.
[0109] Optionally, the rendering module 514 renders the target object according to the second position and the second direction parameter to obtain a second game frame including the target object, including:
[0110] If the number of the target objects is at least two, performing collision detection on the at least two target objects according to the second positions respectively corresponding to the at least two target objects to obtain a detection result;
[0111] Adjusting the second direction parameters respectively corresponding to the at least two target objects according to the detection result to obtain the third direction parameters respectively corresponding to the at least two target objects;
[0112] The at least two target objects are rendered according to the third direction parameters and the second position respectively corresponding to the at least two target objects to obtain a second game frame including the at least two target objects.
[0113] Optionally, the rendering module 514 adjusts the second direction parameters respectively corresponding to the at least two target objects according to the detection result to obtain the third direction parameters respectively corresponding to the at least two target objects, including:
[0114] If the detection result indicates that a first target object and a second target object of the at least two target objects will collide, obtaining an object category of the first target object and an object category of the second target object;
[0115] According to the object category of the first target object and the object category of the second target object, adjusting the second direction parameter of the first target object to obtain a third direction parameter of the first target object;
[0116] According to the object category of the first target object and the object category of the second target object, the second direction parameter of the second target object is adjusted to obtain the third direction parameter of the second target object.
[0117] According to an embodiment of the present application, the steps involved in the data processing method shown above can be Figure 5 The data processing device shown in the figure is executed by each module. For example, Figure 3 The step S101 shown in FIG. 1 can be performed by Figure 5 The acquisition module 511 in is executed, Figure 3 The step S102 shown in FIG. 1 can be performed by Figure 5 The processing module 512 is executed; Figure 3 The step S103 shown in FIG. 1 can be performed by Figure 5 The determination module 513 in is executed.
[0118] According to one embodiment of the present application, Figure 5 The various modules in the data processing device shown can be respectively or all combined into one or several units to constitute, or some of the units (some) can also be split into at least two smaller sub-units in function, and the same operation can be achieved without affecting the realization of the technical effects of the embodiments of the present application. The above modules are divided based on logical functions. In practical applications, the functions of one module can also be realized by at least two units, or the functions of at least two modules can be realized by one unit. In other embodiments of the present application, the data processing device can also include other units. In practical applications, these functions can also be implemented with the assistance of other units, and can be implemented by the collaboration of at least two units.
[0119] According to one embodiment of the present application, a computer program (including program code) capable of executing each step involved in the corresponding method as shown above can be constructed by running a computer program (including program code) on a general-purpose computer device such as a computer including a central processing unit (CPU), a random access storage medium (RAM), a read-only storage medium (ROM) and other processing components and storage components. Figure 5 The data processing device shown in and the data processing method of the embodiment of the present application are implemented. The above computer program can be recorded on, for example, a computer readable recording medium, and loaded into the above computing device through the computer readable recording medium, and run therein.
[0120] In the present application, in order for the physics engine to be able to represent the initial direction parameter (i.e., the first direction parameter of the rotating object in the first game frame), the inter-frame interval duration, and the rotational angular velocity of the rotating object (i.e., the target object), the initial direction parameter, the inter-frame interval duration, and the rotational angular velocity are all within the numerical range controllable by the physics engine. When it is necessary to update the initial direction parameter of the rotating object, the computer device can perform exponential processing on the rotational angular velocity of the rotating object by the inter-frame interval duration between every two game frames (the first game frame and the second game frame) to obtain the target rotation angle of the target object. Based on the exponential processing principle, it can be known that the exponential processing is equivalent to performing cosine, sine, etc. processing on the product of the rotational angular velocity and the inter-frame interval duration. It can be seen that by exponentially processing the rotation angular velocity through the inter-frame interval duration, the target rotation angle obtained by the exponential processing can be limited to a numerical range controllable by the physical engine. Furthermore, based on the target rotation angle and the initial direction parameter of the rotating object, it is determined that the updated direction parameter (i.e., the second direction parameter) of the rotating object also belongs to the numerical range controllable by the physical engine, that is, the updated direction parameter can be represented by the physical engine in the computer device, which can avoid data overflow and game interruption caused by data overflow, thereby improving the smoothness of the game.
[0121] See also Figure 6 , is a schematic diagram of the structure of a computer device provided in an embodiment of the present application. Figure 6 As shown, the above-mentioned computer device 1000 can be the first device in the above-mentioned method, specifically, it can refer to a terminal or a server, including: a processor 1001, a network interface 1004 and a memory 1005. In addition, the above-mentioned computer device 1000 can also include: a user interface 1003, and at least one communication bus 1002. Among them, the communication bus 1002 is used to realize the connection and communication between these components. Among them, in some embodiments, the user interface 1003 may include a display screen (DiSPlay), a keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface). The memory 1005 can be a high-speed RAM memory, or it can be a non-volatile memory (non-volatile MeMory), such as at least one disk storage. The memory 1005 can also be optionally at least one storage device away from the aforementioned processor 1001. As Figure 6 As shown, the memory 1005 as a computer-readable storage medium may include an operating system, a network communication module, a user interface module, and a computer application program.
[0122] exist Figure 6In the computer device 1000 shown, the network interface 1004 can provide a network communication function; the user interface 1003 is mainly used to provide an input interface; and the processor 1001 can be used to call a computer application stored in the memory 1005 to achieve:
[0123] Acquire a first direction parameter and a rotation angular velocity of the target object in a first game frame, and an inter-frame interval duration between the first game frame and a second game frame; the rendering order of the second game frame is after the rendering order of the first game frame;
[0124] Exponentially process the rotation angular velocity according to the inter-frame interval duration to obtain a target rotation angle of the target object;
[0125] A second direction parameter of the target object in the second game frame is determined according to the target rotation angle of the target object and the first direction parameter.
[0126] Optionally, the processor 1001 may be used to call a computer application stored in the memory 1005 to implement exponential processing of the rotation angular velocity according to the inter-frame interval duration to obtain a target rotation angle of the target object, including:
[0127] generating a three-dimensional angular velocity vector of the target object according to the rotational angular velocity;
[0128] Determining a three-dimensional rotation angle vector of the target object according to the product of the three-dimensional angular velocity vector and the inter-frame interval duration;
[0129] Performing exponential processing on the three-dimensional rotation angle vector of the target object to obtain the quaternion rotation angle vector of the target object;
[0130] The quaternion rotation angle vector of the target object is determined as the target rotation angle of the target object.
[0131] Optionally, the processor 1001 may be used to call a computer application stored in the memory 1005 to implement exponential processing of the three-dimensional rotation angle vector of the target object to obtain the quaternion rotation angle vector of the target object, including:
[0132] Converting the three-dimensional rotation angle vector of the target object into a four-dimensional rotation angle vector;
[0133] The four-dimensional angle vector is used as an exponent and the natural constant is used as a base for operation processing to obtain the quaternion rotation angle vector of the target object.
[0134] Optionally, the processor 1001 may be used to call a computer application stored in the memory 1005 to implement a calculation process using the four-dimensional angle vector as an exponent and a natural constant as a base to obtain a quaternion rotation angle vector of the target object, including:
[0135] Performing modulo processing on the four-dimensional rotation angle vector to obtain a real angle of the target object;
[0136] Normalizing the four-dimensional rotation angle vector to obtain a unit four-dimensional rotation angle vector;
[0137] Determine the product of the unit four-dimensional rotation angle vector and the sine value of the real angle as the candidate rotation angle of the target object;
[0138] The sum of the candidate rotation angle of the target object and the cosine value of the real angle is determined as the quaternion rotation angle vector of the target object.
[0139] Optionally, the processor 1001 may be configured to call a computer application stored in the memory 1005 to determine a second direction parameter of the target object in the second game frame according to the target rotation angle of the target object and the first direction parameter, including:
[0140] generating a first quaternion direction vector reflecting the first direction parameter of the target object;
[0141] Determine the product of the first quaternion direction vector and the quaternion rotation angle vector corresponding to the target rotation angle as the second quaternion direction vector of the target object in the second game frame;
[0142] The second quaternion direction vector is determined as a second direction parameter of the target object in the second game frame.
[0143] Optionally, the processor 1001 may be configured to call a computer application stored in the memory 1005 to implement:
[0144] Acquire movement parameters of the target object and a first position of the target object in the first game frame;
[0145] Determining a second position of the target object in the second game frame according to the movement parameter of the target object, the inter-frame interval duration, and the first position;
[0146] The target object is rendered according to the second position and the second direction parameter to obtain a second game frame including the target object.
[0147] Optionally, the processor 1001 may be configured to call a computer application stored in the memory 1005 to determine a second position of the target object in the second game frame according to the movement parameters of the target object, the inter-frame interval duration, and the first position of the target object in the first game frame, including:
[0148] The moving distance of the target object is determined by multiplying the moving speed in the moving parameter by the inter-frame interval time length;
[0149] The second position of the target object in the second game frame is determined according to the moving direction, the moving distance and the first position in the moving parameters.
[0150] Optionally, the processor 1001 may be used to call a computer application stored in the memory 1005 to render the target object according to the second position and the second direction parameter to obtain a second game frame including the target object, including:
[0151] If the number of the target objects is at least two, performing collision detection on the at least two target objects according to the second positions respectively corresponding to the at least two target objects to obtain a detection result;
[0152] Adjusting the second direction parameters respectively corresponding to the at least two target objects according to the detection result to obtain the third direction parameters respectively corresponding to the at least two target objects;
[0153] The at least two target objects are rendered according to the third direction parameters and the second position respectively corresponding to the at least two target objects to obtain a second game frame including the at least two target objects.
[0154] Optionally, the processor 1001 may be used to call a computer application stored in the memory 1005 to implement the adjustment of the second direction parameters respectively corresponding to the at least two target objects according to the detection result to obtain the third direction parameters respectively corresponding to the at least two target objects, including:
[0155] If the detection result indicates that a first target object and a second target object of the at least two target objects will collide, obtaining an object category of the first target object and an object category of the second target object;
[0156] According to the object category of the first target object and the object category of the second target object, adjusting the second direction parameter of the first target object to obtain a third direction parameter of the first target object;
[0157] According to the object category of the first target object and the object category of the second target object, the second direction parameter of the second target object is adjusted to obtain the third direction parameter of the second target object.
[0158] In the present application, in order for the physics engine to be able to represent the initial direction parameter (i.e., the first direction parameter of the rotating object in the first game frame), the inter-frame interval duration, and the rotational angular velocity of the rotating object (i.e., the target object), the initial direction parameter, the inter-frame interval duration, and the rotational angular velocity are all within the numerical range controllable by the physics engine. When it is necessary to update the initial direction parameter of the rotating object, the computer device can perform exponential processing on the rotational angular velocity of the rotating object by the inter-frame interval duration between every two game frames (the first game frame and the second game frame) to obtain the target rotation angle of the target object. Based on the exponential processing principle, it can be known that the exponential processing is equivalent to performing cosine, sine, etc. processing on the product of the rotational angular velocity and the inter-frame interval duration. It can be seen that by exponentially processing the rotation angular velocity through the inter-frame interval duration, the target rotation angle obtained by the exponential processing can be limited to a numerical range controllable by the physical engine. Furthermore, based on the target rotation angle and the initial direction parameter of the rotating object, it is determined that the updated direction parameter (i.e., the second direction parameter) of the rotating object also belongs to the numerical range controllable by the physical engine, that is, the updated direction parameter can be represented by the physical engine in the computer device, which can avoid data overflow and game interruption caused by data overflow, thereby improving the smoothness of the game.
[0159] It should be understood that the computer device described in the embodiments of the present application can execute the description of the above data processing method in the corresponding embodiments above, and can also execute the description of the above data processing device in the corresponding embodiments above, which will not be repeated here. In addition, the description of the beneficial effects of adopting the same method will not be repeated.
[0160] In addition, it should be pointed out here that: the embodiment of the present application also provides a computer-readable storage medium, and the computer-readable storage medium stores a computer program executed by the data processing device mentioned above, and the computer program includes program instructions. When the processor executes the program instructions, it can execute the description of the data processing method in the corresponding embodiment above, so it will not be repeated here. In addition, the description of the beneficial effects of the same method will not be repeated. For technical details not disclosed in the computer-readable storage medium embodiment involved in this application, please refer to the description of the method embodiment of this application.
[0161] As an example, the above program instructions may be deployed on a computer device for execution, or deployed on at least two computer devices at one location for execution, or executed on at least two computer devices distributed at at least two locations and interconnected through a communication network. At least two computer devices distributed at at least two locations and interconnected through a communication network may constitute a blockchain network.
[0162] The computer-readable storage medium may be the data processing device provided in any of the aforementioned embodiments or the central storage unit of the computer device, such as a hard disk or a memory of the computer device. The computer-readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, a smart memory card (SMART Media card, SMC), a secure digital (Secure digital, SD) card, a flash memory card (flaSh card), etc. equipped on the computer device. Further, the computer-readable storage medium may also include both the central storage unit of the computer device and an external storage device. The computer-readable storage medium is used to store the computer program and other programs and data required by the computer device. The computer-readable storage medium may also be used to temporarily store data that has been output or is to be output.
[0163] The terms "first", "second", etc. in the description, claims, and drawings of the embodiments of the present application are used to distinguish between contents in different media, rather than to describe a specific order. In addition, the terms "including" and any of their variations are intended to cover non-exclusive inclusions. For example, a process, method, device, product, or equipment that includes a series of steps or units is not limited to the listed steps or modules, but may optionally include steps or modules that are not listed, or may optionally include other step units inherent to these processes, methods, devices, products, or equipment.
[0164] It is understandable that if the above embodiments of the present application need to use user information, etc., it is necessary to obtain user permission or consent and comply with relevant laws and regulations of relevant countries and regions.
[0165] The embodiment of the present application also provides a computer program product, including a computer program / instruction, which implements the description of the above-mentioned data processing method and decoding method in the corresponding embodiment above when the computer program / instruction is executed by the processor, so it will not be repeated here. In addition, the description of the beneficial effects of adopting the same method will not be repeated. For technical details not disclosed in the embodiment of the computer program product involved in this application, please refer to the description of the method embodiment of this application.
[0166] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. 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 this application.
[0167] The method and related apparatus provided by the embodiment of the present application are described with reference to the method flow chart and / or structural diagram provided by the embodiment of the present application. Specifically, each process and / or box in the method flow chart and / or structural diagram, as well as the combination of the processes and / or boxes in the flow chart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable network connection device to generate a machine, so that the instructions executed by the processor of the computer or other programmable network connection device generate instructions for implementing the process in the process. Figure 1 A process or multiple processes and / or structures Figure 1 These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable network-connected device to work in a specific manner, so that the instructions stored in the computer-readable memory produce a product including an instruction device, which implements the functions specified in the process. Figure 1 A process or multiple processes and / or structures Figure 1 These computer program instructions can also be loaded onto a computer or other programmable network connected device, so that a series of operation steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide for implementing the process. Figure 1 A flow or multiple flows and / or structures illustrate the steps of the functions specified in one block or multiple blocks.
[0168] The above disclosure is only the preferred embodiment of the present application, which certainly cannot be used to limit the scope of rights of the present application. Therefore, equivalent changes made according to the claims of the present application are still within the scope covered by the present application.
Claims
1. A data processing method, characterized in that: include: Obtaining a first direction parameter and a rotational angular velocity of the target object in a first game frame, and an inter-frame interval duration between the first game frame and a second game frame; The rendering order of the second game frame is after the rendering order of the first game frame; Exponentially process the rotation angular velocity according to the inter-frame interval duration to obtain a target rotation angle of the target object; A second direction parameter of the target object in the second game frame is determined according to the target rotation angle of the target object and the first direction parameter.
2. The method according to claim 1, characterized in that The step of exponentially processing the rotation angular velocity according to the inter-frame interval duration to obtain a target rotation angle of the target object includes: generating a three-dimensional angular velocity vector of the target object according to the rotational angular velocity; Determining a three-dimensional rotation angle vector of the target object according to the product of the three-dimensional angular velocity vector and the inter-frame interval duration; Performing exponential processing on the three-dimensional rotation angle vector of the target object to obtain the quaternion rotation angle vector of the target object; The quaternion rotation angle vector of the target object is determined as the target rotation angle of the target object.
3. The method according to claim 2, characterized in that The step of performing index processing on the three-dimensional rotation angle vector of the target object to obtain the quaternion rotation angle vector of the target object includes: Converting the three-dimensional rotation angle vector of the target object into a four-dimensional rotation angle vector; The four-dimensional angle vector is used as an exponent and the natural constant is used as a base for operation processing to obtain the quaternion rotation angle vector of the target object.
4. The method according to claim 3, characterized in that The method of performing calculations using the four-dimensional angle vector as an exponent and a natural constant as a base to obtain a quaternion rotation angle vector of the target object includes: Performing modulo processing on the four-dimensional rotation angle vector to obtain a real angle of the target object; Normalizing the four-dimensional rotation angle vector to obtain a unit four-dimensional rotation angle vector; Determine the product of the unit four-dimensional rotation angle vector and the sine value of the real angle as the candidate rotation angle of the target object; The sum of the candidate rotation angle of the target object and the cosine value of the real angle is determined as the quaternion rotation angle vector of the target object.
5. The method according to claim 1, characterized in that The determining, according to the target rotation angle of the target object and the first direction parameter, a second direction parameter of the target object in the second game frame comprises: generating a first quaternion direction vector reflecting the first direction parameter of the target object; Determine the product of the first quaternion direction vector and the quaternion rotation angle vector corresponding to the target rotation angle as the second quaternion direction vector of the target object in the second game frame; The second quaternion direction vector is determined as a second direction parameter of the target object in the second game frame.
6. The method according to claim 1, characterized in that The method further comprises: Acquire movement parameters of the target object and a first position of the target object in the first game frame; Determining a second position of the target object in the second game frame according to the movement parameter of the target object, the inter-frame interval duration, and the first position; The target object is rendered according to the second position and the second direction parameter to obtain a second game frame including the target object.
7. The method according to claim 6, characterized in that The determining, according to the movement parameter of the target object, the inter-frame interval duration, and the first position of the target object in the first game frame, the second position of the target object in the second game frame comprises: The moving distance of the target object is determined by multiplying the moving speed in the moving parameter by the inter-frame interval time length; The second position of the target object in the second game frame is determined according to the moving direction, the moving distance and the first position in the moving parameters.
8. The method according to claim 6, characterized in that The step of rendering the target object according to the second position and the second direction parameter to obtain a second game frame including the target object comprises: If the number of the target objects is at least two, performing collision detection on the at least two target objects according to the second positions respectively corresponding to the at least two target objects to obtain a detection result; Adjusting the second direction parameters respectively corresponding to the at least two target objects according to the detection result to obtain the third direction parameters respectively corresponding to the at least two target objects; The at least two target objects are rendered according to the third direction parameters and the second position respectively corresponding to the at least two target objects to obtain a second game frame including the at least two target objects.
9. The method according to claim 8, characterized in that The adjusting the second direction parameters respectively corresponding to the at least two target objects according to the detection result to obtain the third direction parameters respectively corresponding to the at least two target objects includes: If the detection result indicates that a first target object and a second target object of the at least two target objects will collide, obtaining an object category of the first target object and an object category of the second target object; According to the object category of the first target object and the object category of the second target object, adjusting the second direction parameter of the first target object to obtain a third direction parameter of the first target object; According to the object category of the first target object and the object category of the second target object, the second direction parameter of the second target object is adjusted to obtain the third direction parameter of the second target object.
10. A data processing device, characterized in that: include: An acquisition module, used to acquire a first direction parameter and a rotation angular velocity of a target object in a game engine in a first game frame, and an inter-frame interval duration between the first game frame and a second game frame; The rendering order of the second game frame is after the rendering order of the first game frame; A processing module, configured to perform exponential processing on the rotation angular velocity according to the inter-frame interval duration to obtain a target rotation angle of the target object; A determination module is used to determine a second direction parameter of the target object in the second game frame according to the target rotation angle of the target object and the first direction parameter.
11. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 9 are implemented.
12. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 9 are implemented.
13. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 9 are implemented.
Citation Information
Cited By
Real number vector operation processing method and device, equipment and storage medium
CN119883373A
