日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

LeapMotion使用入门

發(fā)布時(shí)間:2025/3/18 编程问答 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 LeapMotion使用入门 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

轉(zhuǎn)?https://blog.csdn.net/moonlightpeng/article/details/80174509

先把資料轉(zhuǎn)下來,明天考完試好好研究

1,Leap Motion 之 準(zhǔn)備工作。

a,?官方文檔鏈接, 手勢對應(yīng)類的結(jié)構(gòu)數(shù)據(jù)。

https://leapmotion.github.io/UnityModules/?

這兒對leap手勢的所有官方資料,非常不錯(cuò)。

https://leapmotion.github.io/UnityModules

b,?Interaction-Engine.

c,?Getting Started (Interaction Engine)

?

2,每次在unity中使用時(shí)先一定要把leap motion control panel打開。

?

2 獲得手的相關(guān)信息

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

using Leap;
using Leap.Unity;

public class LeapGestures : MonoBehaviour {

private LeapProvider mProvider;
private Frame mFrame;
private Hand mHand;

[Tooltip ("Velocity (m/s) of Palm ")]
public float smallestVelocity = 0.4f;//手掌移動(dòng)的最小速度
[Tooltip ("Velocity (m/s) of Single Direction ")]
public float deltaVelocity = 0.8f;//單方向上手掌移動(dòng)的速度
[Tooltip ("Distance(m) of Fingertip to Palm")]
public float deltaCloseFinger = 0.5f;//指尖到手掌中心的距離閾值


// Use this for initialization
void Start () {
mProvider = FindObjectOfType<LeapProvider>() as LeapProvider;

}

// Update is called once per frame
void Update () {
mFrame = mProvider.CurrentFrame;//獲取當(dāng)前幀
//獲得手的個(gè)數(shù)
//print ("hand num are " + mFrame.Hands.Count);

if (mFrame.Hands.Count > 0) {

foreach (var item in mFrame.Hands) {
int numFinger = item.Fingers.Count;
print ("item is " + numFinger);


}
}

}
}

?
mFrame = mProvider.CurrentFrame;//獲取當(dāng)前幀
//獲得手的個(gè)數(shù)
//print ("hand num are " + mFrame.Hands.Count);

if (mFrame.Hands.Count > 0) {

foreach (var item in mFrame.Hands) {
int numFinger = item.Fingers.Count;
//print ("item is " + numFinger);

//print("hand are " + isOpenFullHand (item));

if (item.IsLeft) {

//print ("isOpenFullHands is " + isOpenFullHands(item));
print ("isOpenFullHand is " + isOpenFullHand(item));
}

}
}
?

?

?

//判斷有多少個(gè)手指是伸開的,以及伸開的手指是哪個(gè)
public int extendFingerNum(Hand hand)
{
int extendedFingers = 0;
//一個(gè)手指的一次遍歷
for (int f = 0; f < hand.Fingers.Count; f++)
{
Finger digit = hand.Fingers[f];
if (digit.IsExtended) {
print ("Fingers is " + digit);
extendedFingers++;
}
}
return extendedFingers;
}
?

3,其它函數(shù)

hand.GrabStrength

?

通過握拳晃動(dòng)時(shí),它的Strength值大多數(shù)情況下在0.8-0.9范圍內(nèi)。通過該事件響應(yīng)操作便會(huì)不精確。通常情況下,我們只需要兩種狀態(tài):?

?

握拳事件Strength值為:1;非握拳狀態(tài)的值為:0。?

?

GrabStrength float ?的姿勢判斷,?全張開狀態(tài)為0,握拳時(shí)為1,范圍是[0,1]
GrabAngle float
所有?指的彎曲程度。通過觀察四個(gè)?指的?向和?的?向
之間的夾?來計(jì)算這個(gè)?。當(dāng)計(jì)算?度時(shí),不考慮拇指。這
個(gè)?度是?個(gè)開著的?的0弧度,當(dāng)這個(gè)姿勢是?個(gè)緊的拳
頭時(shí),它就會(huì)到達(dá)pi弧度。
PinchStrength float “捏”的?度,?掌攤開時(shí)為0,最?為1;針對拇指與同?只
?的任意其他?指的組合
PinchDistance float 拇指和?指的距離,?來判斷“捏”這個(gè)操作。
Rotation Vector3 返回?掌旋轉(zhuǎn)的四元數(shù)
IsLeft bool 判斷是否是左?
TimeVisible float 返回?在controller中可?的持續(xù)時(shí)間
Fingers List<Finger> ?指列表,從拇指到?名指排列
PalmNormal Vector3 ?掌法向量,如果你的?是平的,這個(gè)?量會(huì)向下,或者是你?掌的前表?。你可以??掌法向量來計(jì)算?平?上的?掌的滾動(dòng)?度。
PalmPosition Vector3 ?掌中?在controller坐標(biāo)系中的位置(mm級)
PalmVelocity Vector3 ?掌位置的速度,mm/s
PalmWidth float ?掌在平的位置時(shí),?掌的估計(jì)寬度。
WristPosition 返回?腕的位置
?

4?Unity3D使用左手坐標(biāo)系統(tǒng),而Leap Motion API使用右手坐標(biāo)系統(tǒng)。(基本上,在相反的方向。Z軸點(diǎn))統(tǒng)一使用米的默認(rèn)單位,而Leap Motion API使用毫米。插件腳本內(nèi)部轉(zhuǎn)換跟蹤數(shù)據(jù)使用左手坐標(biāo)系和尺度距離值米。

5, this.cube.transform.rotation = Quaternion.EulerRotation(h.Direction.Pitch, h.Direction.Yaw, h.Direction.Roll);?

6,?Unity集成Leap Motion

7,?Leap Motion這三個(gè)實(shí)驗(yàn),告訴你手勢還能實(shí)現(xiàn)這些操作

對應(yīng)的英文官方文檔?(Summoning and Superpowers: Designing VR Interactions at a Distance)

8,LEAPMotion VR 各種手勢的判斷。

9,官網(wǎng)的例子https://gallery.leapmotion.com/

10, unity 下載leap的官網(wǎng)。
---------------------
作者:moonlight天人合一
來源:CSDN
原文:https://blog.csdn.net/moonlightpeng/article/details/80174509
版權(quán)聲明:本文為博主原創(chuàng)文章,轉(zhuǎn)載請附上博文鏈接!

轉(zhuǎn)載于:https://www.cnblogs.com/HIT-ryp/p/11098564.html

總結(jié)

以上是生活随笔為你收集整理的LeapMotion使用入门的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。