纳金网

标题: LeapMontion触发器 [打印本页]

作者: 烟雨    时间: 2016-3-7 22:25
标题: LeapMontion触发器

最近开始研究LeapMontion,发现有很多人写了很多的文章,但是触发器的都是一笔带过,对于刚开始玩的得找半天,所有和大家分享一下,当运行的时候场景中出现的手的模型是有collider的,所以就很简单了,在场景中添加HandController,建一个cube,一定要将cube上的collider的istriggle选中,因为手的模型上的collider的istriggle是没有选中的。给cube添加脚本代码如下:
  1. using UnityEngine;
  2. using System.Collections;

  3. public class CubeInteraction : MonoBehaviour {

  4.     public Color c;
  5.     public static Color selectedColor;
  6.     public bool selectable = false;
  7.     void OnTriggerEnter(Collider c) {
  8.         if (c.gameObject.transform.parent.name.Equals("index")) {
  9.             if (this.selectable) {
  10.                 CubeInteraction.selectedColor = this.c;
  11.                 this.transform.Rotate(Vector3.up, 33);
  12.                 return;
  13.             }
  14.             transform.gameObject.GetComponent<Renderer>().material.color = CubeInteraction.selectedColor;
  15.         }
  16.     }
  17. }
复制代码
还有一个[color=rgb(85, 85, 85) !important]问题Unity 和Leap Motion 都是使用的米制系统,但是有些区别:Unity 的是以米为单位,Leap Motion用的是毫米,不是什么大问题,但是当你测量坐标的时候需要知道。

另一个关键属性是Hand Movement Scale 向量,缩放值越大,设备覆盖的物理世界范围越大,你需要查看文档来找到一个合适的数值来适应你当前的应用。Hand Movement Scale向量是用来在不改变模型大小的前提下改变双手移动的范围。

这个文章就是给那些像我一样开始研究vr的朋友的,希望大家能互相交流,提升技术。


作者: Jasonnjw    时间: 2016-3-18 21:57
有用!3Q3Q




欢迎光临 纳金网 (http://go.narkii.com/club/) Powered by Discuz! X2.5