Hololens学习

本文介绍了Hololens的交互方式,包括使用Air-tap进行确认操作,Bloom用于取消或返回主界面。详细讲解了凝视(Gaze)功能的实现,通过获取主摄像机的位置和方向来实现交互。同时,提到了语音输入(Voice input)的实现,给出在飞机模型上应用的示例,并探讨了世界锚(World Anchor)和场景保持(Persistence)功能,以确保混合现实体验的稳定性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Air-tap类似于鼠标点击,一般用于确认功能

Bloom则一般用来取消或回到主界面


1.1凝视功能实现:(Gaze)

UnityEngine.Camera.main.transform.position

获取主摄像机的位置

UnityEngine.Camera.main.transform.forward

获取主摄像机的方向

void Update ()
    {
        RaycastHit hitInfo;
        if (Physics.Raycast(UnityEngine.Camera.main.transform.position,
            UnityEngine.Camera.main.transform.forward,
            out hitInfo, 20f,Physics.DefaultRaycastLayers))
        {
            Transform tran = hitInfo.transform;
            //控制物体旋转
            tran.Rotate(new Vector3(0, 1, 0));
        }
	}

1.2手势(Gesture)

1.创建Gesture Recognizer
GestureRecognizer recognizer=new GestureRecognizer();
2.指定需要捕捉的手势类型
recognizer.SetRecognizableGestures(GestureSetting.Tap);
3.捕捉到手势后的处理
recoginzer.TappedEvent += TapEventHandler;
4.开始捕捉手势
recoginzer.StartCapturingGesture();
5.结束手势捕捉
recoginzer.StopCapturingGesture();

Demo:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

using UnityEngine.VR.WSA.Input;
public class Gesture : MonoBehaviour {
    //定义一个手势识别器
    GestureRecognizer recognizer;  
	// Use this for initialization
	void Start ()
    {
        recognizer = new GestureRecognizer();  //初始化识别器
        //设置识别器类型,这里识别单击和双击
        recognizer.SetRecognizableGestures(GestureSettings.Tap | GestureSettings.DoubleTap);
        //注册手势识别事件
        recognizer.TappedEvent += TapEventHandler;
        //开启手势捕捉功能
        recognizer.StartCapturingGestures();
	}
    //手势识别事件
    //InteractionSourceKind 为事件的来源,是一个枚举值,有以下四个值
    //Other 其他的
    //Hand  手
    //Voice 语音
    //Controller 控制器
    //tapCount表示点击次数,如果tapCount=1代表单击,tapCount=2代表双击
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值