private void LogData(DataRow d) { if (_dataLogger.IsOpen) { _dataLogger.LogData(d.GetData()); } }
private void LogData(DataRow_RotationTest d) { if (_dataLogger.IsOpen) { _dataLogger.LogData(d.GetData()); } }
private void LogGrab(Hand h) { Vector3 objPosition = _target.transform.position; Vector3 closestPt = _target.GetComponent <Collider>().ClosestPointOnBounds(h.Data.GrabAnchor); Transform headset = Camera.main.transform; string[] data = new string[] { _level.ToString(), (Time.time - _bookStartTime).ToString(), objPosition.x.ToString(), objPosition.y.ToString(), objPosition.z.ToString(), closestPt.x.ToString(), closestPt.y.ToString(), closestPt.z.ToString(), h.Palm.Position.x.ToString(), h.Palm.Position.y.ToString(), h.Palm.Position.z.ToString(), h.Data.GrabAnchor.x.ToString(), h.Data.GrabAnchor.y.ToString(), h.Data.GrabAnchor.z.ToString(), //h.Velocity.x.ToString(), h.Velocity.y.ToString(), h.Velocity.z.ToString(), headset.position.x.ToString(), headset.position.y.ToString(), headset.position.z.ToString(), headset.forward.x.ToString(), headset.forward.y.ToString(), headset.forward.z.ToString(), headset.up.x.ToString(), headset.up.y.ToString(), headset.up.z.ToString() }; dataLogger.LogData(data); }
private void HandleInteractionsForcePoke() { long frameId = SingleHandManager.Instance.CurrentHand.FrameId; long currentTimestamp = SingleHandManager.Instance.GetTimestamp(); Vector3 cursorPosition = positions.CursorPosition; Vector3 clickPosition = positions.ClickPosition; float distanceFromScreen = cursorPosition.z; Vector2 cursorPosition2D = cursorPosition; Vector2 clickPosition2D = clickPosition; /** * Update the hand-appeared cooldown timer if needed. * * Do not allow clicks until a certain amount of time has elapsed after a hand first appears. */ if (!handLastSeen) { // Start a hand appeared cooldown timer handAppearedCooldown.Restart(); } else { if (handAppearedCooldown.ElapsedMilliseconds >= millisecondsCooldownOnEntry | !handAppearedCooldown.IsRunning) { handAppearedCooldown.Stop(); } } handLastSeen = true; // If not ignoring clicks... if ((previousTime != 0f) && !handAppearedCooldown.IsRunning) { // Calculate important variables needed in determining the key events long dtMicroseconds = (currentTimestamp - previousTime); float dt = dtMicroseconds / (1000f * 1000f); // Seconds float dz = (-1f) * (distanceFromScreen - previousScreenDistance); // Metres +ve = towards screen float currentVelocity = dz / dt; // m/s Vector2 dPerpPx = cursorPosition2D - previousScreenPos; Vector2 dPerp = GlobalSettings.virtualScreen.PixelsToMeters(dPerpPx); // Update AppliedForce, which is the crux of the ForcePoke algorithm float forceChange = GetAppliedForceChange(currentVelocity, dt, dPerp, distanceFromScreen); appliedForce += forceChange; appliedForce = Mathf.Clamp01(appliedForce); // Optionally log data to a logger, for post-processing if (logData) { dataLogger.LogData( new List <float>() { currentTimestamp, distanceFromScreen, dt, dz, dPerp.magnitude, appliedForce } ); } // Update the deadzone size if (!pressing) { AdjustDeadzoneSize(forceChange); } // Calculate the positions to use for events Vector2 clickInputPos; Vector2 cursorInputPos; if (pressing && ignoreDragging && clampOnPress) { clickInputPos = clickPressPosition; cursorInputPos = cursorPressPosition; } else { clickInputPos = clickPosition2D; cursorInputPos = cursorPosition2D; } // Send the move event SendInputAction(InputType.MOVE, cursorInputPos, clickInputPos, appliedForce); // Determine whether to send any other events if (pressing) { if (requireHold) { SendInputAction(InputType.HOLD, cursorInputPos, clickInputPos, appliedForce); requireHold = false; } else if (appliedForce < unclickThreshold || ignoreDragging) { pressing = false; isDragging = false; cursorPressPosition = Vector2.zero; clickPressPosition = Vector2.zero; SendInputAction(InputType.UP, cursorInputPos, clickInputPos, appliedForce); } else { if (isDragging) { if (!dragDeadzoneShrinkTriggered && CheckForStartDragDeadzoneShrink(cursorPressPosition, cursorPosition2D)) { positioningModule.Stabiliser.StartShrinkingDeadzone(ShrinkType.MOTION_BASED, dragDeadzoneShrinkRate); dragDeadzoneShrinkTriggered = true; } SendInputAction(InputType.DRAG, cursorInputPos, clickInputPos, appliedForce); } else { if (!ignoreDragging && CheckForStartDrag(cursorPressPosition, cursorPosition2D)) { isDragging = true; dragDeadzoneShrinkTriggered = false; } SendInputAction(InputType.HOLD, cursorInputPos, clickInputPos, appliedForce); } } } else if (!decayingForce && appliedForce >= 1f) { // Need the !decayingForce check here to eliminate the risk of double-clicks // when ignoring dragging and moving past the touch-plane. pressing = true; SendInputAction(InputType.DOWN, cursorInputPos, clickInputPos, appliedForce); cursorPressPosition = cursorPosition2D; clickPressPosition = clickPosition2D; // If dragging is off, we want to decay the force after a click back to the unclick threshold if (decayForceOnClick && ignoreDragging) { decayingForce = true; } // This might be only true if "ignoreDragging" is on, but I think because Pokes can be done quite quickly, // there's a chance that no frame is triggered requireHold = true; } else if (allowHover) { SendInputAction(InputType.HOVER, cursorInputPos, clickInputPos, appliedForce); } if (decayingForce && (appliedForce <= decayThreshold)) { decayingForce = false; } } else { // If ignoring clicks, just move horizontally SendInputAction(InputType.MOVE, cursorPosition2D, clickPosition2D, 0f); if (allowHover) { SendInputAction(InputType.HOVER, cursorPosition2D, clickPosition2D, 0f); } } // Update stored variables previousTime = currentTimestamp; previousScreenDistance = distanceFromScreen; previousScreenPos = cursorPosition2D; }