Role displacement determination method and device, electronic equipment and storage medium
By using Bessel splines in electronic devices to simulate ocean currents and calculate character displacement, the problem of not being able to have physical force influence on characters in the prior art is solved, and the gaming experience is improved.
Patent Information
- Application Number
- CN202411995054.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-31
- Publication Date
- 2025-02-28
AI Technical Summary
When simulating the ocean current environment, the prior art cannot effectively affect the characters' physical force, resulting in a poor user's gaming experience.
By storing multiple Bessel splines in an electronic device, each spline represents an ocean current, obtains the current position and target Bessel spline of the character to be moved, generates an offset Bessel spline, calculates the displacement of the character in the ocean current, and calculates the role displacement in combination with active displacement.
It realizes simulation of the physical influence of the characters in the ocean current, improving the user's gaming experience.
Smart Images

Figure CN119524419A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method, device, electronic device and storage medium for determining character displacement. Background Art
[0002] In order to ensure a better gaming experience, games often simulate real-world environments, such as wind, ocean currents, etc. At present, the existing technology generally only simulates ocean currents at a visual level, so that users can see the ocean current environment, but it does not have a physical impact on the character, that is, the force of the ocean current on the character cannot be realized, resulting in a poor gaming experience for users. Summary of the invention
[0003] In view of this, the purpose of the present application is to provide a method, device, electronic device and storage medium for determining character displacement.
[0004] In order to achieve the above purpose, the technical solution adopted in the embodiment of the present application is as follows:
[0005] In a first aspect, the present application provides a method for determining character displacement, which is applied to an electronic device, wherein a plurality of Bezier splines are stored in the electronic device, each of which represents an ocean current, and the method comprises:
[0006] Get the current position of the character to be moved and the corresponding target Bezier spline;
[0007] Generate an offset Bezier spline corresponding to the character to be moved according to the target Bezier spline and the current position;
[0008] The ocean current displacement of the character to be moved is calculated according to the offset Bezier spline, the ocean current parameters corresponding to the target Bezier spline and the current position, and the character displacement of the character to be moved is calculated according to the ocean current displacement and the active displacement of the character to be moved.
[0009] In an optional implementation, the Bezier spline includes a plurality of curve nodes, and adjacent curve nodes form a Bezier curve; and generating an offset Bezier spline corresponding to the character to be moved according to the target Bezier spline and the current position includes:
[0010] Determine a target curve node corresponding to the character to be moved from the target Bezier spline according to the current position, and determine a target Bezier curve according to the target curve node; wherein the character to be moved is located within an ocean current range corresponding to the target Bezier curve with the target curve node as the first node;
[0011] An offset Bezier spline corresponding to the character to be moved is generated according to the current position and the target Bezier curve.
[0012] In an optional implementation, determining a target curve node corresponding to the character to be moved from the target Bezier spline according to the current position includes:
[0013] Determine, according to the current position, a nearest curve node which is closest to the current position from among a plurality of curve nodes corresponding to the target Bezier spline;
[0014] Calculating a Z-axis offset of the current position compared to the nearest curve node according to the current position and the node position of the nearest curve node;
[0015] If the Z-axis offset is less than 0, determining the target curve node to be the previous curve node adjacent to the nearest curve node;
[0016] If the Z-axis offset is not less than 0, the target curve node is determined to be the nearest curve node.
[0017] In an optional implementation, each of the Bezier curves includes a plurality of interpolation nodes, and adjacent interpolation nodes form a Bezier curve segment; and generating an offset Bezier spline corresponding to the character to be moved according to the current position and the target Bezier curve includes:
[0018] Determine a target interpolation node corresponding to the character to be moved from the target Bezier curve according to the current position, and determine a target Bezier curve segment according to the target interpolation node; wherein the character to be moved is located within an ocean current range corresponding to the target Bezier curve segment with the target interpolation node as the first node;
[0019] Determine a first projection position of the current position on the target Bezier curve according to the target Bezier curve segment, the current position and the target Bezier curve;
[0020] An offset between the first projection position and the current position is calculated, and an offset Bezier spline corresponding to the character to be moved is generated according to the offset and the target Bezier spline.
[0021] In an optional implementation, determining a first projection position of the current position on the target Bezier curve according to the target Bezier curve segment, the current position and the target Bezier curve includes:
[0022] Determine a second projection position of the current position on the target Bezier curve segment;
[0023] Calculating a first position ratio according to a line segment length of the target Bezier curve segment and a line segment length between the target interpolation node and the second projection position, and calculating a second position ratio according to the first position ratio and the number of Bezier curve segments in the target Bezier curve;
[0024] The first projection position is calculated according to the second position ratio and a curve formula corresponding to the target Bezier curve.
[0025] In an optional implementation, the ocean current parameters include ocean current speed and ocean current direction; and calculating the ocean current displacement of the character to be moved according to the offset Bezier spline, the ocean current parameters corresponding to the target Bezier spline and the current position, comprises:
[0026] Calculating a moving distance corresponding to the character to be moved according to a moving duration corresponding to the character to be moved and an ocean current speed of the target Bezier spline;
[0027] Calculating an updated position of the character to be moved according to the position of the character to be moved in the offset Bezier spline, the moving distance, and the ocean current direction corresponding to the offset Bezier spline;
[0028] The ocean current displacement of the character to be moved is calculated according to the updated position and the current position.
[0029] In a second aspect, the present application provides a device for determining character displacement, which is applied to an electronic device, wherein a plurality of Bezier splines are stored in the electronic device, each of which represents an ocean current, and the device comprises:
[0030] An acquisition module, used to acquire the current position of the character to be moved and the corresponding target Bezier spline; the current position is the position of the character to be moved in the world coordinate system;
[0031] A generating module, used for generating an offset Bezier spline corresponding to the character to be moved according to the target Bezier spline and the current position;
[0032] A calculation module is used to calculate the ocean current displacement of the character to be moved according to the offset Bezier spline, the ocean current parameters corresponding to the target Bezier spline and the current position, and calculate the character displacement of the character to be moved according to the ocean current displacement and the active displacement of the character to be moved.
[0033] In an optional embodiment, the Bezier spline includes multiple curve nodes, and adjacent curve nodes form a Bezier curve; the generation module is also used to determine the target curve node corresponding to the character to be moved from the target Bezier spline according to the current position; wherein the character to be moved is located within the ocean current range corresponding to the target Bezier curve with the target curve node as the first node; based on the current position and the target Bezier curve, generate an offset Bezier spline corresponding to the character to be moved.
[0034] In a third aspect, the present application provides an electronic device, comprising a processor and a memory, wherein the memory stores a computer program that can be executed by the processor, and the processor can execute the computer program to implement the method described in any one of the aforementioned embodiments.
[0035] In a fourth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the method described in any one of the aforementioned implementations.
[0036] The character displacement determination method, device, electronic device and storage medium provided in the embodiment of the present application can obtain the current position of the character to be moved and the corresponding target Bezier spline, and generate the offset Bezier spline corresponding to the character to be moved according to the target Bezier spline and the current position, thereby calculating the ocean current displacement of the character to be moved according to the ocean current parameters corresponding to the offset Bezier spline and the target Bezier spline and the current position, and calculating the target displacement of the character to be moved according to the ocean current displacement and the active displacement of the character to be moved. In this way, the physical force effect of the ocean current on the character can be simulated to improve the user's gaming experience.
[0037] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0039] Figure 1 A block diagram of an electronic device provided by an embodiment of the present application is shown;
[0040] Figure 2 A schematic diagram of a process of determining a character displacement provided by an embodiment of the present application is shown;
[0041] Figure 3 A schematic diagram of a Bezier curve is shown;
[0042] Figure 4 A functional module diagram of a device for determining character displacement provided in an embodiment of the present application is shown.
[0043] Icon: 100 - electronic device; 110 - memory; 120 - processor; 130 - communication module; 200 - acquisition module; 210 - generation module; 220 - calculation module. DETAILED DESCRIPTION
[0044] 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. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various different configurations.
[0045] Therefore, the following detailed description of the embodiments of the present application provided in the accompanying drawings is not intended to limit the scope of the present application for which protection is sought, but merely represents selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present application.
[0046] It should be noted that relational terms such as "first" and "second" are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprises" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0047] Figure 1 is a block diagram of an electronic device 100 provided in an embodiment of the present application, see Figure 1 , the electronic device 100 includes a memory 110, a processor 120 and a communication module 130. The memory 110, the processor 120 and the communication module 130 are electrically connected to each other directly or indirectly to achieve data transmission or interaction. For example, these components can be electrically connected to each other through one or more communication buses or signal lines.
[0048] The memory 110 is used to store computer programs or data that can be executed by the processor. The memory 110 can be, but is not limited to, a random access memory (RAM), a read only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable read-only memory (EEPROM), etc.
[0049] The processor 120 is used to read / write data or computer programs stored in the memory, and execute the computer program to implement the character displacement determination method provided in the embodiment of the present application.
[0050] The communication module 130 is used to establish a communication connection between the electronic device and other communication terminals through a network, and to send and receive data through the network.
[0051] Optionally, a plurality of Bezier splines are stored in the electronic device, and each Bezier spline represents an ocean current.
[0052] It should be understood that Figure 1 The structure shown is only a schematic diagram of the structure of the electronic device. The electronic device may also include Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown. Figure 1 Each component shown in the figure can be implemented by hardware, software or a combination thereof.
[0053] Next, the above Figure 1 The electronic device in the embodiment is the execution subject, and the character displacement determination method provided in the embodiment of the present application is exemplarily introduced in combination with the flow chart.
[0054] Specifically, Figure 2 A flow chart of a method for determining a character displacement provided in an embodiment of the present application is shown in FIG. Figure 2 , the method comprising:
[0055] Step S20, obtaining the current position of the character to be moved and the corresponding target Bezier spline.
[0056] Optionally, the electronic device may determine a target Bezier spline corresponding to the character to be moved according to a range of an ocean current in which the character to be moved is currently located.
[0057] Optionally, the current position refers to the coordinate position of the character to be moved in the world coordinate system at the current moment. Optionally, the electronic device can calculate the character displacement corresponding to the character to be moved once every preset time length when the character to be moved enters the ocean current range, and move it according to the character displacement. Therefore, the electronic device can obtain the current position of the character to be moved and the corresponding target Bezier spline once every preset time length. For example, the character displacement of the character to be moved in this frame is calculated once every frame.
[0058] Step S21, generating an offset Bezier spline corresponding to the character to be moved according to the target Bezier spline and the current position.
[0059] Optionally, the Bezier spline can characterize the direction of the ocean current at the center of the ocean current, but for the character to be moved, it may be located at other positions in the ocean current. Therefore, in order to make the calculated ocean current displacement conform to the actual situation of the character to be moved and satisfy the simulation of physical forces, it is also necessary to generate the corresponding offset Bezier spline for the current position of the character to be moved, so as to calculate the character displacement of the character to be moved according to the offset Bezier spline corresponding to the character to be moved.
[0060] For example, for a ring-like ocean current with the same flow speed at any point in the current, if two characters start from corresponding positions on the inside and outside of the ring at the same time, the character on the inside of the ring will reach the end position earlier than the character on the outside of the ring.
[0061] Step S22, calculating the ocean current displacement of the character to be moved according to the ocean current parameters corresponding to the offset Bezier spline and the target Bezier spline and the current position, and calculating the character displacement of the character to be moved according to the ocean current displacement and the active displacement of the character to be moved.
[0062] Optionally, current displacement refers to the displacement caused by the force of the ocean current on the character to be moved; active displacement refers to the displacement caused by the character to be moved moving on its own, such as the displacement caused by being pushed by others, the displacement caused by the active movement of the character to be moved, and so on.
[0063] It can be understood that both the ocean current displacement and the active displacement are vector values, and the electronic device can determine the character displacement of the character to be moved by adding the ocean current displacement to the active displacement.
[0064] In this embodiment, the electronic device can move the character to be moved according to the character displacement, so that the character to be moved reaches a new position.
[0065] In the character displacement determination method provided in the embodiment of the present application, the electronic device can obtain the current position of the character to be moved and the corresponding target Bezier spline, and generate the offset Bezier spline corresponding to the character to be moved according to the target Bezier spline and the current position, thereby calculating the ocean current displacement of the character to be moved according to the ocean current parameters corresponding to the offset Bezier spline and the target Bezier spline and the current position, and calculating the character displacement of the character to be moved according to the ocean current displacement and the active displacement of the character to be moved. In this way, the physical force effect of the ocean current on the character can be simulated to improve the user's gaming experience.
[0066] In this embodiment, the Bezier spline may be formed by splicing a plurality of Bezier curves end to end, so the Bezier spline may include a plurality of curve nodes, and adjacent curve nodes form a Bezier curve.
[0067] Figure 3 For a schematic diagram of a Bezier curve, see Figure 3 , the Bezier curve is a third-order curve, defined by four points P0, P1, P2, and P3 in a plane or in three-dimensional space. The third-order Bezier curve starts from P0 and goes to P1, and comes to P3 from the direction of P2. Among them, P0 is the first node of the Bezier curve, P3 is the last node of the Bezier curve, and P1 and P2 are the control points of the Bezier curve, among which P1 is the front control point of P0, and P2 is the back control point of P3.
[0068] Obviously, P1 and P2 are only used to provide direction information for the Bezier curve, and the distance between P0 and P1 determines the length of the curve in the direction of P1 before turning to P2.
[0069] It can be understood that the curve nodes mentioned in this embodiment refer to nodes on the Bezier curve, namely the first node P0 and the last node P3.
[0070] In this embodiment, the formula of the third-order Bezier curve can be represented as follows:
[0071] B(t)=(1-t) 3 P0+3(1-t) 2 tP1+3(1-t)t 2 P2+t 3 P3,0≤t≤1
[0072] Among them, any point on the Bezier curve can be represented by t, that is, when t = 0, it corresponds to Figure 3 Point P0 in the graph corresponds to when t=1 Figure 3 Point P3 in .
[0073] Optionally, since a Bezier spline is composed of multiple Bezier curves connected end to end, a Bezier spline refers to a continuous curve formed by connecting a set of given third-order Bezier curves end to end, and has a continuous derivative, making the curve smooth. Except for the last curve, the tail node of any Bezier curve in the Bezier spline coincides with the first node of the next Bezier curve. If a Bezier spline is composed of n Bezier curves, then it contains n+1 nodes.
[0074] In addition, the first node of the first segment of the Bezier spline curve is the first node of the Bezier spline, and the last node of the last segment of the Bezier spline curve is the last node of the Bezier spline.
[0075] Optionally, the Bezier spline also includes a radial parameter, which characterizes the radial extent of the current.
[0076] In this embodiment, a Bezier spline can represent the direction of the center position of an ocean current, and the radial parameter represents the radial range of the ocean current.
[0077] Optionally, the electronic device may determine the corresponding ocean current range for each curve node in the Bezier spline.
[0078] In one possible implementation, the electronic device can generate a corresponding tangent for each curve node, and determine the plane figure formed by the intersection of the surface perpendicular to the tangent and the Bezier curve as the ocean current cross section of the curve node. The ocean current cross section can be circular, and the radial parameter is the radius of the ocean current cross section.
[0079] It can be understood that, for each curve node, all ocean current ranges between its ocean current cross-section and the ocean current cross-section of the next curve node of the curve node can be regarded as the ocean current range corresponding to the curve node.
[0080] For an example, see Figure 3 The ocean current range between the ocean current cross section of the P0 node and the ocean current cross section of the P3 node can be regarded as the ocean current range corresponding to the P0 node. It can be understood that all points within this ocean current range correspond to the P0 node.
[0081] Based on this, a possible implementation method is provided for how to generate an offset Bezier spline corresponding to the character to be moved according to the target Bezier spline and the current position.
[0082] Specifically, the electronic device can determine the target curve node corresponding to the character to be moved from the target Bezier spline according to the current position, and determine the target Bezier curve according to the target curve node, thereby generating an offset Bezier spline corresponding to the character to be moved according to the current position and the target Bezier curve.
[0083] The character to be moved is located within the ocean current range corresponding to the target Bezier curve with the target curve node as the first node.
[0084] Optionally, the electronic device can determine the target curve node by traversing each curve node in the target Bezier spline to determine which curve node the point corresponding to the current position is located within the ocean current range, thereby determining the target curve node. The Bezier curve with the target curve node as the first node and the next curve node of the target curve node as the tail node is the target Bezier curve.
[0085] In one possible implementation, the electronic device may determine, based on the current position, the nearest curve node that is closest to the current position from among multiple curve nodes corresponding to the target Bezier spline, and calculate the Z-axis offset of the current position compared to the nearest curve node based on the current position and the node position of the nearest curve node.
[0086] In this embodiment, if the Z-axis offset is less than 0, the target curve node is determined to be the previous curve node adjacent to the nearest curve node; if the Z-axis offset is not less than 0, the target curve node is determined to be the nearest curve node.
[0087] Optionally, each curve node corresponds to a world coordinate, and the electronic device can traverse each curve node in the target Bezier spline to determine the distance between each curve node and the current position, thereby determining the nearest curve node closest to the current position, and then determine the corresponding target curve node based on the nearest curve node and the current position.
[0088] In an example, see above Figure 3 If the nearest curve node closest to the current position is P3, then when the Z-axis offset between the current position and P3 is less than 0, the target curve node is determined to be P0, and when the Z-axis offset between the current position and P3 is not less than 0, the target curve node is determined to be P3.
[0089] Optionally, the electronic device can calculate the coordinates of the projection position by calculating the t value corresponding to the projection position of the current position on the target Bezier curve, and substituting the t value into the curve formula corresponding to the target Bezier curve, thereby combining the offset between the projection position and the current position to generate the offset Bezier spline.
[0090] In this embodiment, in order to improve the accuracy of generating the offset Bezier spline, each Bezier curve may be subdivided into a plurality of curve segments, and the projection position of the current position on the target Bezier curve is determined by combining the curve segments.
[0091] Optionally, each Bezier curve may include multiple interpolation nodes, and the multiple interpolation nodes may divide the Bezier curve into multiple Bezier curve segments, that is, two adjacent interpolation nodes may constitute a Bezier curve segment. Optionally, the electronic device may determine the corresponding ocean current range for each interpolation node in the Bezier curve.
[0092] In one possible implementation, the electronic device can generate a corresponding tangent for each interpolation node, and determine the plane figure formed by the intersection of the surface perpendicular to the tangent and the Bezier curve as the ocean current cross section of the interpolation node. The ocean current cross section can be circular, and the radial parameter is the radius of the ocean current cross section.
[0093] It can be understood that for each interpolation node, all ocean current ranges between its ocean current cross section and the ocean current cross section of the next interpolation node of the interpolation node can be regarded as the ocean current range corresponding to the interpolation node. In other words, all points within the ocean current range of a certain interpolation node correspond to the interpolation node.
[0094] Next, a possible implementation method is provided for how to generate an offset Bezier spline corresponding to the character to be moved based on the current position and the target Bezier curve.
[0095] Specifically, the electronic device can determine the target interpolation node corresponding to the character to be moved from the target Bezier curve according to the current position, and determine the target Bezier curve segment according to the target interpolation node, determine the first projection position of the current position on the target Bezier curve according to the target Bezier curve segment, the current position and the target Bezier curve, calculate the offset between the first projection position and the current position, and generate an offset Bezier spline corresponding to the character to be moved according to the offset and the target Bezier spline.
[0096] The character to be moved is located within the ocean current range corresponding to the target Bezier curve segment with the target interpolation node as the first node.
[0097] Optionally, the electronic device may traverse each interpolation node on the target Bezier curve to determine the nearest interpolation node that is closest to the current position, and calculate the Z-axis offset between the current position and the nearest interpolation node.
[0098] It can be understood that if the Z-axis offset is less than 0, the target interpolation node can be determined to be the previous interpolation node of the nearest interpolation node, and if the Z-axis offset is not less than 0, the target interpolation node can be determined to be the nearest interpolation node.
[0099] Optionally, the electronic device may determine a Bezier curve segment with the target interpolation node as the first node and the next node of the target interpolation node as the tail node as the target Bezier curve segment, and thereby determine the first projection position of the current position on the target Bezier curve based on the target Bezier curve segment, the current position and the target Bezier curve, thereby generating an offset Bezier spline.
[0100] Optionally, after determining the first projection position, the electronic device may generate a local coordinate system with the first projection position as the origin and the tangent of the first projection position as the Z axis, thereby determining the offset between the current position and the first projection position according to the local coordinate system.
[0101] Optionally, the electronic device may offset each curve node in the target Bezier spline based on the offset, thereby generating the offset Bezier spline.
[0102] Next, a possible implementation method is provided for determining a first projection position of the current position on the target Bezier curve according to the target Bezier curve segment, the current position and the target Bezier curve.
[0103] Specifically, the electronic device can determine the second projection position of the current position on the target Bezier curve segment, calculate the first position ratio according to the line segment length of the target Bezier curve segment and the line segment length between the target interpolation node and the second projection position, calculate the second position ratio according to the first position ratio and the number of Bezier curve segments in the target Bezier curve, and calculate the first projection position according to the second position ratio and the curve formula corresponding to the target Bezier curve.
[0104] Optionally, to facilitate calculation of the projection position, the electronic device may approximately regard the target Bezier curve segment as a straight line segment for calculation.
[0105] Optionally, if the target interpolation node is P j , then the straight line segment corresponding to the target Bezier curve segment is P j P j+1 , if the current position is P j P j+1 The projection position on is P′, then the first position ratio t′ is P j P′ and P j P j+1 The ratio between .
[0106] It can be understood that t′ can approximately reflect the second projection position of the current position on the target Bezier curve segment.
[0107] Optionally, the electronic device may determine the ratio of the first position ratio to the number of target Bezier curve segments as the second position ratio t. It can be understood that the second position ratio may reflect the first projection position of the current position on the target Bezier curve.
[0108] In this embodiment, the electronic device may substitute the second position ratio into the curve formula corresponding to the target Bezier curve, thereby calculating the coordinates of the first projection position.
[0109] Optionally, based on this, the electronic device can calculate the offset of the character to be moved compared to the target Bezier curve according to the first projection position and the current position, thereby generating an offset Bezier spline according to the offset, and then calculating the ocean current displacement of the character to be moved according to the offset Bezier spline.
[0110] In this embodiment, the ocean current parameters may include ocean current speed and ocean current direction. The electronic device can calculate the moving distance corresponding to the character to be moved according to the moving time corresponding to the character to be moved and the ocean current speed of the target Bezier spline, calculate the updated position of the character to be moved according to the position of the character to be moved in the offset Bezier spline, the moving distance and the ocean current direction corresponding to the offset Bezier spline, and calculate the ocean current displacement of the character to be moved according to the updated position and the current position.
[0111] Optionally, the moving duration refers to the duration between the current moment and the last moment when the character displacement corresponding to the character to be moved was calculated.
[0112] Optionally, the moving distance that the character to be moved should have under the action of the ocean current can be calculated through the moving time and the moving speed.
[0113] Optionally, since the character to be moved needs to move along the Bezier spline, the electronic device can move the character to be moved along the offset Bezier spline according to the position of the character to be moved in the offset Bezier spline and the direction of the ocean current by the moving distance, thereby obtaining the updated position of the character to be moved.
[0114] Optionally, the position of the character to be moved in the offset Bezier spline can be represented by a target curve node on the offset Bezier spline and a second position ratio t, wherein the target curve node on the offset Bezier spline corresponds to the target curve node corresponding to the character to be moved in the target Bezier spline.
[0115] Optionally, the electronic device may calculate the ocean current displacement of the character to be moved under the action of the ocean current according to the updated position and the current position.
[0116] In order to execute the corresponding steps in the above embodiments and various possible methods, a method for implementing a character displacement determination device is given below. Optionally, the character displacement determination device can adopt the above Figure 1For further information, please refer to Figure 4 , Figure 4 This is a functional module diagram of a character displacement determination device provided in an embodiment of the present application. It should be noted that the basic principle and technical effects of the character displacement determination device provided in this embodiment are the same as those of the above-mentioned embodiments. For the sake of brief description, for parts not mentioned in this embodiment, reference can be made to the corresponding contents in the above-mentioned embodiments. The character displacement determination device includes: an acquisition module 200, a generation module 210, and a calculation module 220.
[0117] The acquisition module 200 is used to acquire the current position of the character to be moved and the corresponding target Bezier spline; the current position is the position of the character to be moved in the world coordinate system.
[0118] It can be understood that the acquisition module 200 can also be used to execute the above step S20.
[0119] The generation module 210 is used to generate an offset Bezier spline corresponding to the character to be moved according to the target Bezier spline and the current position.
[0120] It can be understood that the generation module 210 can also be used to execute the above step S21.
[0121] The calculation module 220 is used to calculate the ocean current displacement of the character to be moved according to the ocean current parameters corresponding to the offset Bezier spline and the target Bezier spline and the current position, and calculate the character displacement of the character to be moved according to the ocean current displacement and the active displacement of the character to be moved.
[0122] It can be understood that the calculation module 220 can also be used to execute the above step S22.
[0123] Optionally, the generation module 210 can also be used to determine the target curve node corresponding to the character to be moved from the target Bezier spline according to the current position, and determine the target Bezier curve according to the target curve node; wherein the character to be moved is located within the ocean current range corresponding to the target Bezier curve with the target curve node as the first node; based on the current position and the target Bezier curve, generate an offset Bezier spline corresponding to the character to be moved.
[0124] Optionally, the generation module 210 can also be used to determine the nearest curve node that is closest to the current position from multiple curve nodes corresponding to the target Bezier spline according to the current position; calculate the Z-axis offset of the current position compared to the nearest curve node according to the current position and the node position of the nearest curve node; if the Z-axis offset is less than 0, determine that the target curve node is the previous curve node adjacent to the nearest curve node; if the Z-axis offset is not less than 0, determine that the target curve node is the nearest curve node.
[0125] Optionally, the generation module 210 can also be used to determine a target interpolation node corresponding to the character to be moved from the target Bezier curve according to the current position, and determine a target Bezier curve segment according to the target interpolation node; wherein the character to be moved is located within the ocean current range corresponding to the target Bezier curve segment with the target interpolation node as the first node; determine the first projection position of the current position on the target Bezier curve according to the target Bezier curve segment, the current position and the target Bezier curve; calculate the offset between the first projection position and the current position, and generate an offset Bezier spline corresponding to the character to be moved according to the offset and the target Bezier spline.
[0126] Optionally, the generation module 210 can also be used to determine a second projection position of the current position on the target Bezier curve segment; calculate the first position ratio according to the line segment length of the target Bezier curve segment and the line segment length between the target interpolation node and the second projection position, and calculate the second position ratio according to the first position ratio and the number of Bezier curve segments in the target Bezier curve; calculate the first projection position according to the second position ratio and the curve formula corresponding to the target Bezier curve.
[0127] Optionally, the calculation module 220 can also be used to calculate the moving distance corresponding to the character to be moved based on the moving time corresponding to the character to be moved and the ocean current speed of the target Bezier spline; calculate the updated position of the character to be moved based on the position of the character to be moved in the offset Bezier spline, the moving distance and the ocean current direction corresponding to the offset Bezier spline; calculate the ocean current displacement of the character to be moved based on the updated position and the current position.
[0128] Optionally, the above modules can be stored in the form of software or firmware. Figure 1 The memory shown in the figure or solidified in the operating system (OS) of the electronic device, and can be Figure 1 Meanwhile, the data and program codes required for executing the above modules can be stored in the memory.
[0129] The embodiment of the present application also provides a computer-readable storage medium on which a computer program is stored. When the computer program is processed, the method for determining the character displacement provided in the embodiment of the present application can be implemented.
[0130] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.
[0131] In addition, the functional modules in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
[0132] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0133] The above description is only the preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
Claims
1. A method for determining character displacement, characterized in that: Applied to an electronic device, wherein a plurality of Bezier splines are stored in the electronic device, each of the Bezier splines represents an ocean current, and the method comprises: Get the current position of the character to be moved and the corresponding target Bezier spline; Generate an offset Bezier spline corresponding to the character to be moved according to the target Bezier spline and the current position; The ocean current displacement of the character to be moved is calculated according to the offset Bezier spline, the ocean current parameters corresponding to the target Bezier spline and the current position, and the character displacement of the character to be moved is calculated according to the ocean current displacement and the active displacement of the character to be moved.
2. The method according to claim 1, characterized in that The Bezier spline includes a plurality of curve nodes, and adjacent curve nodes form a Bezier curve; and generating an offset Bezier spline corresponding to the character to be moved according to the target Bezier spline and the current position, comprising: Determine a target curve node corresponding to the character to be moved from the target Bezier spline according to the current position, and determine a target Bezier curve according to the target curve node; wherein the character to be moved is located within an ocean current range corresponding to the target Bezier curve with the target curve node as the first node; An offset Bezier spline corresponding to the character to be moved is generated according to the current position and the target Bezier curve.
3. The method according to claim 2, characterized in that The step of determining a target curve node corresponding to the character to be moved from the target Bezier spline according to the current position includes: Determine, according to the current position, a nearest curve node which is closest to the current position from among a plurality of curve nodes corresponding to the target Bezier spline; Calculating a Z-axis offset of the current position compared to the nearest curve node according to the current position and the node position of the nearest curve node; If the Z-axis offset is less than 0, determining the target curve node to be the previous curve node adjacent to the nearest curve node; If the Z-axis offset is not less than 0, the target curve node is determined to be the nearest curve node.
4. The method according to claim 2, characterized in that Each of the Bezier curves includes a plurality of interpolation nodes, and adjacent interpolation nodes form a Bezier curve segment; generating an offset Bezier spline corresponding to the character to be moved according to the current position and the target Bezier curve, including: Determine a target interpolation node corresponding to the character to be moved from the target Bezier curve according to the current position, and determine a target Bezier curve segment according to the target interpolation node; wherein the character to be moved is located within an ocean current range corresponding to the target Bezier curve segment with the target interpolation node as the first node; Determine a first projection position of the current position on the target Bezier curve according to the target Bezier curve segment, the current position and the target Bezier curve; An offset between the first projection position and the current position is calculated, and an offset Bezier spline corresponding to the character to be moved is generated according to the offset and the target Bezier spline.
5. The method according to claim 4, characterized in that The step of determining a first projection position of the current position on the target Bezier curve according to the target Bezier curve segment, the current position, and the target Bezier curve includes: Determine a second projection position of the current position on the target Bezier curve segment; Calculating a first position ratio according to a line segment length of the target Bezier curve segment and a line segment length between the target interpolation node and the second projection position, and calculating a second position ratio according to the first position ratio and the number of Bezier curve segments in the target Bezier curve; The first projection position is calculated according to the second position ratio and a curve formula corresponding to the target Bezier curve.
6. The method according to claim 1, characterized in that The ocean current parameters include ocean current speed and ocean current direction; the calculating the ocean current displacement of the character to be moved according to the offset Bezier spline, the ocean current parameters corresponding to the target Bezier spline and the current position, comprises: Calculating a moving distance corresponding to the character to be moved according to a moving duration corresponding to the character to be moved and an ocean current speed of the target Bezier spline; Calculating an updated position of the character to be moved according to the position of the character to be moved in the offset Bezier spline, the moving distance, and the ocean current direction corresponding to the offset Bezier spline; The ocean current displacement of the character to be moved is calculated according to the updated position and the current position.
7. A device for determining character displacement, characterized in that: Applied to an electronic device, wherein a plurality of Bezier splines are stored in the electronic device, each of which represents an ocean current, and the device comprises: An acquisition module, used to acquire the current position of the character to be moved and the corresponding target Bezier spline; the current position is the position of the character to be moved in the world coordinate system; A generating module, used for generating an offset Bezier spline corresponding to the character to be moved according to the target Bezier spline and the current position; A calculation module is used to calculate the ocean current displacement of the character to be moved according to the offset Bezier spline, the ocean current parameters corresponding to the target Bezier spline and the current position, and calculate the character displacement of the character to be moved according to the ocean current displacement and the active displacement of the character to be moved.
8. The device according to claim 7, characterized in that The Bezier spline includes a plurality of curve nodes, and adjacent curve nodes form a Bezier curve; the generation module is further used to determine the target curve node corresponding to the character to be moved from the target Bezier spline according to the current position; wherein the character to be moved is located within the ocean current range corresponding to the target Bezier curve with the target curve node as the first node; and based on the current position and the target Bezier curve, generate an offset Bezier spline corresponding to the character to be moved.
9. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory stores a computer program executable by the processor, and the processor can execute the computer program to implement the method according to any one of claims 1 to 6.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.