【VR】Leap Motion 官网文档 FingerModel (手指模型)

前言:

感谢关注和支持这个Leap Motion系列翻译的朋友们,非常抱歉因为工作原因非常久没有更新,今后这个翻译还会继续(除非官方直接给出中文文档)。本篇献给大家的是 《FingerModel (手指模型)》 ,该类主要用于手指模型的创建、更新、信息获取及控制等。


FingerModel¶  手指模型类

FingerModel is the base class for all the other finger scripts. If you are creating your own fingers and need a custom finger script, extend FingerModel and implement the Init() and Update() methods.

手指模型类(FingerModel)是其它手指脚本的基类。假设你要创建自己的手指对象和子定义的手指脚本,那么就须要继承该类并实现Init()方法和Updata()方法。


class FingerModel 手指模型

The base class for all fingers.

全部手指类的基类。


This class serves as the interface between the HandController object, the parent Hand object and the concrete finger objects.

Subclasses of FingerModel must implement InitFinger() and UpdateFinger(). The InitHand() function is typically called by the parent HandModel InitHand() method; likewise, the UpdateFinger() function is typically called by the parent HandModel UpdateHand() function.

该类是HandController对象,手型父对象以及固定手指对象的接口。

手指模型类(FingerModel)的子类必须实现InitFinger() 和 UpdateFinger() 方法。InitHand() 方法通常由其父类HandModel类的InitHand() 方法调用;相同的。UpdateFinger() 方法通常被其父类HandModel类的UpdateHand() 方法调用。


Public Functions  公共函数


Vector3 GetBoneCenter(int bone_type)   获取骨骼中心(參数:骨骼类型)


Returns the center of the given bone on the finger in relation to the controller.

返回给定手指骨骼相对于控制器的中心点位置。



Vector3 GetBoneDirection(int bone_type) 获取骨骼方向(參数:骨骼类型)


Returns the direction the given bone is facing on the finger in relation to the controller.

返回给定手指骨骼相对于控制器的面向的方向。



float GetBoneLength(int bone_type) 获取骨骼长度(參数:骨骼类型)


Returns the length of the finger bone.

返回手指骨骼的长度。



Quaternion GetBoneRotation(int bone_type) 获取骨骼角度(參数:骨骼类型)


Returns the rotation quaternion of the given bone in relation to the controller.

返回给定的骨骼相对于控制器的旋转角度,以四元数表示。



float GetBoneWidth(int bone_type) 获取骨骼宽度(參数:骨骼类型)


Returns the width of the finger bone.

返回手指骨骼的宽度。



HandController GetController() 获取控制器


The parent HandController instance.

父对象 手部控制器的实例。



float GetFingerJointSpreadMecanim()  获取手指关节伸张机制


Returns Mecanim spread angle, which only applies to joint_type = 0 NOTE: Positive spread is towards thumb for index and middle, but is in the opposite direction for the ring and pinky.

For the thumb negative spread rotates the thumb in to the palm.

返回伸张角度。仅适用于关节类型(joint_type)为0的情形。

注意:正的伸张朝向大拇指、食指和中指。反之则朝向无名指和小拇指。


float GetFingerJointStretchMecanim(int joint_type) 获取手指关节舒展机制(參数:关节类型)


Returns Mecanim stretch angle in the range (-180, +180] NOTE: Positive stretch opens the hand.

For the thumb this moves it away from the palm.

返回舒展的角度介于 (-180, +180]。注意:正值表示张开手掌,对于大拇指而言,指的是离开手掌的角度。


Vector3 GetJointPosition(int joint) 获取关节位置(參数:关节)


Returns the location of the given joint on the finger in relation to the controller.

返回给定手指关节相对于控制器的位置。



Finger GetLeapFinger() 获取Leap手指


The Leap Finger object.

获取Leap手指对象。



Hand GetLeapHand() 获取Leap手型


The Leap Hand object.

获取Leap手型对象。



Vector3 GetOffset() 获取偏移量


Returns any additional movement the finger needs because of non-relative palm movement.

返回因为非相对的手掌运动导致的手指的额外移动量。



Ray GetRay() 获取射线


Returns a ray from the tip of the finger in the direction it is pointing.

返回从手指指尖及所指向的方向产生的射线。



Vector3 GetTipPosition() 获取指尖位置


Returns the location of the tip of the finger in relation to the controller.

返回手指指尖相对于控制器的位置。



void InitFinger()  初始化手指


Implement this function to initialize this finger after it is created.

Typically, this function is called by the parent HandModel object.

实现该函数。用于创建手指后进行初始化。

一般来说。该方法由HandModel父对象调用。


void MirrorZAxis(bool mirror = true) 按Z轴镜像


Sets the mirror z-axis flag for this Finger Model.

给手指模型设置Z轴标识。


Mirroring the z axis reverses the hand so that they face the opposite direction as if in a mirror.

沿着Z轴对手型进行镜像。


Parameters 參数

  • mirror - Set true, the default value to mirror; false for normal rendering.


    镜像 - 假设为真(默认值)。产生镜像;否则正常渲染。


void SetController(HandController controller)  设置控制器(參数:手部控制器)


Assigns the HandController parent for this FingerModel object.

给当前手指模型对象加入手部控制器父对象。



void SetLeapHand(Hand hand) 设置Leap手型(參数:手型)


Sets the Leap Hand and Leap Finger for this finger.

Note that Leap Hand and Finger objects are recreated every frame. The parent HandModel object calls this function to set or update the underlying finger. The tracking data in the Leap objects are used to update the FingerModel.

给当前手指设置Leap 手型和Leap 手指。

注意:Leap手型和手指对象会逐帧重建。其父对象手部控制器调用该方法设置或更行其手指。Leap对象中的追踪数据被用于更新手指模型。



void SetOffset(Vector3 offset) 设置偏移量(參数:偏移量)


Sets an offset vector to displace the finger from its normally calculated position relative to the HandController.

Typically, this offset is used to give the virtual hands a larger range of motion then they would have based on their scaled size in the Unity scene.

通过设置偏移量。重置手指相对于手部控制器的正常计算位置。

通常,该偏移量用于提供虚拟手型更大的移动范围。从而适用于Unity场景中的缩放。


abstract void UpdateFinger()  更新手指


Implement this function to update this finger once per game loop.

Typically, this function is called by the parent HandModel object’s UpdateHand() function, which is called in the Unity Update() phase for graphics hand models and in the FixedUpdate() phase for physics hand models.

实现该函数将在每一次游戏循环中得到更新。

一般而言,给方法由其父对象手部模型的UpdateHand() 方法调用。在Unity中,图形手部模型由Update() 阶段调用,而物理手部模型由FixedUpdate() 阶段调用。



Public Members  公共成员

Transform[] bones   骨骼

Bones positioned and rotated by FingerModel.

由手指模型类控制位置和旋转的骨骼变换。


Transform[] joints  关节

Joints positioned and rotated by FingerModel.

由手指模型类控制位置和旋转的关节变换。


const int NUM_BONES  骨骼数量

The number of bones in a finger.

手指骨骼数量。


const int NUM_JOINTS  关节数量

The number of joints in a finger.

手指关节数量。



————————————————————————————————

很多其它參考:

【VR】Leap Motion 官网文档 脚本參考(文件夹)


(版权声明:本篇为Leap Motion 官网文档译文。版权归Leap Motion 官网全部,图文内容仅供学习使用。)


原文地址:https://www.cnblogs.com/blfbuaa/p/6718364.html