-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPupilCameraSettings.cs
96 lines (86 loc) · 2.88 KB
/
PupilCameraSettings.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR;
namespace Pupil
{
[RequireComponent(typeof(PopupWarning))]
public class PupilCameraSettings : MonoBehaviour
{
[SerializeField]
private PupilCamera _camera;
[SerializeField]
private float _left;
[SerializeField]
private float _right;
[SerializeField]
private float _minDistanceIPD;
[SerializeField]
private float _maxDistanceIPD;
[SerializeField]
private float _maxDistance;
[SerializeField]
private string _red;
[SerializeField]
private string _blue;
[SerializeField]
private string _green;
[SerializeField]
private string _yellow;
[SerializeField]
private bool _debug;
private bool _cameraSet;
void Update()
{
SetCamera();
if (_cameraSet)
{
_camera.AutoAdjustIPD();
_camera.AutoAdjustDepthOfField();
if (_debug)
_camera.DrawViewLines();
}
}
public void SetCamera()
{
if (!_cameraSet)
{
_left = PupilDataHolder.left;
_right = PupilDataHolder.right;
_maxDistance = PupilDataHolder.maxDistance;
_maxDistanceIPD = PupilDataHolder.maxIPD;
_minDistanceIPD = PupilDataHolder.minIPD;
_red = PupilDataHolder.red;
_blue = PupilDataHolder.blue;
_green = PupilDataHolder.green;
_yellow = PupilDataHolder.yellow;
_camera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent<PupilCamera>();
if (_camera) {
_camera.SetMinDistanceIPD(_minDistanceIPD);
_camera.SetMaxDistanceIPD(_maxDistance, _maxDistanceIPD);
_cameraSet = true;
}
}
}
public void SetMinDistanceIPD(float ipd)
{
PupilDataHolder.minIPD = ipd;
_camera.SetMinDistanceIPD(PupilDataHolder.minIPD);
}
public void SetMaxDistanceIPD(float ipd)
{
PupilDataHolder.maxIPD = ipd;
_camera.SetMaxDistanceIPD(PupilDataHolder.maxDistance, PupilDataHolder.maxIPD);
}
public void SetMaxDistance()
{
PupilDataHolder.maxDistance = _camera.GetDistanceToGameObject(_camera.FindNearest());
_camera.SetMaxDistanceIPD(PupilDataHolder.maxDistance, PupilDataHolder.maxIPD);
}
public void SetMaxDistance(int ignoreLayer)
{
PupilDataHolder.maxDistance = _camera.GetDistanceToGameObject(_camera.FindNearest(ignoreLayer));
_camera.SetMaxDistanceIPD(PupilDataHolder.maxDistance, PupilDataHolder.maxIPD);
}
}
}