我试图在我的Unity项目中实现类似于HTC Vive控制器的飞跃运动功能。我想从食指上产生一个激光指针,并将Vive的房间传送到激光位置(如同控制器一样)。问题在于最新的飞跃(orion)文件,目前还不清楚。任何想法如何做到这一点?更一般的情况是,我们考虑使用HandController,但我们不明白在哪里添加脚本组件。 谢谢!Htc Vive +作为控制器的飞跃运动
0
A
回答
0
目前还不清楚您所遇到的问题是根据您的场景获取手部数据还是使用该手部数据。
如果您只是试图在场景中获取手部数据,则可以从Unity SDK的示例场景之一复制预制件。如果您尝试将Leap集成到已经设置了VR装备的现有场景中,请查看the core Leap components上的文档,以了解需要开始获取Hand数据的部分。 LeapServiceProvider必须位于场景中的某个位置才能接收手形数据。
只要你有一个LeapServiceProvider的地方,你可以从大跃进运动从任何脚本访问手,随时随地。因此,从指数指尖得到一个射线,只是弹出这个脚本任何老地方:
using Leap;
using Leap.Unity;
using UnityEngine;
public class IndexRay : MonoBehaviour {
void Update() {
Hand rightHand = Hands.Right;
Vector3 indexTipPosition = rightHand.Fingers[1].TipPosition.ToVector3();
Vector3 indexTipDirection = rightHand.Fingers[1].bones[3].Direction.ToVector3();
// You can try using other bones in the index finger for direction as well;
// bones[3] is the last bone; bones[1] is the bone extending from the knuckle;
// bones[0] is the index metacarpal bone.
Debug.DrawRay(indexTipPosition, indexTipDirection, Color.cyan);
}
}
对于它的价值,该指数指尖方向可能不会足够稳定,做你想做的。更可靠的策略是通过手部的指节关节从相机投下一条线(或理论上“相对于相机恒定偏移的肩部位置”):
using Leap;
using Leap.Unity;
using UnityEngine;
public class ProjectiveRay : MonoBehaviour {
// To find an approximate shoulder, let's try 12 cm right, 15 cm down, and 4 cm back relative to the camera.
[Tooltip("An approximation for the shoulder position relative to the VR camera in the camera's (non-scaled) local space.")]
public Vector3 cameraShoulderOffset = new Vector3(0.12F, -0.15F, -0.04F);
public Transform shoulderTransform;
void Update() {
Hand rightHand = Hands.Right;
Vector3 cameraPosition = Camera.main.transform.position;
Vector3 shoulderPosition = cameraPosition + Camera.main.transform.rotation * cameraShoulderOffset;
Vector3 indexKnucklePosition = rightHand.Fingers[1].bones[1].PrevJoint.ToVector3();
Vector3 dirFromShoulder = (indexKnucklePosition - shoulderPosition).normalized;
Debug.DrawRay(indexKnucklePosition, dirFromShoulder, Color.white);
Debug.DrawLine(shoulderPosition, indexKnucklePosition, Color.red);
}
}
相关问题
- 1. SteamVR中的多个摄像头HTC vive
- 2. 与Unity 5上的脚连接的HTC控制器散步
- 3. 运动飞跃 - 刷卡检测不起作用
- 4. 无法为Unity上的HTC Vive项目生成构建
- 5. 使飞跃跳跃字符
- 6. Unity3d HTC Vive径向菜单 - 奇怪的毛刺
- 7. 飞跃运动(Python)的 - 在我的代码错误或错误
- 8. Python:将新值添加到来自飞跃控制器的以前值
- 9. HTC VIVE Unity C#VRTK在同一个控制器上使用简单指针和贝塞尔指针?
- 10. Devise_token_auth - 无法运行控制器动作
- 11. 如何在yii2中运行控制器动作作为ajax
- 12. 2 HTC Vive在一个单一的场景
- 13. Chrome.exe在更新后没有响应HTC vive站点固件
- 14. 的Rails 2.3.8应用跳跃控制器
- 15. 在windows上的htc vive上的ROS虚拟盒流
- 16. 作为CakePHP控制器的动词
- 17. 从PhP到Python的飞跃
- 18. 如何,如果飞跃运动装置连接(OBJ-C)
- 19. 如何实时获取HTC vive陀螺仪的(x,y,z)值?
- 20. Unity如何找到Vive控制器游戏对象?
- 21. Magento的控制器动作
- 22. MVC,控制器的动作
- 23. Rails的控制器动作
- 24. 根据ovr控制器移动闰秒运动控制器
- 25. 为控制器动作添加路由
- 26. Yii - 为控制器动作创建url
- 27. 为MVC控制器动作增加maxRequestLength
- 28. MVC控制器动作参数为空
- 29. HTC VIVE开发者如何共享相同的空间并使用不同的Vive设置进行测试?
- 30. 如何确定SteamVR_TrackedObject是Vive Controller还是Vive Tracker