Commit 076c726c authored by Alexander Krause's avatar Alexander Krause

improved handling

parent f64bc143
......@@ -37,6 +37,7 @@ namespace ExplorVizGestureControl.Gestures
private Dictionary<string, double> dynamicValues = new Dictionary<string, double>();
private float rightHandAnchorLength;
private int selectionStatus = 0;
#endregion
......@@ -107,7 +108,7 @@ namespace ExplorVizGestureControl.Gestures
!GestureDatabase.HandsCrossed())
{
if (rotationActive && !GestureDatabase.HandsAboveSpineBase(1))
if (rotationActive && !GestureDatabase.HandsAboveSpineBase(1, 0.1f))
{
rotationActive = false;
mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0);
......@@ -125,7 +126,7 @@ namespace ExplorVizGestureControl.Gestures
if (handsAbsDistanceY > 0.12f) yDetection = 500;
//Console.WriteLine(handsAbsDistanceY);
Console.WriteLine(handsAbsDistanceY);
distanceZ = distanceZHands - (GestureDatabase.PreviousFrameJoints[(int)JointType.HandLeft].Z - GestureDatabase.PreviousFrameJoints[(int)JointType.HandRight].Z);
distanceY = distanceYHands - (GestureDatabase.PreviousFrameJoints[(int)JointType.HandLeft].Y - GestureDatabase.PreviousFrameJoints[(int)JointType.HandRight].Y);
......@@ -162,10 +163,6 @@ namespace ExplorVizGestureControl.Gestures
}
}
private int selectionStatus = 0;
private void HandleGripAndSelection()
{
if (rotationActive) return;
......
......@@ -117,7 +117,7 @@ namespace ExplorVizGestureControl.Gestures
public static float CalculateVectorLength(CameraSpacePoint point)
{
return (float)Math.Sqrt(Math.Pow(point.X, 2) + Math.Pow(point.Y, 2) + Math.Pow(point.Z, 2));
return (float)Math.Sqrt(Math.Pow(point.X, 2) + Math.Pow(point.Y, 2) + Math.Pow(point.Z, 2));
}
#region HandStates
......@@ -143,7 +143,7 @@ namespace ExplorVizGestureControl.Gestures
}
#endregion
#region Joint comparison
#region Joint comparison
public static Boolean RightElbowBelowRightHand()
{
......@@ -197,45 +197,60 @@ namespace ExplorVizGestureControl.Gestures
joints[(int)JointType.HandLeft].Y >= joints[(int)JointType.Head].Y;
}
public static Boolean HandsAboveSpineBase(int cases = 2)
public static Boolean HandsAboveSpineBase(int cases = 2, float spineBaseOffset = 0.0f)
{
if (cases == 1) return joints[(int)JointType.HandLeft].Y >
joints[(int)JointType.SpineBase].Y ||
joints[(int)JointType.SpineBase].Y + spineBaseOffset ||
joints[(int)JointType.HandRight].Y >
joints[(int)JointType.SpineBase].Y;
joints[(int)JointType.SpineBase].Y + spineBaseOffset;
if (cases == 2) return joints[(int)JointType.HandLeft].Y >
joints[(int)JointType.SpineBase].Y &&
joints[(int)JointType.SpineBase].Y + spineBaseOffset &&
joints[(int)JointType.HandRight].Y >
joints[(int)JointType.SpineBase].Y;
joints[(int)JointType.SpineBase].Y + spineBaseOffset;
if (cases == 3) return joints[(int)JointType.HandLeft].Y >
joints[(int)JointType.SpineBase].Y ^
joints[(int)JointType.SpineBase].Y + spineBaseOffset ^
joints[(int)JointType.HandRight].Y >
joints[(int)JointType.SpineBase].Y;
joints[(int)JointType.SpineBase].Y + spineBaseOffset;
return false;
}
public static Boolean HandsCrossed()
{
{
return joints[(int)JointType.HandLeft].X >= joints[(int)JointType.HandRight].X ? true : false;
}
public static Boolean HandsHaveMinDistance(float distance, char axis = 'x')
{
if (axis.Equals('x')) return Math.Abs(Math.Abs(joints[(int)JointType.HandRight].X) -
Math.Abs(joints[(int)JointType.HandLeft].X)) > distance;
if (axis.Equals('y')) return Math.Abs(Math.Abs(joints[(int)JointType.HandRight].Y) -
Math.Abs(joints[(int)JointType.HandLeft].Y)) > distance;
if (axis.Equals('z')) return Math.Abs(Math.Abs(joints[(int)JointType.HandRight].Z) -
Math.Abs(joints[(int)JointType.HandLeft].Z)) > distance;
return false;
}
public static Boolean HandsHaveAcceptableDistance(float offset = 0.0f, char axis = 'x')
{
if (axis.Equals('x')) return Math.Abs(Math.Abs(joints[(int)JointType.HandLeft].X) -
Math.Abs(joints[(int)JointType.HandRight].X)) <=
Math.Abs(joints[(int)JointType.HandRight].X)) >
Math.Abs(Math.Abs(joints[(int)JointType.ShoulderLeft].X) -
Math.Abs(joints[(int)JointType.ShoulderRight].X)) + offset;
if (axis.Equals('y')) return Math.Abs(Math.Abs(joints[(int)JointType.HandLeft].Y) -
Math.Abs(joints[(int)JointType.HandRight].Y)) <=
Math.Abs(joints[(int)JointType.HandRight].Y)) >
Math.Abs(Math.Abs(joints[(int)JointType.ShoulderLeft].Y) -
Math.Abs(joints[(int)JointType.ShoulderRight].Y)) + offset;
if (axis.Equals('z')) return Math.Abs(Math.Abs(joints[(int)JointType.HandLeft].Z) -
Math.Abs(joints[(int)JointType.HandRight].Z)) <=
Math.Abs(joints[(int)JointType.HandRight].Z)) >
Math.Abs(Math.Abs(joints[(int)JointType.ShoulderLeft].Z) -
Math.Abs(joints[(int)JointType.ShoulderRight].Z)) + offset;
......@@ -265,7 +280,7 @@ namespace ExplorVizGestureControl.Gestures
HandsAboveSpineBase() &&
RightHandBelowRightShoulder() &&
LeftHandBelowLeftShoulder() &&
!HandsCrossed();
HandsHaveMinDistance(0.05f);
}
public static Boolean StartOrReset()
......
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