Ultraleap 3Di示例Interactable Objects组件分析

该示例代码位置如下:
在这里插入图片描述
分析如下:
在这里插入图片描述
Hover Enabled:悬停功能,手放在这个模型上,会触发我们手放在这个模型上的悬停功能。此时当手靠近模型的时候,手的模型的颜色会发生改变,反之,则不会改变。
Contact Enabled:触摸功能,与场景物体产生碰撞的功能。
Grasping Enabled:抓取功能,手是否具有抓取功能,是否会抓取起物体。
在这里插入图片描述
Hover Activation Radius:触发悬停半径,超过这个范围将不会触发悬停
Touch Activation Radius:抓取半径,超过这个范围将不会触发抓取
Multi Grasp Holding Mode:多个人同时抓取,

  • Preserve Pose Per Controller:如果要实现Multi Grasp Holding Mode,我们必须要这个物体允许可以被多个人同时抓取,即被多个手同时抓取,就要求物体开启属性才可以,找到可以交互的物体,挂载组件Interaction Behavior(Script),在下拉栏中选中Allow Multi Grasp;同时,该手还需要有Interaction Manager 这个组件。此时,物体就可以与手发生HoverContactGrasping
    在这里插入图片描述
    在这里插入图片描述
  • Reinitialize On Any Release:进行切换,自行体验二者的不同。

Interaction Objects
物体设置:在这里插入图片描述
Ignore Hover Mode:忽略Hover
Ignore Primary Hover:忽略主悬停
Ignore Contact:忽略碰撞
Ignore Grapsing:忽略抓取
Move Objext When Grasp:抓取的物体是否跟着一起动
在这里插入图片描述
Use Hover 悬停
Use Primary Hover 主悬停
悬停可以有很多,主悬停只有一个。当手在两个物体上悬停,优先选择主悬停。

挂载在物体上的脚本SimpleInteractionGlow.cs

/******************************************************************************
 * Copyright (C) Ultraleap, Inc. 2011-2024.                                   *
 *                                                                            *
 * Use subject to the terms of the Apache License 2.0 available at            *
 * http://www.apache.org/licenses/LICENSE-2.0, or another agreement           *
 * between Ultraleap and you, your company or other organization.             *
 ******************************************************************************/

using Leap.Unity;
using Leap.Unity.Interaction;
using UnityEngine;

namespace Leap.Unity.InteractionEngine.Examples
{
    /// <summary>
    /// This simple script changes the color of an InteractionBehaviour as
    /// a function of its distance to the palm of the closest hand that is
    /// hovering nearby.
    /// </summary>
    [AddComponentMenu("")]
    [RequireComponent(typeof(InteractionBehaviour))]
    public class SimpleInteractionGlow : MonoBehaviour
    {
        [Tooltip("If enabled, the object will lerp to its hoverColor when a hand is nearby.")]
        public bool useHover = true;

        [Tooltip("If enabled, the object will use its primaryHoverColor when the primary hover of an InteractionHand.")]
        public bool usePrimaryHover = false;

        [Header("InteractionBehaviour Colors")]
        public Color defaultColor = Color.Lerp(Color.black, Color.white, 0.1F);

        public Color suspendedColor = Color.red;
        public Color hoverColor = Color.Lerp(Color.black, Color.white, 0.7F);
        public Color primaryHoverColor = Color.Lerp(Color.black, Color.white, 0.8F);

        [Header("InteractionButton Colors")]
        [Tooltip("This color only applies if the object is an InteractionButton or InteractionSlider.")]
        public Color pressedColor = Color.white;

        private Material[] _materials;

        private InteractionBehaviour _intObj;

        [SerializeField]
        private Rend[] rends;

        [System.Serializable]
        public class Rend
        {
            public int materialID = 0;
            public Renderer renderer;
        }

        void Start()
        {
            // 1、获取自身的InteractionBehaviour组件
            _intObj = GetComponent<InteractionBehaviour>();

            if (rends.Length > 0)
            {
                _materials = new Material[rends.Length];

                for (int i = 0; i < rends.Length; i++)
                {
                    _materials[i] = rends[i].renderer.materials[rends[i].materialID];
                }
            }
        }

        void Update()
        {
            if (_materials != null)
            {

                // The target color for the Interaction object will be determined by various simple state checks.
                Color targetColor = defaultColor;

                // "Primary hover" is a special kind of hover state that an InteractionBehaviour can
                // only have if an InteractionHand's thumb, index, or middle finger is closer to it
                // than any other interaction object.
                // 2、判断isPrimaryHovered是否为True,如果是,则表示我们的手放在了物体上,并且触发悬停。usePrimaryHover选项限制,需要勾选才触发
                if (_intObj.isPrimaryHovered && usePrimaryHover)
                {
                    targetColor = primaryHoverColor;// 2.1、变为设置好的颜色
                }
                else
                {
                    // Of course, any number of objects can be hovered by any number of InteractionHands.
                    // InteractionBehaviour provides an API for accessing various interaction-related
                    // state information such as the closest hand that is hovering nearby, if the object
                    // is hovered at all.
                    // 3、判断isHovered 是否为True
                    if (_intObj.isHovered && useHover)
                    {
                        float glow = _intObj.closestHoveringControllerDistance.Map(0F, 0.2F, 1F, 0.0F);
                        targetColor = Color.Lerp(defaultColor, hoverColor, glow);
                    }
                }
				 // 3、判断isSuspended是否暂停,如果是则改变颜色
                if (_intObj.isSuspended)
                {
                    // If the object is held by only one hand and that holding hand stops tracking, the
                    // object is "suspended." InteractionBehaviour provides suspension callbacks if you'd
                    // like the object to, for example, disappear, when the object is suspended.
                    // Alternatively you can check "isSuspended" at any time.
                    targetColor = suspendedColor;
                }

                // We can also check the depressed-or-not-depressed state of InteractionButton objects
                // and assign them a unique color in that case.
                if (_intObj is InteractionButton && (_intObj as InteractionButton).isPressed)
                {
                    targetColor = pressedColor;
                }

                // Lerp actual material color to the target color.
                for (int i = 0; i < _materials.Length; i++)
                {
                    _materials[i].color = Color.Lerp(_materials[i].color, targetColor, 30F * Time.deltaTime);// 2.2、 改变颜色
                }
            }
        }

    }
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/352473.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

蓝凌OA sysUiExtend.do 任意文件上传漏洞复现

0x01 产品简介 蓝凌核心产品EKP平台定位为新一代数字化生态OA平台,数字化向纵深发展,正加速构建产业互联网,对企业协作能力提出更高要求,蓝凌新一代生态型OA平台能够支撑办公数字化、管理智能化、应用平台化、组织生态化,赋能大中型组织更高效的内外协作与管理,支撑商业…

[UI5 常用控件] 02.Title,Link,Label

文章目录 前言1. Title1.1 结合Panel1.2 结合Table1.3 Title里嵌套Link 2. Link3. Label3.1 普通用法3.2 在Form里使用 前言 本章节记录常用控件Title,Link,Label。 其路径分别是&#xff1a; sap.m.Titlesap.m.Linksap.m.Label 1. Title Title可以结合其他控件一起使用 1.…

Android源码设计模式解析与实战第2版笔记(四)

第三章 自由扩展你的项目–Builder 模式 Builder 模式的定义 将一个复杂对象的构建与它的表示分离&#xff0c;使得同样的构建过程可以创建不同的表示。 Builder 模式的使用场景 相同的方法&#xff0c;不同的执行顺序&#xff0c;产生不同的事件结果时 多个部件或零件&…

使用Spring Boot和Tess4J实现本地与远程图片的文字识别

概要&#xff1a; 在本文中&#xff0c;我们将探讨如何在Spring Boot应用程序里集成Tess4J来实现OCR&#xff08;光学字符识别&#xff09;&#xff0c;以识别出本地和远程图片中的文字。我们将从添加依赖说起&#xff0c;然后创建服务类以实现OCR&#xff0c;最后展示如何处理…

Redis客户端之Jedis(一)介绍

目录 一、Jedis介绍&#xff1a; 1、背景&#xff1a; 2、Jedis连接池介绍&#xff1a; 二、Jedis API&#xff1a; 1、连接池API 2、其他常用API&#xff1a; 三、SpringBoot集成Jedis&#xff1a; 1、Redis集群模式&#xff1a; &#xff08;1&#xff09;配置文件…

MySql8的简单使用(1.模糊查询 2.group by 分组 having过滤 3.JSON字段的实践)

MySql8的简单使用&#xff08;1.模糊查询 2.group by 分组 having过滤 3.JSON字段的实践&#xff09; 一.like模糊查询、group by 分组 having 过滤 建表语句 create table student(id int PRIMARY KEY,name char(10),age int,sex char(5)); alter table student add height…

TCP 状态转换以及半关闭

TCP 状态转换&#xff1a; 上图中还没有进行握手的时候状态是关闭的。 三次握手状态的改变&#xff1a; 客户端发起握手。 调用 connect() 函数时状态转化为&#xff1a;SYN_SENT。调用 listen() 函数时状态转换为&#xff1a;LISTEN。ESTABLISHED是被连接的状态。 四次挥手…

卢禹舜个展开幕作品震撼引人驻足

——“天地人和•大道不孤——卢禹舜中国画作品展”在贵州美术馆盛大开展 1月25日&#xff0c;寒风料峭&#xff0c;冬意正浓&#xff0c;但贵州美术馆大厅内却人潮涌动、热闹非凡。下午3点&#xff0c;由中国国家画院、贵州省文化和旅游厅主办&#xff0c;贵州画院(贵州美术馆…

字符串和C预处理器

本文参考C Primer Plus第四章学习 文章目录 常量和预处理器const限定符 1. 常量和预处理器 有时&#xff0c;在程序中要使用常量。例如&#xff0c;可以这样计算圆的周长&#xff1a; circumference 3.14159 * diameter; 这里&#xff0c;常量3.14159 代表著名的常量 pi(π)。…

详解静态网页数据获取以及浏览器数据和网络数据交互流程

目录 前言 一、静态网页数据 二、网址通讯流程 1.DNS查询 2.建立连接 3.发送HTTP请求 4.服务器处理请求 5.服务器响应 6.渲染页面 7.页面交互 三、URL/POST/GET 1.URL 2.GET 形式 3.POST 形式 四.获取静态网页数据 前言 在网站设计领域&#xff0c;基于纯HTM…

C++中map和set的使用

&#xff08;图片来源于网络&#xff09; &#x1f388;个人主页:&#x1f388; :✨✨✨初阶牛✨✨✨ &#x1f43b;强烈推荐优质专栏: &#x1f354;&#x1f35f;&#x1f32f;C的世界(持续更新中) &#x1f43b;推荐专栏1: &#x1f354;&#x1f35f;&#x1f32f;C语言初阶…

shardinig-JDBC二开-支持sharding-jdbc的配置文件接入到nacos

代码在 https://gitee.com/lbmb/mb-live-app 中 【mb-live-framework】 模块里面的【mb-live-framework-datasource-stater】 如果喜欢 希望大家给给star 项目还在持续更新中。 背景介绍&#xff1a; 因为近期在自己写一套直播项目。使用到了sharding-jdbc来做分库分表的组件…

Python第三方扩展库NumPy

Python第三方扩展库NumPy NumPy(Numerical Python&#xff0c;注意使用时全部小写 numpy) 是 Python 语言的一个扩展程序库&#xff0c;支持大量的维度数组与矩阵运算&#xff0c;此外也针对数组运算提供大量的数学函数库。 在Windows平台上安装numpy&#xff0c;可在cmd命令…

游戏设计模式

单列模式 概念 单例模式是一种创建型设计模式&#xff0c;可以保证一个类只有一个实例&#xff0c;并提供一个访问该实例的全局节点。 优点 可以派生&#xff1a;在单例类的实例构造函数中可以设置以允许子类派生。受控访问&#xff1a;因为单例类封装他的唯一实例&#xf…

学习笔记-李沐动手学深度学习(五)(14-15,数值稳定性、模型初始化和激活函数、Kaggle房价预测)

总结 14-数值稳定性&#xff08;梯度爆炸、梯度消失&#xff09; 尤其是对于深度神经网络&#xff08;即神经网络层数很多&#xff09;&#xff0c;最终的梯度就是每层进行累乘 理论 t&#xff1a;为第t层 y&#xff1a;不是之前的预测值&#xff0c;而是包括了损失函数L …

统一聚合支付系统一个支付系统包含微信支付宝支付接口可对外提供多个网站使用同一个支付系统的初探与逻辑图

#聚合支付# #小李子9479# 开发背景 作为一个合格的站长或者运营&#xff0c;基本上都有好几个网站&#xff0c;而变现的方式其中之一就是付费。经常使用的付费包含微信支付和支付宝支付。微信的jsapi支付需要使用到openid&#xff0c;而获取openid需要设置授权域名&#xff…

C#用TimeSpan的Days、Hours、Minutes及Seconds属性确定程序的运行时间

目录 一、TimeSpan结构的Days、Hours、Minutes及Seconds属性 1.Days属性 2.Hours属性 3.Minutes属性 4.Seconds属性 二、确定程序运行时间的方法 1.实例源码 2.生成效果 在程序设计过程中&#xff0c;经常需要在主窗体中动态地显示程序的运行时间。 一、TimeSpan结构的…

【Linux】-同步互斥的另一种办法-信号量

&#x1f496;作者&#xff1a;小树苗渴望变成参天大树&#x1f388; &#x1f389;作者宣言&#xff1a;认真写好每一篇博客&#x1f4a4; &#x1f38a;作者gitee:gitee✨ &#x1f49e;作者专栏&#xff1a;C语言,数据结构初阶,Linux,C 动态规划算法&#x1f384; 如 果 你 …

身份证也可以cisa远程考试

CISA CISM CRISC CGEIT ​只有身份证 ​没有护照 ​没有港澳通行证 ​也可以线上考试

python学习20

前言&#xff1a;相信看到这篇文章的小伙伴都或多或少有一些编程基础&#xff0c;懂得一些linux的基本命令了吧&#xff0c;本篇文章将带领大家服务器如何部署一个使用django框架开发的一个网站进行云服务器端的部署。 文章使用到的的工具 Python&#xff1a;一种编程语言&…
最新文章