public static class Positions
{ //For - Resolution640x480
private const float SkeletonMaxX = 0.6f;
private const float SkeletonMaxY = 0.4f;
private static float Adjust(int primaryScreenResolution, float maxJointPosition, float jointPosition)
{ var value = (((((float)primaryScreenResolution) / maxJointPosition) / 2f) * jointPosition)
+ (primaryScreenResolution / 2);
if (value > primaryScreenResolution || value < 0f) return 0f;
return value;
}
/// <summary>
/// Get the current Joint position and Adjust the Skeleton joint position to the current Screen resolution.
/// </summary>
/// <param name="joint">Joint to Adjust</param>
/// <returns></returns>
public static Vector AdjustToScreen(Joint joint)
{ var newVector = new Vector
{ X = Adjust((int)SystemParameters.PrimaryScreenWidth, SkeletonMaxX, joint.Position.X),
Y = Adjust((int)SystemParameters.PrimaryScreenHeight, SkeletonMaxY, -joint.Position.Y),
Z = joint.Position.Z,
W = joint.Position.W
};
return newVector;
}
/// <summary>
/// Get the current Joint position and Adjust the Skeleton joint position to a specific Screen Size.
/// </summary>
/// <param name="joint">Joint to Adjust</param>
/// <param name="screenWidth">Screen Width</param>
/// <param name="screenHeight">Screen Height</param>
/// <returns></returns>
public static Vector AdjustToScreen(Joint joint, int screenWidth, int screenHeight)
{ var newVector = new Vector
{ X = Adjust(screenWidth, SkeletonMaxX, joint.Position.X),
Y = Adjust(screenHeight, SkeletonMaxY, -joint.Position.Y),
Z = joint.Position.Z,
W = joint.Position.W
};
return newVector;
}
}