add gaze point analyzer for multiple monitors.
This commit is contained in:
Binary file not shown.
@@ -25,9 +25,9 @@ public class GazePointAnalyzer : MonoBehaviour
|
|||||||
[Range(0f, 1f)] public float velocityFilter = 0.1f;
|
[Range(0f, 1f)] public float velocityFilter = 0.1f;
|
||||||
|
|
||||||
[Header("Debug")]
|
[Header("Debug")]
|
||||||
[SerializeField] bool drawAveragePos;
|
public bool drawAveragePos;
|
||||||
[SerializeField] bool drawMoveRects;
|
public bool drawMoveRects;
|
||||||
[SerializeField] bool drawDirtyRects;
|
public bool drawDirtyRects;
|
||||||
|
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,69 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
[RequireComponent(typeof(MultipleMonitorCreator))]
|
||||||
|
public class MultipleMonitorAnalyzer : MonoBehaviour
|
||||||
|
{
|
||||||
|
MultipleMonitorCreator creator_;
|
||||||
|
Vector3 gazePoint_ = Vector3.zero;
|
||||||
|
public Vector3 gazePoint
|
||||||
|
{
|
||||||
|
get { return gazePoint_; }
|
||||||
|
private set
|
||||||
|
{
|
||||||
|
gazePoint_ += (value - gazePoint) * (gazePointFilter / (1f / 60 / Time.deltaTime));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Header("Filters")]
|
||||||
|
[Range(0f, 1f)] public float gazePointFilter = 0.1f;
|
||||||
|
[Range(0f, 1f)] public float moveRectFilter = 0.05f;
|
||||||
|
[Range(0f, 1f)] public float mouseFilter = 0.05f;
|
||||||
|
[Range(0f, 1f)] public float dirtyRectFilter = 0.01f;
|
||||||
|
[Range(0f, 1f)] public float noEventFilter = 0.01f;
|
||||||
|
[Range(0f, 1f)] public float velocityFilter = 0.1f;
|
||||||
|
|
||||||
|
[Header("Debug")]
|
||||||
|
[SerializeField] bool drawGazePoint;
|
||||||
|
[SerializeField] bool drawAveragePos;
|
||||||
|
[SerializeField] bool drawMoveRects;
|
||||||
|
[SerializeField] bool drawDirtyRects;
|
||||||
|
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
creator_ = GetComponent<MultipleMonitorCreator>();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
var cursorMonitorId = uDesktopDuplication.Manager.cursorMonitorId;
|
||||||
|
for (int i = 0; i < creator_.monitors.Count; ++i) {
|
||||||
|
var info = creator_.monitors[i];
|
||||||
|
var analyzer =
|
||||||
|
info.gameObject.GetComponent<GazePointAnalyzer>() ??
|
||||||
|
info.gameObject.AddComponent<GazePointAnalyzer>();
|
||||||
|
UpdateAnalyzer(analyzer);
|
||||||
|
if (info.uddTexture.monitorId == cursorMonitorId) {
|
||||||
|
gazePoint = analyzer.averagePos;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (drawGazePoint) DrawGazePoint();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawGazePoint()
|
||||||
|
{
|
||||||
|
Debug.DrawLine(transform.position, gazePoint, Color.magenta);
|
||||||
|
}
|
||||||
|
|
||||||
|
void UpdateAnalyzer(GazePointAnalyzer analyzer)
|
||||||
|
{
|
||||||
|
analyzer.moveRectFilter = moveRectFilter;
|
||||||
|
analyzer.mouseFilter = mouseFilter;
|
||||||
|
analyzer.dirtyRectFilter = dirtyRectFilter;
|
||||||
|
analyzer.noEventFilter = noEventFilter;
|
||||||
|
analyzer.velocityFilter = velocityFilter;
|
||||||
|
analyzer.drawAveragePos = drawAveragePos;
|
||||||
|
analyzer.drawMoveRects = drawMoveRects;
|
||||||
|
analyzer.drawDirtyRects = drawDirtyRects;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: dbdfccef47068644b81b671bb4e6e166
|
||||||
|
timeCreated: 1479620455
|
||||||
|
licenseType: Pro
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -53,8 +53,10 @@ public class Texture : MonoBehaviour
|
|||||||
{
|
{
|
||||||
if (value) {
|
if (value) {
|
||||||
material.EnableKeyword("BEND_ON");
|
material.EnableKeyword("BEND_ON");
|
||||||
|
material.SetInt("_Bend", 1);
|
||||||
} else {
|
} else {
|
||||||
material.DisableKeyword("BEND_ON");
|
material.DisableKeyword("BEND_ON");
|
||||||
|
material.SetInt("_Bend", 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user