Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by hlppp · Oct 12, 2021 at 08:53 PM · vr

How to get the vertices positions of the meshes on the hand in Oculus Quest?

Sorry I'm new to this field and don't really know anything. In a script I'm writing I wish to get the position vectors of the vertices on the hand, I think they are in OVRPlugin.cs and OVRMesh.cs but I don't know how to refer to them (or if it's possible to refer) in the script I'm writing. How should I do this correctly?

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image hlppp · Oct 13, 2021 at 11:36 AM 0
Share

Sorry I didn't make myself clear, I'm trying to get the vertices of the meshes on the hand

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by rh_galaxy · Oct 13, 2021 at 11:13 AM

[Update: See now that it doesn't answer the question, but I leave it, maybe it helps someone. This is how I get position and rotation of the hand controllers or the head in my VR game. ] This works for me on both Rift and Quest. Unity 2021.1.6f1.

 using UnityEngine;
 using UnityEngine.XR; //new xr system
 using UnityEngine.InputSystem; //new input system
 int iRightHanded = 0;
 internal Vector3 vPosition;
 internal Vector3 vDirection;
 internal Quaternion qRotation;
 //runs every frame, put it on a relevant object. I have it in my singleton CameraController object
 private void Update()
 {
     Mouse mouse = Mouse.current;
     Gamepad gamepad = Gamepad.current;
     UnityEngine.XR.InputDevice handRDevice = InputDevices.GetDeviceAtXRNode(XRNode.RightHand);
     UnityEngine.XR.InputDevice handLDevice = InputDevices.GetDeviceAtXRNode(XRNode.LeftHand);

     //switch hand/use gamepad?
     {
         bool triggerRSupported = handRDevice.TryGetFeatureValue(
             UnityEngine.XR.CommonUsages.trigger, out float triggerR);
         bool button1RSupported = handRDevice.TryGetFeatureValue(
             UnityEngine.XR.CommonUsages.primaryButton, out bool button1R);
         bool button2RSupported = handRDevice.TryGetFeatureValue(
             UnityEngine.XR.CommonUsages.secondaryButton, out bool button2R);
         bool triggerLSupported = handLDevice.TryGetFeatureValue(
             UnityEngine.XR.CommonUsages.trigger, out float triggerL);
         bool button1LSupported = handLDevice.TryGetFeatureValue(
             UnityEngine.XR.CommonUsages.primaryButton, out bool button1L);
         bool button2LSupported = handLDevice.TryGetFeatureValue(
             UnityEngine.XR.CommonUsages.secondaryButton, out bool button2L);
         if (triggerR > 0.5f || button1R || button2R)
         {
             iRightHanded = 1;
         }
         else if (triggerL > 0.5f || button1L || button2L)
         {
             iRightHanded = 2;
         }
         if (gamepad != null)
         {
             if (gamepad.rightTrigger.ReadValue() > 0.5f || gamepad.buttonSouth.isPressed
                 || gamepad.buttonEast.isPressed)
             {
                 iRightHanded = 0;
             }
         }
         if (mouse != null)
         {
             if (mouse.rightButton.isPressed)
             {
                 iRightHanded = 0;
             }
         }
     }

     //update pointing movement (first head)
     vPosition = Camera.main.transform.position;
     vDirection = Camera.main.transform.forward;
     qRotation = Camera.main.transform.rotation;
     //then right hand
     if (iRightHanded == 1)
     {
         bool posRSupported = handRDevice.TryGetFeatureValue(
             UnityEngine.XR.CommonUsages.devicePosition, out Vector3 posR);
         vPosition = transform.TransformPoint(posR); //to world coords
         bool rotRSupported = handRDevice.TryGetFeatureValue(
             UnityEngine.XR.CommonUsages.deviceRotation, out Quaternion rotR);
         vDirection = rotR * Vector3.forward;
         vDirection = transform.TransformDirection(vDirection);
         qRotation = Quaternion.LookRotation(vDirection);
     }
     //then left hand
     if (iRightHanded == 2)
     {
         bool posLSupported = handLDevice.TryGetFeatureValue(
             UnityEngine.XR.CommonUsages.devicePosition, out Vector3 posL);
         vPosition = transform.TransformPoint(posL); //to world coords
         bool rotLSupported = handLDevice.TryGetFeatureValue(
             UnityEngine.XR.CommonUsages.deviceRotation, out Quaternion rotL);
         vDirection = rotL * Vector3.forward;
         vDirection = transform.TransformDirection(vDirection);
         qRotation = Quaternion.LookRotation(vDirection);
     }
 
     //vPosition is world position of either head, right or left hand
     //vDirection is the pointing vector of either head, right or left hand
     //qRotation can be used as direction also
 }

Also includes how to handle gamepad and point with your head. If you don't want world coordinates just take them before transform.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image hlppp · Oct 13, 2021 at 11:35 AM 0
Share

Thank you for your answer!! Actually I want to ask for the position vector array of the vertices of the mesh on the hand, sorry I didn't make myself clear, but still your answer is very useful thanks a lot!

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

170 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Time.deltaTime and vsync - values too low 0 Answers

Detecting and setting active a child object using VRTK 0 Answers

How to change the layout in vr cardboard mode? 0 Answers

vr headset (acer ah100) showing the far clipping plane too near 1 Answer

Zenfone 2 and Unity Native VR 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges