Commit e20f274c authored by Alexander Krause's avatar Alexander Krause

minimized "dragging-lag" to a minimum due to pointer lock

parent 2d1843f9
......@@ -29,7 +29,6 @@ namespace ExplorVizGestureControl.Gestures
private GestureTimer scrollTimer;
private GestureTimer rotationActivationTimer;
private GestureTimer selectionTimer;
internal static GestureTimer delayTimer;
private Boolean rotationActive = false;
......@@ -58,8 +57,7 @@ namespace ExplorVizGestureControl.Gestures
dynamicValues.Add("rotationYActivation", 0.04);
scrollTimer = new GestureTimer(dynamicValues["zoomVelocity"]);
delayTimer = new GestureTimer(2000);
selectionTimer = new GestureTimer(500);
delayTimer = new GestureTimer(2000);
rotationActivationTimer = new GestureTimer(500);
}
#endregion
......@@ -104,8 +102,8 @@ namespace ExplorVizGestureControl.Gestures
if (GestureDatabase.LeftHandClosed())
{
if (!rotationActivationTimer.busy && !anchorSet)
{
rotationActivationTimer.startTimer();
{
rotationActivationTimer.startTimer();
}
if (!anchorSet)
......@@ -114,7 +112,7 @@ namespace ExplorVizGestureControl.Gestures
{
leftHandAnchorY = Math.Abs(GestureDatabase.Joints[(int)JointType.HandLeft].Y);
leftHandAnchorLength = GestureDatabase.CalculateVectorLength(GestureDatabase.Joints[(int)JointType.HandLeft]);
anchorSet = true;
anchorSet = true;
}
else return;
}
......@@ -127,19 +125,19 @@ namespace ExplorVizGestureControl.Gestures
{
if (Math.Abs(leftHandAnchorLength - vLength) < 0.015f)
{
mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0);
mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0);
rotationActive = true;
}
else
{
{
anchorSet = false;
return;
}
}
if (rotationActive)
{
{
float distanceXHands = GestureDatabase.Joints[(int)JointType.HandLeft].X - GestureDatabase.PreviousFrameJoints[(int)JointType.HandLeft].X;
float distanceYHands = GestureDatabase.Joints[(int)JointType.HandLeft].Y - GestureDatabase.PreviousFrameJoints[(int)JointType.HandLeft].Y;
......@@ -156,7 +154,7 @@ namespace ExplorVizGestureControl.Gestures
else return;
}
else if (rotationActive)
{
{
rotationActivationTimer.startTimer();
rotationActive = false;
anchorSet = false;
......@@ -207,6 +205,8 @@ namespace ExplorVizGestureControl.Gestures
}
}
private void HandleGripAndSelection()
{
if (rotationActive || zoomingActive) return;
......@@ -225,39 +225,48 @@ namespace ExplorVizGestureControl.Gestures
if (GestureDatabase.RightHandClosed())
{
if (selectionStatus == 0)
{
selectionStatus = 1;
{
rightHandAnchorLength = GestureDatabase.CalculateVectorLength(GestureDatabase.Joints[(int)JointType.HandRight]);
return;
selectionStatus = 1;
}
float vLength = GestureDatabase.CalculateVectorLength(GestureDatabase.Joints[(int)JointType.HandRight]);
// If hand position didn't change 1.5 cm (in x, y or z), do no more processing for this frame
if (Math.Abs(rightHandAnchorLength - vLength) < 0.015f) return;
// Else handle grip processing
// Check for intentional / non-intentional rotation
if (!gripActive)
{
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
gripActive = true;
// If hand position changed at least 1.5 cm (vector length!), activate dragging
if (Math.Abs(rightHandAnchorLength - vLength) > 0.015f)
{
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
gripActive = true;
}
else
{
return;
}
}
double distanceX = GestureDatabase.Joints[(int)JointType.HandRight].X -
GestureDatabase.PreviousFrameJoints[(int)JointType.HandRight].X;
double distanceY = GestureDatabase.Joints[(int)JointType.HandRight].Y -
GestureDatabase.PreviousFrameJoints[(int)JointType.HandRight].Y;
// Else handle grip processing
if (gripActive)
{
double distanceX = GestureDatabase.Joints[(int)JointType.HandRight].X -
GestureDatabase.PreviousFrameJoints[(int)JointType.HandRight].X;
double distanceY = GestureDatabase.Joints[(int)JointType.HandRight].Y -
GestureDatabase.PreviousFrameJoints[(int)JointType.HandRight].Y;
int moveX = (int)(distanceX * 3000);
int moveY = (int)(distanceY * 3000);
int moveX = (int)(distanceX * 3000);
int moveY = (int)(distanceY * 3000);
Cursor.Position = new Point(Cursor.Position.X, Cursor.Position.Y) + new Size(moveX, -moveY);
Cursor.Position = new Point(Cursor.Position.X, Cursor.Position.Y) + new Size(moveX, -moveY);
}
else return;
}
else if (gripActive)
{
{
selectionStatus = 0;
gripActive = false;
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
gripActive = false;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment