Detailed Description
In order to make the technical solutions of the present invention better understood, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
It should be noted that the terms "first," "second," and the like in the description and claims of the present invention and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the invention described herein are capable of operation in sequences other than those illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
In accordance with an embodiment of the present invention, there is provided an embodiment of a method for controlling the movement of objects in a virtual scene, it being noted that the steps illustrated in the flowchart of the drawings may be performed in a computer system such as a set of computer-executable instructions and that, although a logical order is illustrated in the flowchart, in some cases, the steps illustrated or described may be performed in an order different than here.
Fig. 2 is a flowchart of a method for controlling the movement of an object in a virtual scene according to an embodiment of the present invention, as shown in fig. 2, the method includes the following steps:
step S202, a first angle of rotation of a control device is obtained, wherein the control device is used for controlling the target object to move in the virtual scene.
As an alternative embodiment, the target object may be a virtual object to be controlled in a three-dimensional virtual scene (e.g., a VR game scene), including but not limited to characters of various game characters, flyers, and the like; the control device includes, but is not limited to, an interactive device in a VR game (e.g., a helmet, a three-dimensional mouse, glasses, a bracelet, a handle, etc.), and optionally, an interactive device in an AR game. The first angle may be an angle that the control device rotates when the user controls the target object in the virtual scene to move through the control device.
And S204, determining a second angle according to the first angle, wherein the second angle is increased along with the increase of the first angle under the condition that the first angle is smaller than the preset angle, and the second angle is decreased along with the increase of the first angle under the condition that the first angle is larger than or equal to the preset angle.
Specifically, the second angle may be an angle obtained according to a first angle by which the control device is rotated, wherein the second angle increases as the first angle increases when the first angle is smaller than a preset angle; when the first angle is larger than or equal to the preset angle, the second angle is reduced along with the increase of the first angle.
In an optional embodiment, a may be greater than or equal to 0 and less than or equal to 180 degrees, b may be greater than or equal to 0 and less than or equal to 90 degrees, and the preset angle may be 90 degrees. It can be seen that the first angle can be an acute angle or an obtuse angle, while the second angle is always an acute angle, and when the first angle is an acute angle, the second angle increases with the increase of the first angle; when the first angle is an obtuse angle, the second angle decreases as the first angle increases.
In step S206, the moving speed of the target object in the virtual scene is controlled according to the first angle, and the rotation angle of the target object in the virtual scene is controlled according to the second angle.
Specifically, after a first angle of a control device for controlling the target object is acquired, the moving speed of the target object in the three-dimensional virtual scene is controlled according to the first angle, the rotating angle of the target object in the three-dimensional virtual scene is controlled according to a second angle, and the second angle is always an acute angle and is reduced along with the increase of the first angle, so that the whole curve can be kept in a shape similar to a curved fishing rod instead of a curve in a large arch shape, and the curve simulating the dragged object looks more powerful.
As can be seen from the above, in the above implementation of the present application, the angle (i.e. the first angle) by which the control device for controlling the interaction with the target object in the three-dimensional virtual scene is rotated controls the moving speed of the target object in the three-dimensional virtual scene, and the second angle determined according to the first angle controls the rotating angle of the target object in the three-dimensional virtual scene, and it is easy to note that, in the case that the first angle is smaller than the preset angle, the second angle increases with the increase of the first angle; when the first angle is larger than the preset angle, the second angle is reduced along with the increase of the first angle, the purposes of moving or rotating the object in the three-dimensional virtual scene and simulating the moving curve of the object more truly are achieved through the control equipment, the technical effect of improving the user experience of the user immersed in the three-dimensional virtual scene is achieved, and further the technical problems that in the prior art, the handle based on the 3Dof adopts linear control for controlling the object, the moving of the object can only be achieved, the rotation cannot be achieved, and the experience is poor are solved.
In an alternative embodiment, as shown in fig. 3, obtaining the first angle of rotation of the control device may include the steps of:
step S302, determining a first orientation before the control equipment rotates;
step S304, acquiring a second orientation after the control device rotates, and determining a first angle according to the second orientation and the first orientation.
In particular, in the above-described embodiment, when the user controls the movement of the object in the three-dimensional virtual scene through the control device, the target object to be moved is first selected, and determines the position (i.e., the first position) of the target object to be moved, which object the user typically controls by means of the control device, which object the control device is directed towards, and, thus, the first orientation of the control device before controlling the movement of the target object may be determined based on a first position of the target object in the three-dimensional virtual scene, when the user controls the target object to move through the control equipment, the target object can rotate by a certain angle through the control equipment, from the orientation (i.e., the second orientation) at which the control apparatus stops rotating, the angle of rotation during the entire process in which the control apparatus controls the movement of the target object can be determined, i.e. a first angle, in order to determine the direction or distance in which an object in the three-dimensional virtual scene moves, depending on the first angle.
Alternatively, as an alternative embodiment, the moving speed of the target object in the three-dimensional virtual scene may be proportional to the first angle, and the target object rotates by an angle equal to the second angle during the moving process in the three-dimensional virtual scene.
In accordance with any of the above alternative embodiments, the motion curve of the target object may conform to a cubic Bezier curve.
It is easy to note that when interacting with objects in the three-dimensional virtual scene through the control device, the movement of the objects in the three-dimensional scene is determined from the azimuth information of the handle controller by acquiring the azimuth information of the handle controller in space. The object has six degrees of freedom in space, namely, the degree of freedom of movement along the directions of three orthogonal coordinate axes of x, y and z and the degree of freedom of rotation around the three coordinate axes. The motion of the target object in the virtual scene not only comprises the movement towards all directions, but also comprises the rotation of the target object, the existing control equipment interacting with the three-dimensional virtual scene generally adopts a handle controller with 3 degrees of freedom, the control of the object in the three-dimensional virtual scene is controlled by using a straight line, the straight line is dragged, the object is very stiff, the dragging strength can not be embodied, and only the object is simply moved, but the rotation can not be realized. As an optional implementation mode, the method can use a 3-order Bezier curve to simulate a dragging curve, endow the curve with elasticity, and embody the dragging force sense. The movement and the rotation speed of the object are dynamically controlled according to the angle of the Bezier curve, so that a player can visually find the power of dragging the object by himself.
The following is a brief description of a Bezier curve, which is a mathematical curve applied to a two-dimensional graphics application, wherein a 3-step Bezier curve is a smooth curve drawn according to coordinates of any point at four locations. The four points P0, P1, P2, P3 define cubic Bezier curves in a plane or in three-dimensional space. The curve starts from P0 to P1 and goes from the direction of P2 to P3. Generally does not pass through P1 or P2; these two points only provide directional information there. The spacing between P0 and P1 determines how long the curve "goes" in length "in the direction of P2 before turning to P3. The parametric form of the 3 rd order Bezier curve can be represented by equation (1):
B(t)=P0(1-t)3+3P1t(1-t)2+3P2t2(1-t)+P3t3,t∈[0,1] (1)
the idea of using a 3-order Bezier curve in the present application is as follows: taking a point P0 as a point where a handle is located, taking a point P3 as a point where an object needing to be controlled is located, taking a point P1 as a point calculated according to the orientation of the handle, calculating an angle b according to an included angle a between a vector P0- > P3 and a vector P0- > P1, and obtaining a rotating angle b of the vector P3- > P0, and obtaining 3-order Bezier curves with different shapes by adjusting the corresponding relation of the angles a and b and the vector lengths P0- > P1, P3- > P2, so that the displayed curves are simulated better, the curves are endowed with elasticity, and better strength and strength feeling are obtained. It is easy to note that the lengths of the P0- > P1 and P3- > P2 vectors can be set in a self-defined mode, and a user can adjust the lengths to the best effect according to needs.
It is easy to note that in controlling the movement (movement and/or rotation) of a target object in a three-dimensional virtual scene based on a 3 rd order Bezier curve (which simulates the drag curve of a dragged target object), the above-mentioned angles a and b cannot be in a simple proportional or inverse relationship, because when a increases an obtuse angle from an acute angle with dragging, b also becomes an obtuse angle if a and b are in a simple proportional or inverse relationship, and the curve is drawn in the shape as shown in fig. 4.
As an alternative embodiment, the present application defines the magnitude relationship between the first angle and the second angle as the relationship shown in formula (2):
b=Arcsin(Sin(a)*k); (2)
wherein a is a first angle, b is a second angle, k is a constant, 0< k < 1.
Specifically, after the first angle of the control device in the space is acquired, the corresponding second angle can be calculated by the above equation (2). Since sin (a) is greater than 0 when the first angle is in the range of 0 ≦ a ≦ 180 degrees, b (i.e., the second angle) calculated by arcsin will ensure that the clock is at an acute angle and will decrease with increasing angle a after the angle a has changed to an obtuse angle, so that the entire curve will remain in a curved rod-like shape, as shown in fig. 5, rather than a curve with a large arch shape as shown in fig. 4.
It is apparent from the curves shown in fig. 4 and 5 that the dragging force amount presented in fig. 5 is more sufficient.
Based on the above embodiment, in order to implement the movement and rotation of the object in the three-dimensional virtual scene, in a specific implementation process, a ray may be emitted from the position of the handle in a direction of the handle, the ray hits a hit body of the object, then the object is selected by pressing a button on the handle, and then the object starts to be dragged, and the following process is performed: as shown in fig. 6, with P0 as the point of the handle, P3 as the point of the controlled object, and the vector P0- > P1 as the orientation of the handle, it can be seen from the contents shown in fig. 4 and 5 that the angle P1P0P3 (i.e. the first angle) changes with the change of the orientation of the handle, so it changes between 0 and 180 degrees, the angle P0P3P2 (i.e. the second angle) is always acute, and when the angle P1P0P3 (i.e. the first angle) is acute, the angle P0P3P2 (i.e. the second angle) increases with the increase of the angle P1P0P3 (i.e. the first angle); when the angle P1P0P3 (i.e., the first angle) is an obtuse angle, the angle P0P3P2 (i.e., the second angle) decreases with an increase in the angle P1P0P3, so that two variation types of angles are obtained, which can be respectively used to manipulate different movements of the object.
When the target object in the three-dimensional virtual scene is controlled to move, since the angle P1P0P3 changes along with the handle, and the angle P1P0P3 is larger and larger as the handle is rotated by the hand by a larger angle, the angle can be used to control the movement of the object, the simplest is that the object moves with a speed proportional to the angle, and assuming that the angle value of the angle P1P0P3 is a, the moving speed of the object can be expressed as: v ═ a × k, (k is a constant, and ranges from 0< k < 1). It is easy to note that the moving direction of the target object is variable according to the requirement, and in the case where the target object can move freely, the direction of the vector P3- > P2 can be directly used as the moving direction of the target object. If the target object has a fixed track, i.e. a fixed moving direction, then the target object can be moved along the set moving direction by determining the angle between the projection v, v of the vector P3- > P2 on the plane (the plane parallel to the moving direction and perpendicular to the straight line P0- > P3) and the moving direction of the target object is smaller than a certain value.
In order to solve the problem that the object does not change its position when rotating unlike the movement of the control target object when the target object moves in the three-dimensional virtual scene, if the rotation angle is controlled by using an angle that is always increased as the angle P1P0P3 is increased, the object still rotates as the angle P1P0P3 is increased when the handle moves to the rear, that is, the angle P1P0P is an obtuse angle, and in order to solve the problem, the object is controlled by using the angle P0P3P2, the angle P0P3P2 is increased from 0, the angle P0P3P2 is increased as the angle P1P0P3 is increased when the angle P1P0P3 is an acute angle, and the angle P0P3P2 is decreased as the angle P1P0P3 is increased, and the object rotation angle is also decreased when the angle P1P0P3 is an obtuse angle.
Through the embodiment of the application, the movement and the rotation of the object are controlled by using different angles of the Bezier curve, so that the movement and the rotation of the object can be more consistent with the cognition of people, and the reality is more realized. The 3-order Bezier curve is used for simulating a dragging curve, elasticity is given to the curve, the curve looks more powerful and voluminous, and immersion of a player in VR can be improved.
According to an embodiment of the present invention, there is further provided an apparatus embodiment for implementing the method for controlling the motion of an object in a virtual scene, and fig. 7 is a schematic diagram of an apparatus for controlling the motion of an object in a virtual scene according to an embodiment of the present invention, as shown in fig. 7, the apparatus includes: an acquisition unit 701, a determination unit 703, and a control unit 705.
The acquiring unit 701 is configured to acquire a first angle of rotation of a control device, where the control device is configured to control a target object to move in a virtual scene;
a determining unit 703 configured to determine a second angle according to the first angle, where the second angle increases with an increase of the first angle when the first angle is smaller than a preset angle, and the second angle decreases with an increase of the first angle when the first angle is greater than or equal to the preset angle;
a control unit 705 for controlling a moving speed of the target object moving in the virtual scene according to the first angle and controlling a rotation angle of the target object rotating in the virtual scene according to the second angle.
It should be noted here that the above-mentioned acquiring unit 701, determining unit 703 and control unit 705 correspond to steps S202 to S206 in the method embodiment, and the above-mentioned modules are the same as the examples and application scenarios implemented by the corresponding steps, but are not limited to the disclosure of the above-mentioned method embodiment. It should be noted that the modules described above as part of an apparatus may be implemented in a computer system such as a set of computer-executable instructions.
As can be seen from the above, in the above implementation of the present application, the angle (i.e. the first angle) by which the control device for controlling the interaction with the target object in the three-dimensional virtual scene is rotated controls the moving speed of the target object in the three-dimensional virtual scene, and the second angle determined according to the first angle controls the rotating angle of the target object in the three-dimensional virtual scene, and it is easy to note that, in the case that the first angle is smaller than the preset angle, the second angle increases with the increase of the first angle; when the first angle is larger than the preset angle, the second angle is reduced along with the increase of the first angle, the purposes of moving or rotating the object in the three-dimensional virtual scene and simulating the moving curve of the object more truly are achieved through the control equipment, the technical effect of improving the user experience of the user immersed in the three-dimensional virtual scene is achieved, and further the technical problems that in the prior art, the handle based on the 3Dof adopts linear control for controlling the object, the moving of the object can only be achieved, the rotation cannot be achieved, and the experience is poor are solved.
In an alternative embodiment, the obtaining unit may include: the first determining module is used for determining a first orientation before the control equipment rotates; and the second determining module is used for acquiring a second orientation after the control equipment rotates and determining the first angle according to the second orientation and the first orientation.
In an alternative embodiment, the speed of movement is proportional to the first angle and the angle of rotation is equal to the second angle.
In an alternative embodiment, the determining unit is further configured to determine the second angle by the following formula: arcsin (sin (a) k); wherein a is a first angle, b is a second angle, k is a constant, 0< k < 1.
In an optional embodiment, a is greater than or equal to 0 and less than or equal to 180 degrees, b is greater than or equal to 0 and less than or equal to 90 degrees, and the preset angle is 90 degrees.
In an alternative embodiment, the moving and/or rotating of the target object in the virtual scene is controlled based on a cubic Bezier curve.
According to an embodiment of the present invention, there is further provided a storage medium, where the storage medium includes a stored program, where when the program runs, the apparatus on which the storage medium is controlled to execute any one of the optional or preferred methods for controlling motion of an object in a virtual scene in the above method embodiments.
According to an embodiment of the present invention, there is further provided a processor, configured to execute a program, where the program executes any one of the optional or preferred methods for controlling the motion of an object in a virtual scene in the above method embodiments.
According to an embodiment of the present invention, there is also provided a terminal including: one or more processors, a memory, a display device, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, the one or more programs comprising instructions for performing any one of the optional or preferred methods of the above method embodiments for controlling motion of an object in a virtual scene.
The application provides an use Bezier curve control object rotation and removal method in VR, utilize the speed that first angle control object removed, utilize the angle that second angle control object turned to, wherein, first angle is along with the increase of handle pivoted angle and bigger, the second angle is when being in the acute angle, along with the increase of handle pivoted angle and bigger, when being in the obtuse angle, along with the increase of handle pivoted angle and smaller, thereby simulate the curve that shows better, give curve elasticity, thereby obtain better strength sense.
The above-mentioned apparatus may comprise a processor and a memory, and the above-mentioned units may be stored in the memory as program units, and the processor executes the above-mentioned program units stored in the memory to implement the corresponding functions.
The memory may include volatile memory in a computer readable medium, Random Access Memory (RAM) and/or nonvolatile memory such as Read Only Memory (ROM) or flash memory (flash RAM), and the memory includes at least one memory chip.
The order of the embodiments of the present application described above does not represent the merits of the embodiments.
In the above embodiments of the present application, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments. In the embodiments provided in the present application, it should be understood that the disclosed technology can be implemented in other ways.
The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units may be a logical division, and in actual implementation, there may be another division, for example, multiple units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, units or modules, and may be in an electrical or other form.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application may be substantially implemented or contributed to by the prior art, or all or part of the technical solution may be embodied in a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic or optical disk, and other various media capable of storing program codes.
The foregoing is only a preferred embodiment of the present application and it should be noted that those skilled in the art can make several improvements and modifications without departing from the principle of the present application, and these improvements and modifications should also be considered as the protection scope of the present application.