[go: up one dir, main page]

CN115814398A - Method and device for moving waistband following player in virtual reality and computer equipment - Google Patents

Method and device for moving waistband following player in virtual reality and computer equipment Download PDF

Info

Publication number
CN115814398A
CN115814398A CN202211490580.8A CN202211490580A CN115814398A CN 115814398 A CN115814398 A CN 115814398A CN 202211490580 A CN202211490580 A CN 202211490580A CN 115814398 A CN115814398 A CN 115814398A
Authority
CN
China
Prior art keywords
belt
current
distance
speed
player
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211490580.8A
Other languages
Chinese (zh)
Inventor
罗威
许秋子
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Realis Multimedia Technology Co Ltd
Original Assignee
Shenzhen Realis Multimedia Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Realis Multimedia Technology Co Ltd filed Critical Shenzhen Realis Multimedia Technology Co Ltd
Priority to CN202211490580.8A priority Critical patent/CN115814398A/en
Publication of CN115814398A publication Critical patent/CN115814398A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F13/00Video games, i.e. games using an electronically generated display having two or more dimensions
    • A63F13/20Input arrangements for video game devices
    • A63F13/21Input arrangements for video game devices characterised by their sensors, purposes or types
    • A63F13/212Input arrangements for video game devices characterised by their sensors, purposes or types using sensors worn by the player, e.g. for measuring heart beat or leg activity
    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F13/00Video games, i.e. games using an electronically generated display having two or more dimensions
    • A63F13/20Input arrangements for video game devices
    • A63F13/21Input arrangements for video game devices characterised by their sensors, purposes or types
    • A63F13/211Input arrangements for video game devices characterised by their sensors, purposes or types using inertial sensors, e.g. accelerometers or gyroscopes
    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F13/00Video games, i.e. games using an electronically generated display having two or more dimensions
    • A63F13/50Controlling the output signals based on the game progress
    • A63F13/52Controlling the output signals based on the game progress involving aspects of the displayed game scene

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Human Computer Interaction (AREA)
  • Health & Medical Sciences (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Biophysics (AREA)
  • Cardiology (AREA)
  • General Health & Medical Sciences (AREA)
  • Heart & Thoracic Surgery (AREA)
  • Processing Or Creating Images (AREA)
  • User Interface Of Digital Computer (AREA)

Abstract

The invention relates to a method, a device, computer equipment and a storage medium for moving a waistband following a player in virtual reality, wherein the method comprises the following steps: obtaining an interpolation value according to a forward vector of the current rotation of the head of the player and a horizontal plane normal vector, and obtaining a product of the interpolation value and the maximum distance of backward movement of the waistband to obtain a first distance of backward movement of the waistband; obtaining a unit vector of a projection vector of the current player head orientation on a horizontal plane, and multiplying the unit vector by a first distance to obtain a displacement vector; subtracting the displacement vector from the current position coordinate of the head of the player to obtain a second distance coordinate of the waistband; subtracting the current first position coordinate of the waistband from the second distance coordinate to obtain a distance difference, and obtaining the current speed of the waistband according to the displacement moving speed coefficient and the distance difference of the waistband; and acquiring a product result of the current speed and the previous frame time, and accumulating the displacement coordinate of the current frame and the product result to obtain the updated position of the waistband. The method can meet the experience effect of game setting in virtual reality.

Description

虚拟现实中腰带跟随玩家的移动方法、装置和计算机设备Belt-following player's movement method, device and computer equipment in virtual reality

技术领域technical field

本发明涉及虚拟现实的游戏技术领域,特别是涉及一种虚拟现实中腰带跟随玩家的移动方法、装置、计算机设备和存储介质。The present invention relates to the technical field of virtual reality games, in particular to a belt-following player movement method, device, computer equipment and storage medium in virtual reality.

背景技术Background technique

一般虚拟现实的游戏中只有玩家头部和手部的捕捉,这个时候要把腰带呈现出来,一般直接跟随着玩家头部移动旋转,但是这样效果并不是很好。因为玩家在使用腰带的时候,例如拿腰带工具,拿腰带上的枪之类的动作,都是低头的。低头时候玩家头部的中心位置会比身体前倾一段距离,所以低头的时候腰带的位置会前倾,不满足虚拟现实中游戏设置的效果,虚拟现实中腰带跟随玩家的移动方式不满足游戏设置需求。Generally, in virtual reality games, only the player's head and hands are captured. At this time, the belt should be displayed, and it usually follows the movement and rotation of the player's head directly, but the effect is not very good. Because when the player uses the belt, such as holding the belt tool, taking the gun on the belt, etc., they all bow their heads. When bowing the head, the center of the player's head will lean forward a certain distance from the body, so the position of the belt will lean forward when bowing the head, which does not meet the effect of the game settings in virtual reality, and the way the belt follows the player in virtual reality does not meet the game settings need.

发明内容Contents of the invention

本发明的目的在于克服现有技术的不足,提供了一种虚拟现实中腰带跟随玩家的移动方法、装置、计算机设备和存储介质,能够在玩家移动过程玩家低头看腰带时,腰带会在玩家头部后方一点的腰部附近而不是玩家头部的垂直下方,满足虚拟现实中游戏设置的效果,提高虚拟游戏的体验效果。The purpose of the present invention is to overcome the deficiencies of the prior art, and provide a method, device, computer equipment and storage medium for the belt to follow the player in virtual reality. When the player looks down at the belt during the player's movement, the belt will be on the player's head. Near the waist a little behind the head instead of vertically below the player's head, it satisfies the effect of game settings in virtual reality and improves the experience of virtual games.

为了解决上述中至少一个技术问题,本发明实施例提供了一种虚拟现实中腰带跟随玩家的移动方法,所述方法包括:In order to solve at least one of the above technical problems, an embodiment of the present invention provides a method for moving a belt following a player in virtual reality, the method comprising:

获取所述玩家的头部当前旋转的向前向量,根据所述当前向量与水平面的法向量获取到当前玩家低头的插值,获取所述腰带往后移的最大距离,将所述插值与所述最大距离进行乘积运算,得到所述腰带需要往后移的第一距离;Obtain the forward vector of the current rotation of the player's head, obtain the interpolation value of the current player's head down according to the current vector and the normal vector of the horizontal plane, obtain the maximum distance that the belt moves backward, and combine the interpolation value with the The maximum distance is multiplied to obtain the first distance that the belt needs to move back;

获取当前玩家头朝向在水平面上投影向量,将所述投影向量转化为单位向量,将所述单位向量乘以所述第一距离,得到所述第一距离的位移向量,获取所述玩家的头部的当前位置的坐标,将所述当前位置的坐标减去所述位移向量,得到所述腰带即将移动到的第二距离的坐标;Obtain the projection vector of the current player's head orientation on the horizontal plane, convert the projection vector into a unit vector, multiply the unit vector by the first distance to obtain the displacement vector of the first distance, and obtain the player's head the coordinates of the current position of the head, and subtract the displacement vector from the coordinates of the current position to obtain the coordinates of the second distance to which the belt is about to move;

获取所述腰带当前的第一位置坐标,将所述第二距离的坐标减去所述第一位置坐标得到距离差,获取腰带位移移动速度系数,根据所述腰带位移移动速度系数与所述距离差得到所述腰带的当前速度;Obtain the current first position coordinates of the belt, subtract the first position coordinates from the coordinates of the second distance to obtain a distance difference, obtain the belt displacement movement speed coefficient, and obtain the belt displacement movement speed coefficient according to the distance between the belt displacement movement speed coefficient and the distance difference to get the current speed of the belt;

获取上一帧的时间,将所述当前速度与所述上一帧时间进行相乘,得到第三距离,获取所述腰带当前帧的位移坐标,将所述当前帧的位移坐标与所述第三距离进行累加,得到所述当前的腰带的更新位置,所述腰带基于所述更新位置进行移动。Obtaining the time of the previous frame, multiplying the current speed by the time of the previous frame to obtain a third distance, obtaining the displacement coordinates of the current frame of the belt, and multiplying the displacement coordinates of the current frame by the first The three distances are accumulated to obtain the updated position of the current belt, and the belt moves based on the updated position.

在其中一个实施例中,根据所述当前向量与水平面的法向量获取到当前玩家低头的插值,包括:In one of the embodiments, the interpolation of the current player bowing his head is obtained according to the current vector and the normal vector of the horizontal plane, including:

将所述当前向量与水平面的法向量进行点积,根据所述点积得到夹角;Performing a dot product of the current vector and the normal vector of the horizontal plane, and obtaining an included angle according to the dot product;

将90度减去所述夹角的度数,得到差值,将所述差值再除以90度,得到所述当前玩家低头的插值。The degree of the included angle is subtracted from 90 degrees to obtain a difference, and the difference is divided by 90 degrees to obtain an interpolation value of the current player bowing his head.

在其中一个实施例中,所述方法还包括:In one embodiment, the method also includes:

当所述夹角的度数大于90度时,将所述夹角的度数设置为90度。When the degree of the included angle is greater than 90 degrees, the degree of the included angle is set to 90 degrees.

在其中一个实施例中,所述根据所述腰带位移移动速度系数与所述距离差得到所述腰带的当前速度,包括:In one of the embodiments, the obtaining the current speed of the belt according to the belt displacement movement speed coefficient and the distance difference includes:

计算所述距离差的平方值,将所述平方值与所述所述腰带位移移动速度系数进行相乘,得到当前帧腰带的速度,根据所述当前帧腰带的速度得到所述腰带的当前速度。Calculate the square value of the distance difference, multiply the square value by the belt displacement movement speed coefficient to obtain the speed of the belt in the current frame, and obtain the current speed of the belt according to the speed of the belt in the current frame .

在其中一个实施例中,所述根据所述当前帧腰带的速度得到所述腰带的当前速度,包括:In one of the embodiments, the obtaining the current speed of the belt according to the speed of the belt in the current frame includes:

获取所述腰带的最小速度;Get the minimum speed of the belt;

将所述最小速度与所述当前帧腰带的速度进行比较,将所述最小速度与所述当前帧腰带的速度中的最大速度作为所述腰带的当前速度。The minimum speed is compared with the speed of the belt in the current frame, and the maximum speed of the minimum speed and the speed of the belt in the current frame is taken as the current speed of the belt.

在其中一个实施例中,所述方法还包括:In one embodiment, the method also includes:

获取所述腰带的第一旋转和所述玩家的第二旋转,获取所述第一旋转和所述第二旋转的角度差;Obtain the first rotation of the belt and the second rotation of the player, and obtain the angle difference between the first rotation and the second rotation;

获取腰带位移移动旋转系数,将所述角度差与所述腰带位移移动旋转系数的乘积,得到所述腰带的旋转速度;Obtaining the rotation coefficient of the belt displacement movement, multiplying the angle difference by the rotation coefficient of the belt displacement movement to obtain the rotation speed of the belt;

通过上一帧的时间,将所述上一帧的时间乘以所述腰带的旋转速度,得到所述腰带的旋转值;Multiplying the time of the previous frame by the rotation speed of the belt to obtain the rotation value of the belt through the time of the previous frame;

获取所述腰带的当前旋转,将所述当前旋转加上所述腰带的旋转值,得到所述腰带的更新旋转,所述腰带根据所述更新旋转在移动中进行旋转。The current rotation of the belt is obtained, and the current rotation is added to the rotation value of the belt to obtain an updated rotation of the belt, and the belt rotates during movement according to the updated rotation.

在其中一个实施例中,所述将所述角度差与所述腰带位移移动旋转系数的乘积,得到所述腰带的旋转速度,包括:In one of the embodiments, the product of the angle difference and the belt displacement rotation coefficient to obtain the rotation speed of the belt includes:

将所述角度差与所述腰带位移移动旋转系数的乘积,得到乘积值;multiplying the product of the angle difference and the belt displacement rotation coefficient to obtain a product value;

获取所述腰带最小旋转速度;Obtain the minimum rotation speed of the belt;

获取所述乘积值与所述腰带最小旋转速度中的最大值,将所述最大值作为所述腰带的旋转速度。Obtain the maximum value of the product value and the minimum rotation speed of the belt, and use the maximum value as the rotation speed of the belt.

一种虚拟现实中腰带跟随玩家的移动装置,所述装置包括:A mobile device in which a belt follows a player in virtual reality, the device comprising:

第一获取模块,用于获取所述玩家的头部当前旋转的向前向量,根据所述当前向量与水平面的法向量获取到当前玩家低头的插值,获取所述腰带往后移的最大距离,将所述插值与所述最大距离进行乘积运算,得到所述腰带需要往后移的第一距离;The first obtaining module is used to obtain the forward vector of the current rotation of the player's head, obtain the interpolation of the current player's head bowing according to the current vector and the normal vector of the horizontal plane, and obtain the maximum distance for the belt to move backward, performing a product operation on the interpolation value and the maximum distance to obtain the first distance that the waistband needs to move backward;

第二获取模块,用于获取当前玩家头朝向在水平面上投影向量,将所述投影向量转化为单位向量,将所述单位向量乘以所述第一距离,得到所述第一距离的位移向量,获取所述玩家的头部的当前位置的坐标,将所述当前位置的坐标减去所述位移向量,得到所述腰带即将移动到的第二距离的坐标;The second acquisition module is used to acquire the projection vector of the current player's head orientation on the horizontal plane, convert the projection vector into a unit vector, multiply the unit vector by the first distance, and obtain the displacement vector of the first distance , obtaining the coordinates of the current position of the player's head, and subtracting the displacement vector from the coordinates of the current position to obtain the coordinates of the second distance to which the belt is about to move;

第三获取模块,用于获取所述腰带当前的第一位置坐标,将所述第二距离的坐标减去所述第一位置坐标得到距离差,获取腰带位移移动速度系数,根据所述腰带位移移动速度系数与所述距离差得到所述腰带的当前速度;The third acquiring module is used to acquire the current first position coordinates of the belt, subtract the first position coordinates from the coordinates of the second distance to obtain a distance difference, acquire the belt displacement movement speed coefficient, and obtain the belt displacement according to the belt displacement The current speed of the belt is obtained by moving the speed coefficient and the distance difference;

第四获取模块,用于获取上一帧的时间,将所述当前速度与所述上一帧时间进行相乘,得到第三距离,获取所述腰带当前帧的位移坐标,将所述当前帧的位移坐标与所述第三距离进行累加,得到所述当前的腰带的更新位置,所述腰带基于所述更新位置进行移动。The fourth obtaining module is used to obtain the time of the last frame, multiply the current speed by the time of the last frame to obtain a third distance, obtain the displacement coordinates of the current frame of the belt, and convert the current frame to The displacement coordinates of and the third distance are accumulated to obtain the updated position of the current belt, and the belt moves based on the updated position.

另外,本发明实施例还提供了一种计算机设备,其包括:存储器、处理器及存储在存储器上并可在处理器上运行的应用程序,处理器执行应用程序时实现上述任一实施例方法的步骤。In addition, an embodiment of the present invention also provides a computer device, which includes: a memory, a processor, and an application program stored on the memory and operable on the processor. When the processor executes the application program, the method in any of the above embodiments is implemented. A step of.

另外,本发明实施例还提供了一种计算机可读存储介质,其上存储有应用程序,应用程序被处理器执行时实现上述任一实施例方法的步骤。In addition, an embodiment of the present invention also provides a computer-readable storage medium, on which an application program is stored, and when the application program is executed by a processor, the steps of the method in any of the foregoing embodiments are implemented.

在本发明实施例中,通过实施上述方法,获取玩家的头部当前旋转的向前向量,根据当前向量与水平面的法向量获取到当前玩家低头的插值,获取腰带往后移的最大距离,将插值与最大距离进行乘积运算,得到腰带需要往后移的第一距离;获取当前玩家头朝向在水平面上投影向量,将投影向量转化为单位向量,将单位向量乘以第一距离,得到第一距离的位移向量,获取玩家的头部的当前位置的坐标,将当前位置的坐标减去位移向量,得到腰带即将移动到的第二距离的坐标;获取腰带当前的第一位置坐标,将第二距离的坐标减去第一位置坐标得到距离差,获取腰带位移移动速度系数,根据腰带位移移动速度系数与距离差得到腰带的当前速度;获取上一帧的时间,将当前速度与上一帧时间进行相乘,得到第三距离,获取腰带当前帧的位移坐标,将当前帧的位移坐标与第三距离进行累加,得到当前的腰带的更新位置,腰带基于更新位置进行移动。因此,能够在玩家移动过程玩家低头看腰带时,腰带会在玩家头部后方一点的腰部附近而不是玩家头部的垂直下方,满足虚拟现实中游戏设置的效果,提高虚拟游戏的体验效果。In the embodiment of the present invention, by implementing the above method, the forward vector of the current rotation of the player's head is obtained, and the interpolation of the current player's bowing is obtained according to the current vector and the normal vector of the horizontal plane, and the maximum distance for the belt to move backward is obtained. Interpolation is multiplied by the maximum distance to obtain the first distance that the belt needs to move backward; obtain the current player's head orientation projection vector on the horizontal plane, convert the projection vector into a unit vector, and multiply the unit vector by the first distance to obtain the first The displacement vector of the distance, obtain the coordinates of the current position of the player's head, subtract the displacement vector from the coordinates of the current position, and obtain the coordinates of the second distance that the belt is about to move to; obtain the coordinates of the current first position of the belt, and set the second Subtract the first position coordinate from the distance coordinate to obtain the distance difference, obtain the belt displacement movement speed coefficient, and obtain the current speed of the belt according to the belt displacement movement speed coefficient and the distance difference; obtain the time of the previous frame, and compare the current speed with the time of the previous frame Multiply to obtain the third distance, obtain the displacement coordinates of the current frame of the belt, and accumulate the displacement coordinates of the current frame and the third distance to obtain the updated position of the current belt, and the belt moves based on the updated position. Therefore, when the player looks down at the belt during the player's movement, the belt will be near the waist a little behind the player's head instead of vertically below the player's head, which satisfies the effect of game settings in virtual reality and improves the experience of virtual games.

附图说明Description of drawings

图1是本发明实施例中的一种虚拟现实中腰带跟随玩家的移动方法的流程示意图;FIG. 1 is a schematic flowchart of a method for moving a belt following a player in a virtual reality embodiment of the present invention;

图2是本发明实施例中的一种虚拟现实中腰带跟随玩家的移动装置的结构示意图;Fig. 2 is a schematic structural diagram of a belt-following player's mobile device in a virtual reality embodiment of the present invention;

图3是本发明实施例中的计算机设备的结构组成示意图。Fig. 3 is a schematic diagram of the structural composition of a computer device in an embodiment of the present invention.

具体实施方式Detailed ways

下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其它实施例,都属于本发明保护的范围。The following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only some, not all, embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by persons of ordinary skill in the art without creative efforts fall within the protection scope of the present invention.

本发明实施例提供了一种虚拟现实中腰带跟随玩家的移动方法,如图1所示,该一种虚拟现实中腰带跟随玩家的移动方法包括以下步骤:An embodiment of the present invention provides a method for moving a belt following a player in virtual reality. As shown in FIG. 1 , the method for moving a belt following a player in virtual reality includes the following steps:

S102,获取所述玩家的头部当前旋转的向前向量,根据所述当前向量与水平面的法向量获取到当前玩家低头的插值,获取所述腰带往后移的最大距离,将所述插值与所述最大距离进行乘积运算,得到所述腰带需要往后移的第一距离。S102. Obtain the forward vector of the current rotation of the player's head, obtain the interpolation value of the current player's head bowing according to the current vector and the normal vector of the horizontal plane, obtain the maximum distance that the belt moves backward, and combine the interpolation value with The maximum distance is multiplied to obtain the first distance that the belt needs to move backward.

在一实施例中,根据所述当前向量与水平面的法向量获取到当前玩家低头的插值,包括:将所述当前向量与水平面的法向量进行点积,根据所述点积得到夹角;将90度减去所述夹角的度数,得到差值,将所述差值再除以90度,得到所述当前玩家低头的插值。In an embodiment, obtaining the interpolation of the current player bowing his head according to the current vector and the normal vector of the horizontal plane includes: performing a dot product of the current vector and the normal vector of the horizontal plane, and obtaining an included angle according to the dot product; The degree of the included angle is subtracted from 90 degrees to obtain a difference, and the difference is divided by 90 degrees to obtain an interpolation value of the current player bowing his head.

优选地,所述方法还包括:当所述夹角的度数大于90度时,将所述夹角的度数设置为90度。Preferably, the method further includes: when the degree of the included angle is greater than 90 degrees, setting the degree of the included angle to 90 degrees.

首先说明的是,在本发明中,虚拟现实的游戏中已知玩家头部的旋转和位置。本发明的技术算法核心有两个,一种是延时缓慢移动旋转,一种是低头往后位移。本发明在游戏的虚幻引擎中设置腰带类ToolBelt。ToolBelt上具备以下的核心成员变量和成员函数:Firstly, in the present invention, the rotation and position of the player's head are known in the virtual reality game. There are two technical algorithm cores in the present invention, one is slow movement and rotation with time delay, and the other is backward displacement with the head bowed. The present invention sets the belt class ToolBelt in the unreal engine of the game. ToolBelt has the following core member variables and member functions:

float变量BeltMoveSpeed,腰带位移移动速度系数,因为腰带的位移速度与腰带和玩家当前的距离有关,这个距离乘上这个系数就是当前速度,可以根据实际需求效果进行调整。The float variable BeltMoveSpeed is the belt movement speed coefficient, because the belt displacement speed is related to the current distance between the belt and the player. This distance multiplied by this coefficient is the current speed, which can be adjusted according to the actual demand effect.

float变量BeltMoveMinSpeed,腰带最小速度,当距离无限接近玩家的时候,速度也会无限小,所以设置最小速度避免无限缓慢移动float variable BeltMoveMinSpeed, the minimum speed of the belt, when the distance is infinitely close to the player, the speed will be infinitely small, so set the minimum speed to avoid infinitely slow movement

float变量BeltDistance,腰带往后移的最大距离,玩家头朝向与水平面的夹角为0时为腰带位移为0,玩家头朝向与水平的夹角为90度时,腰带往后的位移达到最大为这个BeltDistance。float variable BeltDistance, the maximum distance that the belt moves backwards. When the angle between the player's head and the horizontal plane is 0, the belt displacement is 0. When the angle between the player's head and the horizontal is 90 degrees, the maximum backward displacement of the belt is This BeltDistance.

float变量BeltHeight,一个腰带高度的系数,与玩家当前高度相乘得出当前腰带的高度应该在哪。The float variable BeltHeight, a coefficient of belt height, is multiplied by the player's current height to get where the current belt height should be.

float变量BeltRotSpeed,与BeltMoveSpeed同理,区别是这个是旋转系数The float variable BeltRotSpeed is the same as BeltMoveSpeed, the difference is that this is the rotation coefficient

float变量BeltRotMinSpeed,腰带最小旋转速度float variable BeltRotMinSpeed, the minimum rotation speed of the belt

float变量RotChangeMinAngle,腰带最小需要旋转的角度,当玩家旋转值根腰带旋转值的角度差小于这个值,则不需要进行旋转float variable RotChangeMinAngle, the minimum rotation angle of the belt, when the angle difference between the rotation value of the player and the rotation value of the belt is less than this value, no rotation is required

函数UpdateTransform,在Tick函数(虚幻引擎自带的帧函数,每帧调用一次)中调用,不断更新腰带的位置旋转,里面处理所有主要的算法。The function UpdateTransform is called in the Tick function (the frame function that comes with Unreal Engine, which is called once per frame), and continuously updates the position and rotation of the belt, which processes all the main algorithms.

函数GetTargetLocationAndRotation,获取目的位置与旋转,因为移动算法运用的是延时的,当玩家移动到哪并非一瞬间过去,而是会有一个移动过去的过程,所以使用这个函数去获取到目的位置旋转,在用算法让腰带位移旋转过去目的点。The function GetTargetLocationAndRotation, obtains the target position and rotation, because the movement algorithm uses a delay, when the player moves, it does not pass in an instant, but there will be a process of moving past, so use this function to obtain the target position and rotation, Use the algorithm to let the belt displacement rotate past the target point.

具体地,首先获取到目的的位置和旋转,腰带需要移动到的位置和旋转到的旋转值。调用GetTargetLocationAndRotation函数,在GetTargetLocationAndRotation函数里,首先获取玩家头部当前的位置旋转,目的旋转直接返回当前玩家头部旋转即可,目的位移则需要进行一些处理。目的位移的具体处理为:获取到玩家头部当前旋转的向前向量,即玩家头的朝向,然后与水平面的法向量(0,0,-1)进行点积获取到夹角的cos值,然后用反三角函数计算出这个角度的度数。如果这个角度值大于90时就视为90。因为大于90度时玩家为抬头状态,此时玩家看不到自己的腰带,和头往前时一样的处理即可。进而,90度减去这个度数,然后再除以90度,即可获取到当前玩家低头的插值。当头低到最低时为1,头往前时为0。这个插值乘上BeltDistance得出需要往后移的距离。也即是,得到所述腰带需要往后移的第一距离。Specifically, first obtain the target position and rotation, the position to which the belt needs to move and the rotation value to which it is rotated. Call the GetTargetLocationAndRotation function. In the GetTargetLocationAndRotation function, first obtain the current position and rotation of the player's head. The target rotation can directly return the current player's head rotation. The target displacement needs to be processed. The specific processing of the target displacement is: obtain the forward vector of the current rotation of the player's head, that is, the orientation of the player's head, and then perform a dot product with the normal vector (0,0,-1) of the horizontal plane to obtain the cos value of the included angle. Then use inverse trigonometric functions to find the angle in degrees. If the angle value is greater than 90, it is regarded as 90. Because the player is head-up when the angle is greater than 90 degrees, and the player cannot see his belt at this time, it can be handled the same as when the head is forward. Furthermore, subtract this degree from 90 degrees, and then divide by 90 degrees to obtain the interpolation value of the current player bowing his head. 1 when the head is at its lowest point, and 0 when the head is forward. This interpolation is multiplied by the BeltDistance to get the distance that needs to be moved back. That is, the first distance that the belt needs to move backward is obtained.

S104,获取当前玩家头朝向在水平面上投影向量,将所述投影向量转化为单位向量,将所述单位向量乘以所述第一距离,得到所述第一距离的位移向量,获取所述玩家的头部的当前位置的坐标,将所述当前位置的坐标减去所述位移向量,得到所述腰带即将移动到的第二距离的坐标。S104. Obtain the projection vector of the current player's head orientation on the horizontal plane, convert the projection vector into a unit vector, multiply the unit vector by the first distance to obtain a displacement vector of the first distance, and obtain the player The coordinates of the current position of the head of the head are subtracted from the coordinates of the current position by the displacement vector to obtain the coordinates of the second distance to which the belt is about to move.

具体地,获取到当前玩家头朝向在水平面上投影向量,然后转化为单位向量,乘上上面得到的需要后移的距离,即为第一距离的位移向量,头当前的位置减去这个第一距离的位移向量就是GetTargetLocationAndRotation函数需要返回的目的位置。目的位置即为所述腰带即将移动到的第二距离的坐标。Specifically, get the projection vector of the current player's head orientation on the horizontal plane, then convert it into a unit vector, multiply it by the distance that needs to be moved back obtained above, that is, the displacement vector of the first distance, subtract the first from the current position of the head The displacement vector of the distance is the destination location that the GetTargetLocationAndRotation function needs to return. The target position is the coordinate of the second distance to which the belt is about to move.

S106,获取所述腰带当前的第一位置坐标,将所述第二距离的坐标减去所述第一位置坐标得到距离差,获取腰带位移移动速度系数,根据所述腰带位移移动速度系数与所述距离差得到所述腰带的当前速度。S106. Obtain the current first position coordinates of the waist belt, subtract the first position coordinates from the second distance coordinates to obtain a distance difference, obtain the belt displacement speed coefficient, and obtain the belt displacement speed coefficient according to the waist belt displacement speed coefficient and the The distance difference yields the current speed of the belt.

在一实施例中,所述根据所述腰带位移移动速度系数与所述距离差得到所述腰带的当前速度,包括:计算所述距离差的平方值,将所述平方值与所述所述腰带位移移动速度系数进行相乘,得到当前帧腰带的速度,根据所述当前帧腰带的速度得到所述腰带的当前速度。In an embodiment, the obtaining the current speed of the belt according to the belt displacement movement speed coefficient and the distance difference includes: calculating the square value of the distance difference, and combining the square value with the The belt displacement movement speed coefficients are multiplied to obtain the belt speed in the current frame, and the current speed of the belt is obtained according to the belt speed in the current frame.

在一实施例中,所述根据所述当前帧腰带的速度得到所述腰带的当前速度,包括:获取所述腰带的最小速度;将所述最小速度与所述当前帧腰带的速度进行比较,将所述最小速度与所述当前帧腰带的速度中的最大速度作为所述腰带的当前速度。In an embodiment, the obtaining the current speed of the belt according to the speed of the belt in the current frame includes: obtaining the minimum speed of the belt; comparing the minimum speed with the speed of the belt in the current frame, The maximum speed among the minimum speed and the speed of the belt in the current frame is taken as the current speed of the belt.

具体地,UpdateTransform函数里,首先获取腰带当前的第一位置坐标,将第二距离的坐标减去第一位置坐标得到距离差。进而,将得到的距离差进行平方,再乘上BeltMoveSpeed,得出当前速度。Specifically, in the UpdateTransform function, first obtain the current first position coordinates of the belt, and subtract the first position coordinates from the second distance coordinates to obtain the distance difference. Then, the obtained distance difference is squared, and then multiplied by BeltMoveSpeed to obtain the current speed.

进而,将当前速度与BeltMoveMinSpeed进行比较,数值比较大的那个值为这一帧真正的当前速度。Furthermore, compare the current speed with BeltMoveMinSpeed, and the one with the larger value is the true current speed of this frame.

S108,获取上一帧的时间,将所述当前速度与所述上一帧时间进行相乘,得到第三距离,获取所述腰带当前帧的位移坐标,将所述当前帧的位移坐标与所述第三距离进行累加,得到所述当前的腰带的更新位置,所述腰带基于所述更新位置进行移动。S108. Obtain the time of the previous frame, multiply the current speed by the time of the previous frame to obtain a third distance, obtain the displacement coordinates of the current frame of the belt, and multiply the displacement coordinates of the current frame with the The third distance is accumulated to obtain the current update position of the belt, and the belt moves based on the update position.

具体地,调用GetWorldDeltaSeconds函数获取上一帧的时间,当前速度乘上一帧的时间获得到第三距离,获取腰带当前帧的位移坐标,将当前帧的位移坐标与第三距离进行累加,得到当前的腰带的更新位置。其中,使用虚幻引擎自带的GetActorLocation函数获取到腰带当前帧的位移坐标。Specifically, call the GetWorldDeltaSeconds function to obtain the time of the previous frame, multiply the current speed by the time of one frame to obtain the third distance, obtain the displacement coordinates of the current frame of the belt, and accumulate the displacement coordinates of the current frame with the third distance to obtain the current The updated location of the belt. Among them, use the GetActorLocation function that comes with Unreal Engine to get the displacement coordinates of the current frame of the belt.

通过实施上述方法,获取玩家的头部当前旋转的向前向量,根据当前向量与水平面的法向量获取到当前玩家低头的插值,获取腰带往后移的最大距离,将插值与最大距离进行乘积运算,得到腰带需要往后移的第一距离;获取当前玩家头朝向在水平面上投影向量,将投影向量转化为单位向量,将单位向量乘以第一距离,得到第一距离的位移向量,获取玩家的头部的当前位置的坐标,将当前位置的坐标减去位移向量,得到腰带即将移动到的第二距离的坐标;获取腰带当前的第一位置坐标,将第二距离的坐标减去第一位置坐标得到距离差,获取腰带位移移动速度系数,根据腰带位移移动速度系数与距离差得到腰带的当前速度;获取上一帧的时间,将当前速度与上一帧时间进行相乘,得到第三距离,获取腰带当前帧的位移坐标,将当前帧的位移坐标与第三距离进行累加,得到当前的腰带的更新位置,腰带基于更新位置进行移动。因此,能够在玩家移动过程玩家低头看腰带时,腰带会在玩家头部后方一点的腰部附近而不是玩家头部的垂直下方,满足虚拟现实中游戏设置的效果,提高虚拟游戏的体验效果。By implementing the above method, obtain the forward vector of the current rotation of the player's head, obtain the interpolation value of the current player's lowered head according to the current vector and the normal vector of the horizontal plane, obtain the maximum distance for the belt to move backward, and perform a product operation on the interpolation value and the maximum distance , get the first distance that the belt needs to move back; get the projection vector of the current player's head orientation on the horizontal plane, convert the projection vector into a unit vector, multiply the unit vector by the first distance, get the displacement vector of the first distance, and get the player The coordinates of the current position of the head of the head, subtract the displacement vector from the coordinates of the current position, and obtain the coordinates of the second distance that the belt is about to move to; obtain the current first position coordinates of the belt, and subtract the first from the coordinates of the second distance Get the distance difference from the position coordinates, get the belt displacement speed coefficient, and get the current speed of the belt according to the belt displacement speed coefficient and the distance difference; get the time of the previous frame, multiply the current speed with the time of the previous frame, and get the third Distance, to obtain the displacement coordinates of the current frame of the belt, and accumulate the displacement coordinates of the current frame with the third distance to obtain the updated position of the current belt, and the belt moves based on the updated position. Therefore, when the player looks down at the belt during the player's movement, the belt will be near the waist a little behind the player's head instead of vertically below the player's head, which satisfies the effect of game settings in virtual reality and improves the experience of virtual games.

在一实施例中,S108之后,还包括:获取所述腰带的第一旋转和所述玩家的第二旋转,获取所述第一旋转和所述第二旋转的角度差;获取腰带位移移动旋转系数,将所述角度差与所述腰带位移移动旋转系数的乘积,得到所述腰带的旋转速度;通过上一帧的时间,将所述上一帧的时间乘以所述腰带的旋转速度,得到所述腰带的旋转值;获取所述腰带的当前旋转,将所述当前旋转加上所述腰带的旋转值,得到所述腰带的更新旋转,所述腰带根据所述更新旋转在移动中进行旋转。In an embodiment, after S108, it further includes: obtaining the first rotation of the belt and the second rotation of the player, obtaining the angle difference between the first rotation and the second rotation; obtaining the displacement, movement, and rotation of the belt coefficient, the product of the angle difference and the belt displacement rotation coefficient is obtained to obtain the rotation speed of the belt; through the time of the previous frame, the time of the previous frame is multiplied by the rotation speed of the belt, obtaining the rotation value of the belt; obtaining the current rotation of the belt, adding the current rotation to the rotation value of the belt to obtain an update rotation of the belt, and the belt is moving according to the update rotation rotate.

在一实施例中,所述将所述角度差与所述腰带位移移动旋转系数的乘积,得到所述腰带的旋转速度,包括:将所述角度差与所述腰带位移移动旋转系数的乘积,得到乘积值;获取所述腰带最小旋转速度;获取所述乘积值与所述腰带最小旋转速度中的最大值,将所述最大值作为所述腰带的旋转速度。In an embodiment, the step of obtaining the rotation speed of the waist belt by multiplying the product of the angle difference and the rotation coefficient of the belt displacement includes: multiplying the product of the angle difference and the rotation coefficient of the belt displacement, Obtain the product value; obtain the minimum rotation speed of the belt; obtain the maximum value of the product value and the minimum rotation speed of the belt, and use the maximum value as the rotation speed of the belt.

然后旋转跟位移一样,但是旋转不进行平方。具体地,获取到腰带旋转和玩家旋转的角度差。其中,使用GetAcatorRotation函数获取到玩家当前的旋转。因为腰带需要永远保持水平,所以这个角度差是投影到水平面上的角度差,然后角度差乘上BeltRotSpeed就得到了腰带的旋转速度,然后乘上GetWorldDeltaSeconds获取的时间,就得到旋转值,腰带当前的旋转加上这个旋转值就更新好了腰带旋转,每一帧都是如此反复的处理,腰带的位移旋转就完成了。Then rotation is the same as displacement, but the rotation is not squared. Specifically, the angle difference between the rotation of the belt and the rotation of the player is acquired. Among them, use the GetAcatorRotation function to get the current rotation of the player. Because the belt needs to be kept horizontal forever, this angle difference is the angle difference projected onto the horizontal plane, and then the angle difference is multiplied by BeltRotSpeed to get the rotation speed of the belt, and then multiplied by the time obtained by GetWorldDeltaSeconds to get the rotation value, the current belt rotation The belt rotation is updated by adding this rotation value to the rotation, and each frame is processed repeatedly in this way, and the displacement and rotation of the belt is completed.

其中,如果角度差乘上BeltRotSpeed得出的旋转速度比腰带最小旋转速度小,则后面使用这个最小速度而非计算得到的腰带的旋转速度。也即,则后续使用腰带最小旋转速度乘上GetWorldDeltaSeconds获取的时间,得到旋转值。Among them, if the rotation speed obtained by multiplying the angle difference by BeltRotSpeed is smaller than the minimum rotation speed of the belt, then use this minimum speed instead of the calculated rotation speed of the belt. That is, the minimum rotation speed of the belt is multiplied by the time obtained by GetWorldDeltaSeconds to obtain the rotation value.

因此,本发明实现了在玩家移动的过程中,腰带会延时缓慢的跟随玩家,随着靠近而减速,当玩家低头看腰带的时候,腰带是会在头部后方一点的腰部附近而不是头的垂直下方,体验效果更加好。Therefore, the present invention realizes that in the process of the player's movement, the belt will follow the player slowly with a delay, and decelerate as the player approaches. When the player looks down at the belt, the belt will be near the waist a little behind the head instead of the head. vertically below, the experience is even better.

在一实施例中,本发明还提供一种虚拟现实中腰带跟随玩家的移动装置。如图2所示,该装置包括:In one embodiment, the present invention also provides a mobile device in which the belt follows the player in virtual reality. As shown in Figure 2, the device includes:

第一获取模块22,用于获取所述玩家的头部当前旋转的向前向量,根据所述当前向量与水平面的法向量获取到当前玩家低头的插值,获取所述腰带往后移的最大距离,将所述插值与所述最大距离进行乘积运算,得到所述腰带需要往后移的第一距离;The first obtaining module 22 is used to obtain the forward vector of the current rotation of the player's head, obtain the interpolation value of bowing the current player's head according to the normal vector of the current vector and the horizontal plane, and obtain the maximum distance that the belt moves backward , performing a product operation on the interpolation and the maximum distance to obtain the first distance that the belt needs to move backward;

第二获取模块24,用于获取当前玩家头朝向在水平面上投影向量,将所述投影向量转化为单位向量,将所述单位向量乘以所述第一距离,得到所述第一距离的位移向量,获取所述玩家的头部的当前位置的坐标,将所述当前位置的坐标减去所述位移向量,得到所述腰带即将移动到的第二距离的坐标;The second obtaining module 24 is used to obtain the projection vector of the current player's head orientation on the horizontal plane, convert the projection vector into a unit vector, multiply the unit vector by the first distance, and obtain the displacement of the first distance vector, obtaining the coordinates of the current position of the player's head, and subtracting the displacement vector from the coordinates of the current position to obtain the coordinates of the second distance to which the belt is about to move;

第三获取模块26,用于获取所述腰带当前的第一位置坐标,将所述第二距离的坐标减去所述第一位置坐标得到距离差,获取腰带位移移动速度系数,根据所述腰带位移移动速度系数与所述距离差得到所述腰带的当前速度;The third acquiring module 26 is used to acquire the current first position coordinates of the belt, subtract the first position coordinates from the coordinates of the second distance to obtain a distance difference, and acquire the displacement movement speed coefficient of the belt, according to the waist belt The current speed of the belt is obtained by the displacement moving speed coefficient and the distance difference;

第四获取模块28,用于获取上一帧的时间,将所述当前速度与所述上一帧时间进行相乘,得到第三距离,获取所述腰带当前帧的位移坐标,将所述当前帧的位移坐标与所述第三距离进行累加,得到所述当前的腰带的更新位置,所述腰带基于所述更新位置进行移动。The fourth obtaining module 28 is used to obtain the time of the last frame, multiply the current speed by the time of the last frame to obtain a third distance, obtain the displacement coordinates of the current frame of the belt, and convert the current The frame displacement coordinates are accumulated with the third distance to obtain the updated position of the current belt, and the belt moves based on the updated position.

关于一种虚拟现实中腰带跟随玩家的移动装置的具体限定可以参见上文中对于一种虚拟现实中腰带跟随玩家的移动方法的限定,在此不再赘述。上述一种虚拟现实中腰带跟随玩家的移动装置中的各个模块可全部或部分通过软件、硬件及其组合来实现。上述各模块可以硬件形式内嵌于或独立于计算机设备中的处理器中,也可以以软件形式存储于计算机设备中的存储器中,以便于处理器调用执行以上各个模块对应的操作。For a specific definition of a belt-following player's movement device in virtual reality, please refer to the above-mentioned definition of a belt-following player's movement method in virtual reality, which will not be repeated here. All or part of the modules in the belt-following player's mobile device in virtual reality can be implemented in whole or in part by software, hardware and combinations thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, and can also be stored in the memory of the computer device in the form of software, so that the processor can invoke and execute the corresponding operations of the above-mentioned modules.

本发明实施例提供的一种计算机可读存储介质,所述计算机可读存储介质上存储有应用程序,该程序被处理器执行时实现上述实施例中任意一个实施例的一种虚拟现实中腰带跟随玩家的移动方法。其中,所述计算机可读存储介质包括但不限于任何类型的盘(包括软盘、硬盘、光盘、CD-ROM、和磁光盘)、ROM(Read-Only Memory,只读存储器)、RAM(RandomAcceSS Memory,随即存储器)、EPROM(EraSable Programmable Read-Only Memory,可擦写可编程只读存储器)、EEPROM(Electrically EraSable ProgrammableRead-Only Memory,电可擦可编程只读存储器)、闪存、磁性卡片或光线卡片。也就是,存储设备包括由设备(例如,计算机、手机)以能够读的形式存储或传输信息的任何介质,可以是只读存储器,磁盘或光盘等。A computer-readable storage medium provided by an embodiment of the present invention, an application program is stored on the computer-readable storage medium, and when the program is executed by a processor, a virtual reality belt in any one of the above-mentioned embodiments is implemented Follows the player's movement method. Wherein, the computer-readable storage medium includes but is not limited to any type of disk (including floppy disk, hard disk, optical disk, CD-ROM, and magneto-optical disk), ROM (Read-Only Memory, read-only memory), RAM (Random Access Memory , random memory), EPROM (EraSable Programmable Read-Only Memory, Erasable Programmable Read-Only Memory), EEPROM (Electrically EraSable Programmable Read-Only Memory, Electrically Erasable Programmable Read-Only Memory), flash memory, magnetic card or optical card . That is, a storage device includes any medium that stores or transmits information in a readable form by a device (eg, a computer, a mobile phone), and may be a read-only memory, a magnetic disk or an optical disk, and the like.

本发明实施例还提供了一种计算机应用程序,其运行在计算机上,该计算机应用程序用于执行上述中任意一个实施例的一种虚拟现实中腰带跟随玩家的移动方法。An embodiment of the present invention also provides a computer application program, which runs on a computer, and the computer application program is used to implement a method for moving a belt-following player in virtual reality according to any one of the above-mentioned embodiments.

此外,图3是本发明实施例中的计算机设备的结构组成示意图。In addition, FIG. 3 is a schematic diagram of the structural composition of the computer device in the embodiment of the present invention.

本发明实施例还提供了一种计算机设备,如图3所示。所述计算机设备包括处理器302、存储器303、输入单元304以及显示单元305等器件。本领域技术人员可以理解,图3示出的设备结构器件并不构成对所有设备的限定,可以包括比图示更多或更少的部件,或者组合某些部件。存储器303可用于存储应用程序301以及各功能模块,处理器302运行存储在存储器303的应用程序301,从而执行设备的各种功能应用以及数据处理。存储器可以是内存储器或外存储器,或者包括内存储器和外存储器两者。内存储器可以包括只读存储器(ROM)、可编程ROM(PROM)、电可编程ROM(EPROM)、电可擦写可编程ROM(EEPROM)、快闪存储器、或者随机存储器。外存储器可以包括硬盘、软盘、ZIP盘、U盘、磁带等。本发明所公开的存储器包括但不限于这些类型的存储器。本发明所公开的存储器只作为例子而非作为限定。The embodiment of the present invention also provides a computer device, as shown in FIG. 3 . The computer device includes a processor 302, a memory 303, an input unit 304, a display unit 305 and other components. Those skilled in the art can understand that the device structure shown in FIG. 3 does not limit all devices, and may include more or less components than those shown in the figure, or combine certain components. The memory 303 can be used to store the application program 301 and various functional modules, and the processor 302 runs the application program 301 stored in the memory 303 to execute various functional applications and data processing of the device. The memory may be internal memory or external memory, or include both internal memory and external memory. The internal memory may include read only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), flash memory, or random access memory. External storage may include hard disk, floppy disk, ZIP disk, U disk, magnetic tape, etc. The memory disclosed in the present invention includes but is not limited to these types of memory. The memory disclosed in the present invention is only an example rather than a limitation.

输入单元304用于接收信号的输入,以及接收用户输入的关键字。输入单元304可包括触控面板以及其它输入设备。触控面板可收集用户在其上或附近的触摸操作(比如用户使用手指、触笔等任何适合的物体或附件在触控面板上或在触控面板附近的操作),并根据预先设定的程序驱动相应的连接装置;其它输入设备可以包括但不限于物理键盘、功能键(比如播放控制按键、开关按键等)、轨迹球、鼠标、操作杆等中的一种或多种。显示单元305可用于显示用户输入的信息或提供给用户的信息以及终端设备的各种菜单。显示单元305可采用液晶显示器、有机发光二极管等形式。处理器302是终端设备的控制中心,利用各种接口和线路连接整个设备的各个部分,通过运行或执行存储在存储器303内的软件程序和/或模块,以及调用存储在存储器内的数据,执行各种功能和处理数据。The input unit 304 is used for receiving signal input, and receiving a keyword input by a user. The input unit 304 may include a touch panel and other input devices. The touch panel can collect the user's touch operation on or near it (such as the user's operation on the touch panel or near the touch panel by using any suitable object or accessory such as a finger or a stylus), and The program drives the corresponding connection device; other input devices may include, but are not limited to, one or more of physical keyboards, function keys (such as playback control buttons, switch buttons, etc.), trackballs, mice, and joysticks. The display unit 305 can be used to display information input by the user or provided to the user, as well as various menus of the terminal device. The display unit 305 may be in the form of a liquid crystal display, an organic light emitting diode, or the like. The processor 302 is the control center of the terminal equipment, and uses various interfaces and lines to connect various parts of the entire equipment, by running or executing software programs and/or modules stored in the memory 303, and calling data stored in the memory to execute Various functions and processing data.

作为一个实施例,所述计算机设备包括:一个或多个处理器302,存储器303,一个或多个应用程序301,其中所述一个或多个应用程序301被存储在存储器303中并被配置为由所述一个或多个处理器302执行,所述一个或多个应用程序301配置用于执行上述实施例中的任意一实施例中的一种虚拟现实中腰带跟随玩家的移动方法。As an embodiment, the computer device includes: one or more processors 302, a memory 303, and one or more application programs 301, wherein the one or more application programs 301 are stored in the memory 303 and are configured to Executed by the one or more processors 302, the one or more application programs 301 are configured to execute a method for moving a belt-following player in virtual reality in any one of the above-mentioned embodiments.

另外,以上对本发明实施例所提供的一种虚拟现实中腰带跟随玩家的移动方法、装置、计算机设备和存储介质进行了详细介绍,本文中应采用了具体个例对本发明的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本发明的方法及其核心思想;同时,对于本领域的一般技术人员,依据本发明的思想,在具体实施方式及应用范围上均会有改变之处,综上所述,本说明书内容不应理解为对本发明的限制。In addition, a method, device, computer equipment, and storage medium for belt-following player movement in virtual reality provided by the embodiments of the present invention have been described in detail above. In this paper, specific examples should be used to illustrate the principles and implementation methods of the present invention. To clarify, the descriptions of the above embodiments are only used to help understand the method of the present invention and its core idea; meanwhile, for those of ordinary skill in the art, according to the idea of the present invention, there will be changes in the specific implementation and application scope In summary, the content of this specification should not be construed as limiting the present invention.

Claims (10)

1.一种虚拟现实中腰带跟随玩家的移动方法,其特征在于,所述方法包括:1. A method for moving the belt following the player in virtual reality, characterized in that the method comprises: 获取所述玩家的头部当前旋转的向前向量,根据所述当前向量与水平面的法向量获取到当前玩家低头的插值,获取所述腰带往后移的最大距离,将所述插值与所述最大距离进行乘积运算,得到所述腰带需要往后移的第一距离;Obtain the forward vector of the current rotation of the player's head, obtain the interpolation value of the current player's head down according to the current vector and the normal vector of the horizontal plane, obtain the maximum distance that the belt moves backward, and combine the interpolation value with the The maximum distance is multiplied to obtain the first distance that the belt needs to move back; 获取当前玩家头朝向在水平面上投影向量,将所述投影向量转化为单位向量,将所述单位向量乘以所述第一距离,得到所述第一距离的位移向量,获取所述玩家的头部的当前位置的坐标,将所述当前位置的坐标减去所述位移向量,得到所述腰带即将移动到的第二距离的坐标;Obtain the projection vector of the current player's head orientation on the horizontal plane, convert the projection vector into a unit vector, multiply the unit vector by the first distance to obtain the displacement vector of the first distance, and obtain the player's head the coordinates of the current position of the head, and subtract the displacement vector from the coordinates of the current position to obtain the coordinates of the second distance to which the belt is about to move; 获取所述腰带当前的第一位置坐标,将所述第二距离的坐标减去所述第一位置坐标得到距离差,获取腰带位移移动速度系数,根据所述腰带位移移动速度系数与所述距离差得到所述腰带的当前速度,其中,腰带的位移速度与腰带和玩家当前的距离有关,所述当前速度可根据实际需求进行调整;Obtain the current first position coordinates of the belt, subtract the first position coordinates from the coordinates of the second distance to obtain a distance difference, obtain the belt displacement movement speed coefficient, and obtain the belt displacement movement speed coefficient according to the distance between the belt displacement movement speed coefficient and the distance difference to obtain the current speed of the belt, wherein the displacement speed of the belt is related to the current distance between the belt and the player, and the current speed can be adjusted according to actual needs; 获取上一帧的时间,将所述当前速度与所述上一帧时间进行相乘,得到第三距离,获取所述腰带当前帧的位移坐标,将所述当前帧的位移坐标与所述第三距离进行累加,得到所述当前的腰带的更新位置,所述腰带基于所述更新位置进行移动。Obtaining the time of the previous frame, multiplying the current speed by the time of the previous frame to obtain a third distance, obtaining the displacement coordinates of the current frame of the belt, and multiplying the displacement coordinates of the current frame by the first The three distances are accumulated to obtain the updated position of the current belt, and the belt moves based on the updated position. 2.根据权利要求1所述的方法,其特征在于,根据所述当前向量与水平面的法向量获取到当前玩家低头的插值,包括:2. The method according to claim 1, wherein the interpolation of the current player bowing his head is obtained according to the current vector and the normal vector of the horizontal plane, comprising: 将所述当前向量与水平面的法向量进行点积,根据所述点积得到夹角;Performing a dot product of the current vector and the normal vector of the horizontal plane, and obtaining an included angle according to the dot product; 将90度减去所述夹角的度数,得到差值,将所述差值再除以90度,得到所述当前玩家低头的插值。The degree of the included angle is subtracted from 90 degrees to obtain a difference, and the difference is divided by 90 degrees to obtain an interpolation value of the current player bowing his head. 3.根据权利要求2所述的方法,其特征在于,所述方法还包括:3. The method according to claim 2, wherein the method further comprises: 当所述夹角的度数大于90度时,将所述夹角的度数设置为90度。When the degree of the included angle is greater than 90 degrees, the degree of the included angle is set to 90 degrees. 4.根据权利要求1所述的方法,其特征在于,所述根据所述腰带位移移动速度系数与所述距离差得到所述腰带的当前速度,包括:4. The method according to claim 1, wherein the obtaining the current speed of the belt according to the belt displacement moving speed coefficient and the distance difference comprises: 计算所述距离差的平方值,将所述平方值与所述所述腰带位移移动速度系数进行相乘,得到当前帧腰带的速度,根据所述当前帧腰带的速度得到所述腰带的当前速度。Calculate the square value of the distance difference, multiply the square value by the belt displacement movement speed coefficient to obtain the speed of the belt in the current frame, and obtain the current speed of the belt according to the speed of the belt in the current frame . 5.根据权利要求4所述的方法,其特征在于,所述根据所述当前帧腰带的速度得到所述腰带的当前速度,包括:5. The method according to claim 4, wherein said obtaining the current speed of the belt according to the speed of the belt in the current frame comprises: 获取所述腰带的最小速度;Get the minimum speed of the belt; 将所述最小速度与所述当前帧腰带的速度进行比较,将所述最小速度与所述当前帧腰带的速度中的最大速度作为所述腰带的当前速度。The minimum speed is compared with the speed of the belt in the current frame, and the maximum speed of the minimum speed and the speed of the belt in the current frame is taken as the current speed of the belt. 6.根据权利要求1所述的方法,其特征在于,所述方法还包括:6. The method according to claim 1, further comprising: 获取所述腰带的第一旋转和所述玩家的第二旋转,获取所述第一旋转和所述第二旋转的角度差;Obtain the first rotation of the belt and the second rotation of the player, and obtain the angle difference between the first rotation and the second rotation; 获取腰带位移移动旋转系数,将所述角度差与所述腰带位移移动旋转系数的乘积,得到所述腰带的旋转速度;Obtaining the rotation coefficient of the belt displacement movement, multiplying the angle difference by the rotation coefficient of the belt displacement movement to obtain the rotation speed of the belt; 通过上一帧的时间,将所述上一帧的时间乘以所述腰带的旋转速度,得到所述腰带的旋转值;Multiplying the time of the previous frame by the rotation speed of the belt to obtain the rotation value of the belt through the time of the previous frame; 获取所述腰带的当前旋转,将所述当前旋转加上所述腰带的旋转值,得到所述腰带的更新旋转,所述腰带根据所述更新旋转在移动中进行旋转。The current rotation of the belt is obtained, and the current rotation is added to the rotation value of the belt to obtain an updated rotation of the belt, and the belt rotates during movement according to the updated rotation. 7.根据权利要求6所述的方法,其特征在于,所述将所述角度差与所述腰带位移移动旋转系数的乘积,得到所述腰带的旋转速度,包括:7. The method according to claim 6, wherein the step of obtaining the rotation speed of the belt by the product of the angle difference and the belt displacement rotation coefficient comprises: 将所述角度差与所述腰带位移移动旋转系数的乘积,得到乘积值;multiplying the product of the angle difference and the belt displacement rotation coefficient to obtain a product value; 获取所述腰带最小旋转速度;Obtain the minimum rotation speed of the belt; 获取所述乘积值与所述腰带最小旋转速度中的最大值,将所述最大值作为所述腰带的旋转速度。Obtain the maximum value of the product value and the minimum rotation speed of the belt, and use the maximum value as the rotation speed of the belt. 8.一种虚拟现实中腰带跟随玩家的移动装置,其特征在于,所述装置包括:8. A mobile device in which the belt follows the player in virtual reality, characterized in that the device comprises: 第一获取模块,用于获取所述玩家的头部当前旋转的向前向量,根据所述当前向量与水平面的法向量获取到当前玩家低头的插值,获取所述腰带往后移的最大距离,将所述插值与所述最大距离进行乘积运算,得到所述腰带需要往后移的第一距离;The first obtaining module is used to obtain the forward vector of the current rotation of the player's head, obtain the interpolation of the current player's head bowing according to the current vector and the normal vector of the horizontal plane, and obtain the maximum distance for the belt to move backward, performing a product operation on the interpolation value and the maximum distance to obtain the first distance that the waistband needs to move backward; 第二获取模块,用于获取当前玩家头朝向在水平面上投影向量,将所述投影向量转化为单位向量,将所述单位向量乘以所述第一距离,得到所述第一距离的位移向量,获取所述玩家的头部的当前位置的坐标,将所述当前位置的坐标减去所述位移向量,得到所述腰带即将移动到的第二距离的坐标;The second acquisition module is used to acquire the projection vector of the current player's head orientation on the horizontal plane, convert the projection vector into a unit vector, multiply the unit vector by the first distance, and obtain the displacement vector of the first distance , obtaining the coordinates of the current position of the player's head, and subtracting the displacement vector from the coordinates of the current position to obtain the coordinates of the second distance to which the belt is about to move; 第三获取模块,用于获取所述腰带当前的第一位置坐标,将所述第二距离的坐标减去所述第一位置坐标得到距离差,获取腰带位移移动速度系数,根据所述腰带位移移动速度系数与所述距离差得到所述腰带的当前速度;The third acquiring module is used to acquire the current first position coordinates of the belt, subtract the first position coordinates from the coordinates of the second distance to obtain a distance difference, acquire the belt displacement movement speed coefficient, and obtain the belt displacement according to the belt displacement The current speed of the belt is obtained by moving the speed coefficient and the distance difference; 第四获取模块,用于获取上一帧的时间,将所述当前速度与所述上一帧时间进行相乘,得到第三距离,获取所述腰带当前帧的位移坐标,将所述当前帧的位移坐标与所述第三距离进行累加,得到所述当前的腰带的更新位置,所述腰带基于所述更新位置进行移动。The fourth obtaining module is used to obtain the time of the last frame, multiply the current speed by the time of the last frame to obtain a third distance, obtain the displacement coordinates of the current frame of the belt, and convert the current frame to The displacement coordinates of and the third distance are accumulated to obtain the updated position of the current belt, and the belt moves based on the updated position. 9.一种计算机设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的应用程序,其特征在于,所述处理器执行所述应用程序时实现权利要求1至7中任一项所述方法的步骤。9. A computer device, comprising a memory, a processor, and an application program stored on the memory and operable on the processor, characterized in that, when the processor executes the application program, any one of claims 1 to 7 is realized. A step of said method. 10.一种计算机可读存储介质,其上存储有应用程序,其特征在于,所述应用程序被处理器执行时实现权利要求1至7中任一项所述方法的步骤。10. A computer-readable storage medium, on which an application program is stored, wherein, when the application program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
CN202211490580.8A 2021-01-21 2021-01-21 Method and device for moving waistband following player in virtual reality and computer equipment Pending CN115814398A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211490580.8A CN115814398A (en) 2021-01-21 2021-01-21 Method and device for moving waistband following player in virtual reality and computer equipment

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202211490580.8A CN115814398A (en) 2021-01-21 2021-01-21 Method and device for moving waistband following player in virtual reality and computer equipment
CN202110084886.2A CN112791381B (en) 2021-01-21 2021-01-21 Method and device for moving waistband following player in virtual reality and computer equipment

Related Parent Applications (1)

Application Number Title Priority Date Filing Date
CN202110084886.2A Division CN112791381B (en) 2021-01-21 2021-01-21 Method and device for moving waistband following player in virtual reality and computer equipment

Publications (1)

Publication Number Publication Date
CN115814398A true CN115814398A (en) 2023-03-21

Family

ID=75811133

Family Applications (2)

Application Number Title Priority Date Filing Date
CN202110084886.2A Active CN112791381B (en) 2021-01-21 2021-01-21 Method and device for moving waistband following player in virtual reality and computer equipment
CN202211490580.8A Pending CN115814398A (en) 2021-01-21 2021-01-21 Method and device for moving waistband following player in virtual reality and computer equipment

Family Applications Before (1)

Application Number Title Priority Date Filing Date
CN202110084886.2A Active CN112791381B (en) 2021-01-21 2021-01-21 Method and device for moving waistband following player in virtual reality and computer equipment

Country Status (1)

Country Link
CN (2) CN112791381B (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100292005A1 (en) * 2009-05-12 2010-11-18 Takeshi Miyamoto Game apparatus and computer-readable storage medium having a game program stored thereon
US20170116788A1 (en) * 2015-10-22 2017-04-27 Shandong University New pattern and method of virtual reality system based on mobile devices
CN108499107A (en) * 2018-04-16 2018-09-07 网易(杭州)网络有限公司 The control method of virtual role, device and storage medium in virtual reality

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP3765623B2 (en) * 1996-07-16 2006-04-12 株式会社ナムコ 3D simulator apparatus and information storage medium
WO2007064456A2 (en) * 2005-11-28 2007-06-07 The George Washington University Virtual reality simulator harness systems
KR20160147735A (en) * 2014-04-22 2016-12-23 소니 주식회사 Head region position detection device and head region position detection method, image processing device and image processing method, display device, and computer program
JP6783541B2 (en) * 2016-03-30 2020-11-11 株式会社バンダイナムコエンターテインメント Program and virtual reality experience provider
WO2017190293A1 (en) * 2016-05-04 2017-11-09 深圳动三帝虚拟现实互动科技有限公司 Virtual reality display method, device, and terminal
KR101809440B1 (en) * 2016-11-21 2017-12-15 김승정 Size Measuring Method using Augmented Reality of Smart Device
CN108230429A (en) * 2016-12-14 2018-06-29 上海交通大学 Real-time whole body posture reconstruction method based on head and two-hand positions and posture

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100292005A1 (en) * 2009-05-12 2010-11-18 Takeshi Miyamoto Game apparatus and computer-readable storage medium having a game program stored thereon
US20170116788A1 (en) * 2015-10-22 2017-04-27 Shandong University New pattern and method of virtual reality system based on mobile devices
CN108499107A (en) * 2018-04-16 2018-09-07 网易(杭州)网络有限公司 The control method of virtual role, device and storage medium in virtual reality

Also Published As

Publication number Publication date
CN112791381A (en) 2021-05-14
CN112791381B (en) 2022-12-27

Similar Documents

Publication Publication Date Title
US11886643B2 (en) Information processing apparatus and information processing method
US9001062B2 (en) Method for controlling computer that is held and operated by user using a re-touch determination area
WO2019153824A1 (en) Virtual object control method, device, computer apparatus, and storage medium
EP3398045A1 (en) Hand tracking for interaction feedback
CN111135556B (en) Virtual camera control method and device, electronic equipment and storage medium
WO2018018857A1 (en) Gesture control method and apparatus applied to vr device
US9262012B2 (en) Hover angle
US20150231491A1 (en) Advanced Game Mechanics On Hover-Sensitive Devices
CN106445118B (en) Virtual reality exchange method and device
WO2023173668A1 (en) Input recognition method in virtual scene, device and storage medium
WO2017116815A1 (en) Hand tracking for user interface operation at-a-distance
CN113168281B (en) Computer readable medium, electronic device and method
CN112791381B (en) Method and device for moving waistband following player in virtual reality and computer equipment
US20140115532A1 (en) Information-processing device, storage medium, information-processing method, and information-processing system
US20250086911A1 (en) Indicating a Position of an Occluded Physical Object
WO2015176376A1 (en) Method and device for automatically adjusting valid touch point, and computer storage medium
CN112565605A (en) Image display method and device and electronic equipment
CN107977071B (en) An operating method and device suitable for a space system
WO2023216613A1 (en) Control method, electronic device and computer storage medium
WO2023070933A1 (en) Gesture recognition method and apparatus, device, and medium
US10620760B2 (en) Touch motion tracking and reporting technique for slow touch movements
CN112433628A (en) Rigid body pose determination method and device of double-light-ball interactive pen and computer equipment
WO2025060808A1 (en) Gesture-based movement control method and related device
CN117944031A (en) Control method of flexible mechanical arm, equipment and medium
CN117908673A (en) Virtual object control method, device and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination