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.
 
 
 
 
 

52 lines
1.6 KiB

//======= Copyright (c) Valve Corporation, All rights reserved. ===============
//
// Purpose: Used to render an external camera of vr player (split front/back).
//
//=============================================================================
using UnityEngine;
using System.Collections;
namespace Valve.VR
{
public class SteamVR_ExternalCamera_LegacyManager
{
public static bool hasCamera { get { return cameraIndex != -1; } }
public static int cameraIndex = -1;
private static SteamVR_Events.Action newPosesAction = null;
public static void SubscribeToNewPoses()
{
if (newPosesAction == null)
newPosesAction = SteamVR_Events.NewPosesAction(OnNewPoses);
newPosesAction.enabled = true;
}
private static void OnNewPoses(TrackedDevicePose_t[] poses)
{
if (cameraIndex != -1)
return;
int controllercount = 0;
for (int index = 0; index < poses.Length; index++)
{
if (poses[index].bDeviceIsConnected)
{
ETrackedDeviceClass deviceClass = OpenVR.System.GetTrackedDeviceClass((uint)index);
if (deviceClass == ETrackedDeviceClass.Controller || deviceClass == ETrackedDeviceClass.GenericTracker)
{
controllercount++;
if (controllercount >= 3)
{
cameraIndex = index;
break;
}
}
}
}
}
}
}