SHARE
TWEET

Untitled

a guest Feb 4th, 2019 104 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using VRTK;
  6. using UnityEngine.XR;
  7. using Oculus.Avatar;
  8. using Photon.Pun;
  9.  
  10. public class AvatarCustomDriverOpenVR : OvrAvatarDriver
  11. {
  12.    
  13.     void Awake()
  14.     {
  15.        
  16.  
  17.  
  18.    
  19.  
  20.  
  21.     }
  22.  
  23.     private void Start()
  24.     {
  25.  
  26. #if UNITY_ANDROID
  27.  
  28.         try
  29.         {
  30.         GameObject reference = VRTK_DeviceFinder.GetControllerLeftHand();
  31.             if (reference) {
  32.  
  33.         reference.GetComponent<VRTK_Pointer>().enabled = false;
  34.         reference.GetComponent<VRTK_UIPointer>().enabled = false;
  35.        if(reference.GetComponent<InputSwitcherUI>()!=null) reference.GetComponent<InputSwitcherUI>().enabled = false;
  36.             }
  37.         }
  38.         catch (Exception e) {
  39.             Debug.LogException(e);
  40.         }
  41.        
  42. #endif
  43.     }
  44.    
  45.    
  46.     float voiceAmplitude = 0.0f;
  47.     ControllerPose GetControllerPose()
  48.     {
  49.         ovrAvatarButton buttons = 0;
  50.         ovrAvatarTouch touches = 0;
  51.         return new ControllerPose
  52.         {
  53.             buttons = buttons,
  54.             touches = touches,
  55.             joystickPosition = Vector3.zero,
  56.             indexTrigger = 0,
  57.             handTrigger = 0,
  58.             isActive = true,
  59.         };
  60.     }
  61.  
  62.     private void CalculateCurrentPose()
  63.     {
  64.         Vector3 headPos = UnityEngine.XR.InputTracking.GetLocalPosition(UnityEngine.XR.XRNode.CenterEye);
  65.  
  66.         CurrentPose = new PoseFrame
  67.         {
  68.             voiceAmplitude = voiceAmplitude,
  69.             headPosition = headPos,
  70.  
  71.             headRotation = UnityEngine.XR.InputTracking.GetLocalRotation(UnityEngine.XR.XRNode.CenterEye),
  72.          
  73.             handLeftPosition = UnityEngine.XR.InputTracking.GetLocalPosition(UnityEngine.XR.XRNode.LeftHand),
  74.             handLeftRotation = UnityEngine.XR.InputTracking.GetLocalRotation(UnityEngine.XR.XRNode.LeftHand),
  75.             handRightPosition = UnityEngine.XR.InputTracking.GetLocalPosition(UnityEngine.XR.XRNode.RightHand),
  76.             handRightRotation = UnityEngine.XR.InputTracking.GetLocalRotation(UnityEngine.XR.XRNode.RightHand),
  77.             controllerLeftPose = GetControllerPose(),
  78.             controllerRightPose = GetControllerPose(),
  79.  
  80.         };
  81.  
  82.  
  83.     }
  84.     public override void UpdateTransforms(IntPtr sdkAvatar)
  85.     {
  86.         CalculateCurrentPose();
  87.        
  88.  
  89.         UpdateTransformsFromPose(sdkAvatar);
  90.     }
  91.  
  92. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top