Commit acc8acda authored by Alexander Krause's avatar Alexander Krause

Refactoring 1

parent 6df06c71
......@@ -30,7 +30,7 @@ namespace ExplorVizGestureControl.Gestures
private Vector3D handRight;
private Vector3D handLeft;
private ExplorVizGestureControl.Gestures.GestureDatabase.PhIZ phiz;
private GestureDatabase.PhIZ phiz;
private GestureTimer scrollTimer;
private GestureTimer openObjectTimer;
......@@ -40,7 +40,7 @@ namespace ExplorVizGestureControl.Gestures
private double oldZ = 0;
private double oldY = 0;
private Vector3D oldHandRight;
private CameraSpacePoint oldHandRight;
private Boolean gripActive = false;
private Dictionary<string, double> dynamicValues = new Dictionary<string, double>();
......@@ -199,20 +199,20 @@ namespace ExplorVizGestureControl.Gestures
if (!gripActive)
{
oldHandRight = handRight;
oldHandRight = GestureDatabase.Joints[(int)JointType.HandRight];
gripActive = true;
}
double distanceX = handRight.X - oldHandRight.X;
double distanceY = handRight.Y - oldHandRight.Y;
double distanceX = GestureDatabase.Joints[(int)JointType.HandRight].X - oldHandRight.X;
double distanceY = GestureDatabase.Joints[(int)JointType.HandRight].Y - oldHandRight.Y;
int moveX = (int)(distanceX * 1000);
int moveY = (int)(distanceY * 1000);
Cursor.Position = new Point(Cursor.Position.X, Cursor.Position.Y) + new Size(moveX, -moveY);
oldHandRight.X = handRight.X;
oldHandRight.Y = handRight.Y;
oldHandRight.X = GestureDatabase.Joints[(int)JointType.HandRight].X;
oldHandRight.Y = GestureDatabase.Joints[(int)JointType.HandRight].Y;
}
else if (gripActive)
{
......
......@@ -28,24 +28,25 @@ namespace ExplorVizGestureControl.Gestures
private static IReadOnlyDictionary<string, Func<bool>> gestureDictionary;
private static Vector3D elbowLeft;
private static Vector3D elbowRight;
public static Vector3D elbowLeft;
public static Vector3D elbowRight;
public static Vector3D handLeft;
public static Vector3D handRight;
private static Vector3D shoulderLeft;
public static Vector3D shoulderLeft;
public static Vector3D shoulderRight;
public static Vector3D wristRight;
public static Vector3D wristLeft;
public static Vector3D spineMid;
public static Vector3D spineBase;
public static Vector3D head;
public static Vector3D oldSpineBase;
public static Vector3D oldSpineBase;
public static Vector3D handRightTip;
public static Vector3D handLeftTip;
public static PhIZ phiz;
public static CameraSpacePoint[] filteredJoints;
public static CameraSpacePoint[] joints;
public static HandState handRightState;
public static HandState handLeftState;
......@@ -77,6 +78,8 @@ namespace ExplorVizGestureControl.Gestures
maxCapacity = 10;
headsStack = new Vector3D[maxCapacity];
int jointCount = Enum.GetNames(typeof(JointType)).Length;
}
#endregion
......@@ -85,7 +88,11 @@ namespace ExplorVizGestureControl.Gestures
public static void refreshJoints(CameraSpacePoint[] filteredJoints, Vector3D[] accumulatedJoint, HandState right, HandState left)
{
GestureDatabase.filteredJoints = filteredJoints;
GestureDatabase.joints = filteredJoints;
GestureDatabase.joints[(int)JointType.ShoulderRight].X = (float)accumulatedJoint[(int)JointType.ShoulderRight].X;
GestureDatabase.joints[(int)JointType.ShoulderRight].Y = (float)accumulatedJoint[(int)JointType.ShoulderRight].Y;
GestureDatabase.joints[(int)JointType.ShoulderRight].Z = (float)accumulatedJoint[(int)JointType.ShoulderRight].Z;
int jtElbowLeft = (int)JointType.ElbowLeft;
int jtElbowRight = (int)JointType.ElbowRight;
......@@ -287,6 +294,8 @@ namespace ExplorVizGestureControl.Gestures
}
}
public static CameraSpacePoint[] Joints { get { return joints; } }
#endregion
......
......@@ -106,8 +106,6 @@ namespace ExplorVizGestureControl.StreamsAndDrawing
public void DrawBodies()
{
CameraSpacePoint[] filteredJoints = GestureDatabase.filteredJoints;
using (DrawingContext dc = this.drawingGroup.Open())
{
// Draw a transparent background
......@@ -119,12 +117,12 @@ namespace ExplorVizGestureControl.StreamsAndDrawing
Dictionary<JointType, Point> jointPoints = new Dictionary<JointType, Point>();
Dictionary<JointType, Joint> joints = new Dictionary<JointType, Joint>();
int length = filteredJoints.Length;
int length = GestureDatabase.Joints.Length;
for (int i = 0; i < length; i++)
{
Joint joint = new Joint();
joint.Position = filteredJoints[i];
joint.Position = GestureDatabase.Joints[i];
JointType type = (JointType)Enum.GetValues(typeof(JointType)).GetValue(i);
joints.Add(type, joint);
}
......@@ -132,9 +130,9 @@ namespace ExplorVizGestureControl.StreamsAndDrawing
foreach (JointType jointType in joints.Keys)
{
CameraSpacePoint position;
position.X = filteredJoints[(int)jointType].X;
position.Y = filteredJoints[(int)jointType].Y;
position.Z = filteredJoints[(int)jointType].Z;
position.X = GestureDatabase.Joints[(int)jointType].X;
position.Y = GestureDatabase.Joints[(int)jointType].Y;
position.Z = GestureDatabase.Joints[(int)jointType].Z;
// sometimes the depth(Z) of an inferred joint may show as negative
// clamp down to 0.1f to prevent coordinatemapper from returning (-Infinity, -Infinity)
......
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