Skeleton.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. namespace TouchlessA3D {
  5. public enum SkeletonPointsID {
  6. THUMB1 = 0,
  7. THUMB2 = 1,
  8. THUMB3 = 2,
  9. THUMB4 = 3,
  10. INDEX1 = 4,
  11. INDEX2 = 5,
  12. INDEX3 = 6,
  13. INDEX4 = 7,
  14. MIDDLE1 = 8,
  15. MIDDLE2 = 9,
  16. MIDDLE3 = 10,
  17. MIDDLE4 = 11,
  18. RING1 = 12,
  19. RING2 = 13,
  20. RING3 = 14,
  21. RING4 = 15,
  22. PINKY1 = 16,
  23. PINKY2 = 17,
  24. PINKY3 = 18,
  25. PINKY4 = 19,
  26. WRIST = 20,
  27. SKELETON_POINTS_END = 21,
  28. }
  29. public static class SkeletonInfo {
  30. public const int POINTS_END = 21;
  31. public const int BONES_END = 21;
  32. }
  33. public class Skeleton {
  34. public readonly Dictionary<SkeletonPointsID, Vector3> points;
  35. public Skeleton(NativeCalls.ta3d_point_3_float_t[] listOfPoints) {
  36. points = new Dictionary<SkeletonPointsID, Vector3>();
  37. for (int i = 0; i < (int)SkeletonPointsID.SKELETON_POINTS_END; i++) {
  38. points.Add((SkeletonPointsID)i, new Vector3(listOfPoints[i].coordinates[0], -listOfPoints[i].coordinates[1],
  39. listOfPoints[i].coordinates[2]));
  40. }
  41. }
  42. public Vector3 Position(SkeletonPointsID id, Transform camera) {
  43. return camera.TransformPoint(points[id]);
  44. }
  45. public Vector3 Position(int index, Transform camera) {
  46. return Position((SkeletonPointsID)index, camera);
  47. }
  48. }
  49. }