zoukankan      html  css  js  c++  java
  • Unity开发Leapmotion

    新建一个场景,删掉里面的Main Camera

    从Prefabs里拖入LMHeadMountedRig

    然后给LeapHandController上添加四个手,如图所示:



    手从Prefabs文件夹中选择。
       

     



    点击运行,就可以发现手已经出现了

    选中CenterEyeAnchor,将override eye position勾掉

    如果不勾掉的话就会出现重影的效果


    然后运行之后就可以了



     如果要使用api接口,要引入Leap.Unity命名空间。官方文档上讲,在unity使用的时候,要通过LeapProvider来访问,使用LeapController的话要进行手动转换空间坐标
    1. using UnityEngine;
    2. using System.Collections;
    3. using Leap.Unity;
    4. using Leap;
    5. public class Test : MonoBehaviour {
    6. LeapProvider provider;
    7. // Use this for initialization
    8. void Start () {
    9. provider = FindObjectOfType<LeapProvider>() as LeapProvider;
    10. }
    11. // Update is called once per frame
    12. void Update () {
    13. Frame frame = provider.CurrentFrame;
    14. foreach (Hand hand in frame.Hands)
    15. {
    16. if (hand.IsLeft)
    17. {
    18. transform.position = hand.PalmPosition.ToVector3() +
    19. hand.PalmNormal.ToVector3() *
    20. (transform.localScale.y * .5f + .02f);
    21. transform.rotation = hand.Basis.Rotation();
    22. }
    23. }
    24. }
    25. }

    要使用hand和Finger的话,必须是来自于Frame,所以首先通过provider初始化当前这一帧。然后把这个脚本绑定到一个GameObject上,启动播放,可以发现GameObject随着左手的移动而移动。

    吐槽一下Leapmotion,官网上连个教程都没有,文档太少了。只有这么个简单的示例,哎!




  • 相关阅读:
    mac 使用brew 安装php-redis
    thinkphp6 使用redis 实现消息队列
    Redis 桌面管理器:Another Redis Desktop Manager
    linux 查看并关闭shell脚本执行
    MySQL教程之concat以及group_concat的用法
    PHP redis 使用
    thinkphp6 command(自定义指令)
    git 使用
    linux shell中 "2>&1"含义
    linux crontab 定时任务
  • 原文地址:https://www.cnblogs.com/zhuzhenfeng/p/5404580.html
Copyright © 2011-2022 走看看