/// <summary> /// Get the Position of the GameView. (Use this informations if you have some troubles with windowed Applications) /// </summary> /// <returns></returns> public static Vector2 GetGameViewPosition() { Win32HelperClass.Point position = new Win32HelperClass.Point(); pointerToGameWindow = Win32HelperClass.GetForegroundWindow(); Win32HelperClass.ClientToScreen(pointerToGameWindow, ref position); return(new Vector2(position.x, position.y)); }
/// <summary> /// Write the SampleData into the gazeModel /// </summary> /// <param name="sampleData"></param> private void GetSampleCallbackFunction(EyeTrackingController.SampleStruct sampleData) { //Left Eye gazeModel.posLeftEye = new Vector3((float)sampleData.leftEye.eyePositionX, (float)sampleData.leftEye.eyePositionY, (float)sampleData.leftEye.eyePositionZ); gazeModel.posGazeLeft = new Vector2((float)sampleData.leftEye.gazeX, (float)sampleData.leftEye.gazeY); //Right Eye gazeModel.posRightEye = new Vector3((float)sampleData.rightEye.eyePositionX, (float)sampleData.rightEye.eyePositionY, (float)sampleData.rightEye.eyePositionZ); gazeModel.posGazeRight = new Vector2((float)sampleData.rightEye.gazeX, (float)sampleData.rightEye.gazeY); //PupilData gazeModel.diamLeftEye = (float)sampleData.leftEye.diam; gazeModel.diamRightEye = (float)sampleData.leftEye.diam; #if UNITY_EDITOR Rect gameView = getOffsetFromGameView(); Vector2 posGazeLeft = new Vector3(gazeModel.posGazeLeft.x, gazeModel.posGazeLeft.y - gameView.y); Vector2 posGazeRight = new Vector3(gazeModel.posGazeRight.x, gazeModel.posGazeRight.y - gameView.y); gazeModel.posGazeLeft = posGazeLeft; gazeModel.posGazeRight = posGazeRight; #else Vector2 offSet = Win32HelperClass.GetGameViewPosition(); if (offSet.x >= 0) { gazeModel.posGazeLeft = gazeModel.posGazeLeft - offSet; gazeModel.posGazeRight = gazeModel.posGazeRight - offSet; } else { gazeModel.posGazeLeft = offSet - gazeModel.posGazeLeft; gazeModel.posGazeRight = offSet - gazeModel.posGazeRight; } #endif gazeModel.gameScreenPosition = Win32HelperClass.GetGameViewPosition(); //Head Position gazeModel.posHead = (gazeModel.posLeftEye + gazeModel.posRightEye) * 0.5f; //TimeStamp of the Sample gazeModel.timeStamp = sampleData.timestamp; }