2021년 4학년 1학기 기업연계프로젝트2 컴퓨터소프트웨어공학과 <원광투어팀> 팀장 : 송유진 팀원 : 김나영, 이경희, 한유진
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.6 KiB

5 years ago
  1. //======= Copyright (c) Valve Corporation, All rights reserved. ===============
  2. //
  3. // Purpose: Used to render an external camera of vr player (split front/back).
  4. //
  5. //=============================================================================
  6. using UnityEngine;
  7. using System.Collections;
  8. namespace Valve.VR
  9. {
  10. public class SteamVR_ExternalCamera_LegacyManager
  11. {
  12. public static bool hasCamera { get { return cameraIndex != -1; } }
  13. public static int cameraIndex = -1;
  14. private static SteamVR_Events.Action newPosesAction = null;
  15. public static void SubscribeToNewPoses()
  16. {
  17. if (newPosesAction == null)
  18. newPosesAction = SteamVR_Events.NewPosesAction(OnNewPoses);
  19. newPosesAction.enabled = true;
  20. }
  21. private static void OnNewPoses(TrackedDevicePose_t[] poses)
  22. {
  23. if (cameraIndex != -1)
  24. return;
  25. int controllercount = 0;
  26. for (int index = 0; index < poses.Length; index++)
  27. {
  28. if (poses[index].bDeviceIsConnected)
  29. {
  30. ETrackedDeviceClass deviceClass = OpenVR.System.GetTrackedDeviceClass((uint)index);
  31. if (deviceClass == ETrackedDeviceClass.Controller || deviceClass == ETrackedDeviceClass.GenericTracker)
  32. {
  33. controllercount++;
  34. if (controllercount >= 3)
  35. {
  36. cameraIndex = index;
  37. break;
  38. }
  39. }
  40. }
  41. }
  42. }
  43. }
  44. }