UltiDrawExt.cs 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  1. /** A commerical class which should not be public. Use PEDraw instead. **/
  2. using UnityEngine;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using System.Text;
  6. using System.IO;
  7. namespace Ximmerse.XR.Utils
  8. {
  9. internal static class UltiDrawExt
  10. {
  11. #region constant mesh data
  12. /// <summary>
  13. /// Serialize transform represent a full hierarchy transform node.
  14. /// </summary>
  15. [System.Serializable]
  16. internal struct serializeTransform
  17. {
  18. public Matrix4x4 t;
  19. public int idx;
  20. public int pIdx;
  21. public serializeTransform (Vector3 localposition, Quaternion localrotation, Vector3 localscale, int parentNodeIndex, int thisNodeIndex)
  22. {
  23. t = Matrix4x4.TRS (localposition, localrotation, localscale);
  24. pIdx = parentNodeIndex;
  25. idx = thisNodeIndex;
  26. }
  27. }
  28. /// <summary>
  29. /// The human bones transform data.
  30. /// </summary>
  31. static List<serializeTransform> humanBonesTransformData = new List<serializeTransform>();
  32. /// <summary>
  33. /// The dog bones transform data.
  34. /// </summary>
  35. static List<serializeTransform> dogBoneTransformData = new List<serializeTransform>();
  36. /// <summary>
  37. /// a constant string represent human bone array transform, in the format of serializeTransform format.
  38. /// </summary>
  39. static readonly string humanBonesArrayTransform = @"{""t"":{""e00"":1.0,""e01"":0.0,""e02"":0.0,""e03"":0.0,""e10"":0.0,""e11"":1.0,""e12"":0.0,""e13"":0.0,""e20"":0.0,""e21"":0.0,""e22"":1.0,""e23"":0.0,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":0,""pIdx"":-1}
  40. {""t"":{""e00"":0.7400000095367432,""e01"":0.0,""e02"":0.0,""e03"":-0.001463174819946289,""e10"":0.0,""e11"":0.7400000095367432,""e12"":0.0,""e13"":0.703000009059906,""e20"":0.0,""e21"":0.0,""e22"":0.7400000095367432,""e23"":0.0009672641754150391,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":1,""pIdx"":0}
  41. {""t"":{""e00"":1.0,""e01"":0.0,""e02"":0.0,""e03"":-0.0014305412769317628,""e10"":0.0,""e11"":1.0,""e12"":0.0,""e13"":0.703000009059906,""e20"":0.0,""e21"":0.0,""e22"":1.0,""e23"":0.0007693099905736744,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":2,""pIdx"":1}
  42. {""t"":{""e00"":1.0,""e01"":0.0,""e02"":0.0,""e03"":0.06136259436607361,""e10"":0.0,""e11"":1.0,""e12"":0.0,""e13"":0.6240360140800476,""e20"":0.0,""e21"":0.0,""e22"":1.0,""e23"":0.0021881582215428354,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":3,""pIdx"":2}
  43. {""t"":{""e00"":1.0,""e01"":0.0,""e02"":0.0,""e03"":0.09640645980834961,""e10"":0.0,""e11"":1.0,""e12"":0.0,""e13"":0.32629460096359255,""e20"":0.0,""e21"":0.0,""e22"":1.0,""e23"":0.00793412234634161,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":4,""pIdx"":3}
  44. {""t"":{""e00"":1.0,""e01"":0.0,""e02"":0.0,""e03"":0.08718058466911316,""e10"":0.0,""e11"":1.0,""e12"":0.0,""e13"":0.025894761085510255,""e20"":0.0,""e21"":0.0,""e22"":1.0,""e23"":-0.0777798593044281,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":5,""pIdx"":4}
  45. {""t"":{""e00"":1.0,""e01"":0.0,""e02"":0.0,""e03"":0.12086915969848633,""e10"":0.0,""e11"":1.0,""e12"":0.0,""e13"":-0.008080661296844483,""e20"":0.0,""e21"":0.0,""e22"":1.0,""e23"":0.0074321795254945759,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":6,""pIdx"":5}
  46. {""t"":{""e00"":1.0,""e01"":0.0,""e02"":0.0,""e03"":0.0003235340118408203,""e10"":0.0,""e11"":1.0,""e12"":0.0,""e13"":0.703000009059906,""e20"":0.0,""e21"":0.0,""e22"":1.0,""e23"":0.0003035354311577976,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":7,""pIdx"":1}
  47. {""t"":{""e00"":1.0,""e01"":0.0,""e02"":0.0,""e03"":-0.06487572193145752,""e10"":0.0,""e11"":1.0,""e12"":0.0,""e13"":0.6297387480735779,""e20"":0.0,""e21"":0.0,""e22"":1.0,""e23"":0.004691872745752335,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":8,""pIdx"":7}
  48. {""t"":{""e00"":1.0,""e01"":0.0,""e02"":0.0,""e03"":-0.07720482349395752,""e10"":0.0,""e11"":1.0,""e12"":0.0,""e13"":0.32857710123062136,""e20"":0.0,""e21"":0.0,""e22"":1.0,""e23"":0.03169003501534462,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":9,""pIdx"":8}
  49. {""t"":{""e00"":1.0,""e01"":0.0,""e02"":0.0,""e03"":-0.0570397675037384,""e10"":0.0,""e11"":1.0,""e12"":0.0,""e13"":0.026610076427459718,""e20"":0.0,""e21"":0.0,""e22"":1.0,""e23"":-0.04747875779867172,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":10,""pIdx"":9}
  50. {""t"":{""e00"":1.0,""e01"":0.0,""e02"":0.0,""e03"":-0.0839042067527771,""e10"":0.0,""e11"":1.0,""e12"":0.0,""e13"":-0.0032608509063720705,""e20"":0.0,""e21"":0.0,""e22"":1.0,""e23"":0.04334092512726784,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":11,""pIdx"":10}
  51. {""t"":{""e00"":1.0,""e01"":0.0,""e02"":0.0,""e03"":0.0013662278652191163,""e10"":0.0,""e11"":1.0,""e12"":0.0,""e13"":0.703000009059906,""e20"":0.0,""e21"":0.0,""e22"":1.0,""e23"":0.0029565095901489259,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":12,""pIdx"":1}
  52. {""t"":{""e00"":1.0,""e01"":0.0,""e02"":0.0,""e03"":-0.00571247935295105,""e10"":0.0,""e11"":1.0,""e12"":0.0,""e13"":0.7875664234161377,""e20"":0.0,""e21"":0.0,""e22"":1.0,""e23"":0.010860915295779705,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":13,""pIdx"":12}
  53. {""t"":{""e00"":1.0,""e01"":0.0,""e02"":0.0,""e03"":-0.01089528203010559,""e10"":0.0,""e11"":1.0,""e12"":0.0,""e13"":0.8606693744659424,""e20"":0.0,""e21"":0.0,""e22"":1.0,""e23"":0.05359872803092003,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":14,""pIdx"":13}
  54. {""t"":{""e00"":1.0,""e01"":0.0,""e02"":0.0,""e03"":-0.01089528203010559,""e10"":0.0,""e11"":1.0,""e12"":0.0,""e13"":0.8606693744659424,""e20"":0.0,""e21"":0.0,""e22"":1.0,""e23"":0.05359872803092003,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":15,""pIdx"":14}
  55. {""t"":{""e00"":1.0,""e01"":0.0,""e02"":0.0,""e03"":-0.009985089302062989,""e10"":0.0,""e11"":1.0,""e12"":0.0,""e13"":0.9322498440742493,""e20"":0.0,""e21"":0.0,""e22"":1.0,""e23"":0.03631620109081268,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":16,""pIdx"":15}
  56. {""t"":{""e00"":1.0,""e01"":0.0,""e02"":0.0,""e03"":-0.00807046890258789,""e10"":0.0,""e11"":1.0,""e12"":0.0,""e13"":1.0056337118148804,""e20"":0.0,""e21"":0.0,""e22"":1.0,""e23"":0.029990311712026597,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":17,""pIdx"":16}
  57. {""t"":{""e00"":1.0,""e01"":0.0,""e02"":0.0,""e03"":-0.01089528203010559,""e10"":0.0,""e11"":1.0,""e12"":0.0,""e13"":0.8606693744659424,""e20"":0.0,""e21"":0.0,""e22"":1.0,""e23"":0.05359872803092003,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":18,""pIdx"":14}
  58. {""t"":{""e00"":1.0,""e01"":0.0,""e02"":0.0,""e03"":0.09816440939903259,""e10"":0.0,""e11"":1.0,""e12"":0.0,""e13"":0.9019056558609009,""e20"":0.0,""e21"":0.0,""e22"":1.0,""e23"":-0.03930070996284485,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":19,""pIdx"":18}
  59. {""t"":{""e00"":1.0,""e01"":0.0,""e02"":0.0,""e03"":0.15319743752479554,""e10"":0.0,""e11"":1.0,""e12"":0.0,""e13"":0.7013065218925476,""e20"":0.0,""e21"":0.0,""e22"":1.0,""e23"":-0.0412604920566082,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":20,""pIdx"":19}
  60. {""t"":{""e00"":1.0,""e01"":0.0,""e02"":0.0,""e03"":0.16081850230693818,""e10"":0.0,""e11"":1.0,""e12"":0.0,""e13"":0.575278639793396,""e20"":0.0,""e21"":0.0,""e22"":1.0,""e23"":0.016833415254950525,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":21,""pIdx"":20}
  61. {""t"":{""e00"":1.0,""e01"":0.0,""e02"":0.0,""e03"":0.16081850230693818,""e10"":0.0,""e11"":1.0,""e12"":0.0,""e13"":0.575278639793396,""e20"":0.0,""e21"":0.0,""e22"":1.0,""e23"":0.016833415254950525,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":22,""pIdx"":21}
  62. {""t"":{""e00"":1.0,""e01"":0.0,""e02"":0.0,""e03"":0.16748084127902986,""e10"":0.0,""e11"":1.0,""e12"":0.0,""e13"":0.5482072830200195,""e20"":0.0,""e21"":0.0,""e22"":1.0,""e23"":0.026929959654808046,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":23,""pIdx"":22}
  63. {""t"":{""e00"":1.0,""e01"":0.0,""e02"":0.0,""e03"":0.16081850230693818,""e10"":0.0,""e11"":1.0,""e12"":0.0,""e13"":0.575278639793396,""e20"":0.0,""e21"":0.0,""e22"":1.0,""e23"":0.016833415254950525,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":24,""pIdx"":21}
  64. {""t"":{""e00"":1.0,""e01"":0.0,""e02"":0.0,""e03"":-0.01089528203010559,""e10"":0.0,""e11"":1.0,""e12"":0.0,""e13"":0.8606693744659424,""e20"":0.0,""e21"":0.0,""e22"":1.0,""e23"":0.05359872803092003,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":25,""pIdx"":14}
  65. {""t"":{""e00"":1.0,""e01"":0.0,""e02"":0.0,""e03"":-0.10616716742515564,""e10"":0.0,""e11"":1.0,""e12"":0.0,""e13"":0.9059644937515259,""e20"":0.0,""e21"":0.0,""e22"":1.0,""e23"":-0.04334395006299019,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":26,""pIdx"":25}
  66. {""t"":{""e00"":1.0,""e01"":0.0,""e02"":0.0,""e03"":-0.15962770581245423,""e10"":0.0,""e11"":1.0,""e12"":0.0,""e13"":0.6957725882530212,""e20"":0.0,""e21"":0.0,""e22"":1.0,""e23"":-0.040417157113552096,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":27,""pIdx"":26}
  67. {""t"":{""e00"":1.0,""e01"":0.0,""e02"":0.0,""e03"":-0.1639036238193512,""e10"":0.0,""e11"":1.0,""e12"":0.0,""e13"":0.5614107847213745,""e20"":0.0,""e21"":0.0,""e22"":1.0,""e23"":0.008602261543273926,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":28,""pIdx"":27}
  68. {""t"":{""e00"":1.0,""e01"":0.0,""e02"":0.0,""e03"":-0.1639036238193512,""e10"":0.0,""e11"":1.0,""e12"":0.0,""e13"":0.5614107847213745,""e20"":0.0,""e21"":0.0,""e22"":1.0,""e23"":0.008602261543273926,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":29,""pIdx"":28}
  69. {""t"":{""e00"":1.0,""e01"":0.0,""e02"":0.0,""e03"":-0.1672215759754181,""e10"":0.0,""e11"":1.0,""e12"":0.0,""e13"":0.5370010137557983,""e20"":0.0,""e21"":0.0,""e22"":1.0,""e23"":0.01574113965034485,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":30,""pIdx"":29}
  70. {""t"":{""e00"":1.0,""e01"":0.0,""e02"":0.0,""e03"":-0.1639036238193512,""e10"":0.0,""e11"":1.0,""e12"":0.0,""e13"":0.5614107847213745,""e20"":0.0,""e21"":0.0,""e22"":1.0,""e23"":0.008602438494563103,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":31,""pIdx"":28}";
  71. static readonly string dogBonesArrayTransform = @"{""t"":{""e00"":1.0,""e01"":0.0,""e02"":0.0,""e03"":0.0,""e10"":0.0,""e11"":1.0,""e12"":0.0,""e13"":0.0,""e20"":0.0,""e21"":0.0,""e22"":1.0,""e23"":0.0,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":0,""pIdx"":-1}
  72. {""t"":{""e00"":-1.0545731043976048e-7,""e01"":0.0,""e02"":0.8846399188041687,""e03"":0.0,""e10"":0.0,""e11"":0.8846399784088135,""e12"":0.0,""e13"":0.39899998903274538,""e20"":-0.8846399784088135,""e21"":0.0,""e22"":-1.0545730333433312e-7,""e23"":-0.1080000028014183,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":1,""pIdx"":0}
  73. {""t"":{""e00"":-1.192093463942001e-7,""e01"":0.0,""e02"":1.0000003576278687,""e03"":0.0,""e10"":0.0,""e11"":1.0,""e12"":0.0,""e13"":0.39899998903274538,""e20"":-1.0000003576278687,""e21"":0.0,""e22"":-1.192093463942001e-7,""e23"":-0.1080000028014183,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":2,""pIdx"":1}
  74. {""t"":{""e00"":0.006082834210246801,""e01"":0.0049187070690095428,""e02"":0.9999696612358093,""e03"":0.0,""e10"":-4.656613983300417e-10,""e11"":0.9999879002571106,""e12"":-0.004918799735605717,""e13"":0.39899998903274538,""e20"":-0.999981701374054,""e21"":0.00002992013469338417,""e22"":0.006082774605602026,""e23"":-0.1080000028014183,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":3,""pIdx"":2}
  75. {""t"":{""e00"":-0.009465336799621582,""e01"":0.004484670236706734,""e02"":0.9999452233314514,""e03"":-0.0011411692248657346,""e10"":-2.3283064365386965e-10,""e11"":0.999989926815033,""e12"":-0.004484870936721563,""e13"":0.3722013831138611,""e20"":-0.9999552369117737,""e21"":-0.000042450614273548126,""e22"":-0.009465217590332032,""e23"":0.05792776495218277,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":4,""pIdx"":3}
  76. {""t"":{""e00"":-0.010424971580505371,""e01"":-0.01848859153687954,""e02"":0.9997747540473938,""e03"":0.000763662566896528,""e10"":0.0,""e11"":0.9998290538787842,""e12"":0.018489593639969827,""e13"":0.3768046796321869,""e20"":-0.9999457597732544,""e21"":0.00019275490194559097,""e22"":-0.010423301719129086,""e23"":0.2569822072982788,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":5,""pIdx"":4}
  77. {""t"":{""e00"":-0.002127171028405428,""e01"":-0.05337836593389511,""e02"":-0.9985722303390503,""e03"":0.0008065859437920153,""e10"":-1.862645593320167e-9,""e11"":0.9985744953155518,""e12"":-0.05337848886847496,""e13"":0.43585166335105898,""e20"":0.9999979734420776,""e21"":-0.00011354686284903437,""e22"":-0.0021241905633360149,""e23"":0.3658486306667328,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":6,""pIdx"":5}
  78. {""t"":{""e00"":-0.0021271705627441408,""e01"":-0.05337834730744362,""e02"":-0.9985719323158264,""e03"":-0.00022880038886796683,""e10"":-1.862645149230957e-9,""e11"":0.9985741972923279,""e12"":-0.05337847024202347,""e13"":0.449261873960495,""e20"":0.9999977350234985,""e21"":-0.0001135468264692463,""e22"":-0.002124189864844084,""e23"":0.5156348347663879,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":7,""pIdx"":6}
  79. {""t"":{""e00"":-0.8066263794898987,""e01"":0.20425330102443696,""e02"":0.5546481013298035,""e03"":0.038460057228803638,""e10"":0.0,""e11"":0.9383928775787354,""e12"":-0.3455701768398285,""e13"":0.3480559289455414,""e20"":-0.5910616517066956,""e21"":-0.27874600887298586,""e22"":-0.7569325566291809,""e23"":0.2341313660144806,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":8,""pIdx"":4}
  80. {""t"":{""e00"":0.38020431995391848,""e01"":0.22023969888687135,""e02"":0.8982980251312256,""e03"":0.07097065448760987,""e10"":7.450580596923828e-9,""e11"":0.9712352156639099,""e12"":-0.23812207579612733,""e13"":0.30337703227996828,""e20"":-0.9249025583267212,""e21"":0.09053503721952439,""e22"":0.36926785111427309,""e23"":0.2783515751361847,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":9,""pIdx"":8}
  81. {""t"":{""e00"":0.6010429263114929,""e01"":0.07524804025888443,""e02"":0.7956666946411133,""e03"":0.08297658711671829,""e10"":3.725290742551124e-9,""e11"":0.9955576658248901,""e12"":-0.09415226429700852,""e13"":0.20603010058403016,""e20"":-0.7992169260978699,""e21"":0.056589525192976,""e22"":0.5983729958534241,""e23"":0.18637129664421082,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":10,""pIdx"":9}
  82. {""t"":{""e00"":0.3366647958755493,""e01"":-0.08522284775972367,""e02"":0.9377604126930237,""e03"":0.04759543761610985,""e10"":3.725290298461914e-9,""e11"":0.99589604139328,""e12"":0.09050621092319489,""e13"":0.054351806640625,""e20"":-0.9416245818138123,""e21"":-0.03047024831175804,""e22"":0.33528321981430056,""e23"":0.2095521092414856,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":11,""pIdx"":10}
  83. {""t"":{""e00"":0.33666470646858218,""e01"":-0.08522284775972367,""e02"":0.9377602934837341,""e03"":0.04009012132883072,""e10"":3.7252891882388896e-9,""e11"":0.99589604139328,""e12"":0.09050620347261429,""e13"":0.0017881393432617188,""e20"":-0.9416242837905884,""e21"":-0.03047024831175804,""e22"":0.33528319001197817,""e23"":0.2447327971458435,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":12,""pIdx"":11}
  84. {""t"":{""e00"":0.8483540415763855,""e01"":-0.19343015551567079,""e02"":0.4928286373615265,""e03"":-0.03761489316821098,""e10"":7.450580152834618e-9,""e11"":0.9308678507804871,""e12"":0.3653559684753418,""e13"":0.3483971357345581,""e20"":-0.5294291973114014,""e21"":-0.3099512755870819,""e22"":0.7897055149078369,""e23"":0.2348514199256897,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":13,""pIdx"":4}
  85. {""t"":{""e00"":-0.33795595169067385,""e01"":-0.22764495015144349,""e02"":0.9132162928581238,""e03"":-0.07241242378950119,""e10"":-2.2351748896198843e-8,""e11"":0.9703072905540466,""e12"":0.24187642335891725,""e13"":0.30366551876068118,""e20"":-0.9411624073982239,""e21"":0.081743523478508,""e22"":-0.32792094349861147,""e23"":0.2772636115550995,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":14,""pIdx"":13}
  86. {""t"":{""e00"":-0.4894235134124756,""e01"":-0.11179473996162415,""e02"":0.864850640296936,""e03"":-0.08062644302845001,""e10"":-7.450580596923828e-9,""e11"":0.9917483925819397,""e12"":0.12819817662239076,""e13"":0.20760351419448853,""e20"":-0.8720463514328003,""e21"":0.0627431869506836,""e22"":-0.48538511991500857,""e23"":0.1835324466228485,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":15,""pIdx"":14}
  87. {""t"":{""e00"":-0.4453616142272949,""e01"":0.09492304176092148,""e02"":0.8903051614761353,""e03"":-0.04463654384016991,""e10"":0.0,""e11"":0.9943641424179077,""e12"":-0.10601773858070374,""e13"":0.056218743324279788,""e20"":-0.8953511714935303,""e21"":-0.04721619188785553,""e22"":-0.4428516626358032,""e23"":0.20767557621002198,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":16,""pIdx"":15}
  88. {""t"":{""e00"":-0.44536149501800539,""e01"":0.09492302685976029,""e02"":0.8903048634529114,""e03"":-0.03327874466776848,""e10"":0.0,""e11"":0.9943639636039734,""e12"":-0.10601770877838135,""e13"":0.004392057657241821,""e20"":-0.8953509330749512,""e21"":-0.04721618443727493,""e22"":-0.4428515136241913,""e23"":0.24291649460792542,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":17,""pIdx"":16}
  89. {""t"":{""e00"":-0.00951206125319004,""e01"":0.004385181237012148,""e02"":0.9999443888664246,""e03"":-0.023664170876145364,""e10"":0.0,""e11"":0.9999904036521912,""e12"":-0.00438537634909153,""e13"":0.3561616837978363,""e20"":-0.9999541640281677,""e21"":-0.00004171393811702728,""e22"":-0.009511941112577916,""e23"":0.022660143673419954,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":18,""pIdx"":4}
  90. {""t"":{""e00"":-0.009512066841125489,""e01"":0.004385181237012148,""e02"":0.9999451041221619,""e03"":-0.05481899902224541,""e10"":0.0,""e11"":0.9999904036521912,""e12"":-0.004385379608720541,""e13"":0.31206589937210085,""e20"":-0.9999547600746155,""e21"":-0.00004171393811702728,""e22"":-0.009511947631835938,""e23"":0.02293962985277176,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":19,""pIdx"":18}
  91. {""t"":{""e00"":-0.009512066841125489,""e01"":0.004385181237012148,""e02"":0.9999451041221619,""e03"":-0.010768407955765725,""e10"":0.0,""e11"":0.9999904036521912,""e12"":-0.004385379608720541,""e13"":0.27109038829803469,""e20"":-0.9999547600746155,""e21"":-0.00004171393811702728,""e22"":-0.009511947631835938,""e23"":0.022505037486553193,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":20,""pIdx"":19}
  92. {""t"":{""e00"":-0.009511584416031838,""e01"":0.0043851882219314579,""e02"":0.9999443888664246,""e03"":0.020565465092658998,""e10"":-2.3283050487599156e-10,""e11"":0.9999904036521912,""e12"":-0.004385383799672127,""e13"":0.355981707572937,""e20"":-0.9999541640281677,""e21"":-0.00004171207547187805,""e22"":-0.009511464275419712,""e23"":0.022235490381717683,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":21,""pIdx"":4}
  93. {""t"":{""e00"":-0.009511590003967286,""e01"":0.0043851882219314579,""e02"":0.9999451041221619,""e03"":0.05133204534649849,""e10"":-2.3283064365386965e-10,""e11"":0.9999904036521912,""e12"":-0.004385387059301138,""e13"":0.31161433458328249,""e20"":-0.9999547600746155,""e21"":-0.00004171207547187805,""e22"":-0.009511470794677735,""e23"":0.021925978362560273,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":22,""pIdx"":21}
  94. {""t"":{""e00"":-0.009511590003967286,""e01"":0.0043851882219314579,""e02"":0.9999451041221619,""e03"":0.0025005231145769359,""e10"":0.0,""e11"":0.9999904036521912,""e12"":-0.004385386593639851,""e13"":0.2710461914539337,""e20"":-0.9999547600746155,""e21"":-0.0000417118426412344,""e22"":-0.009511470794677735,""e23"":0.022374875843524934,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":23,""pIdx"":22}
  95. {""t"":{""e00"":-0.009512066841125489,""e01"":0.004385181237012148,""e02"":0.9999451041221619,""e03"":-0.02771071158349514,""e10"":0.0,""e11"":0.9999904036521912,""e12"":-0.004385379608720541,""e13"":0.34849026799201968,""e20"":-0.9999547600746155,""e21"":-0.00004171393811702728,""e22"":-0.009511947631835938,""e23"":0.06611385196447373,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":24,""pIdx"":4}
  96. {""t"":{""e00"":-0.009512066841125489,""e01"":0.004385181237012148,""e02"":0.9999451041221619,""e03"":-0.05886555463075638,""e10"":0.0,""e11"":0.9999904036521912,""e12"":-0.004385379608720541,""e13"":0.3043944835662842,""e20"":-0.9999547600746155,""e21"":-0.00004171393811702728,""e22"":-0.009511947631835938,""e23"":0.06639335304498673,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":25,""pIdx"":24}
  97. {""t"":{""e00"":-0.009512066841125489,""e01"":0.004385181237012148,""e02"":0.9999451041221619,""e03"":-0.014814935624599457,""e10"":0.0,""e11"":0.9999904036521912,""e12"":-0.004385379608720541,""e13"":0.2634190022945404,""e20"":-0.9999547600746155,""e21"":-0.00004171393811702728,""e22"":-0.009511947631835938,""e23"":0.06595874577760697,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":26,""pIdx"":25}
  98. {""t"":{""e00"":-0.009511590003967286,""e01"":0.004385193809866905,""e02"":0.9999451041221619,""e03"":0.025364847853779794,""e10"":-2.3283064365386965e-10,""e11"":0.9999917149543762,""e12"":-0.004385387059301138,""e13"":0.34827059507369997,""e20"":-0.9999547600746155,""e21"":-0.00004171213004156016,""e22"":-0.009511470794677735,""e23"":0.06560566276311875,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":27,""pIdx"":4}
  99. {""t"":{""e00"":-0.009511590003967286,""e01"":0.0043851882219314579,""e02"":0.9999451041221619,""e03"":0.05613144487142563,""e10"":-2.3283064365386965e-10,""e11"":0.9999904036521912,""e12"":-0.004385387059301138,""e13"":0.30390316247940066,""e20"":-0.9999547600746155,""e21"":-0.00004171207547187805,""e22"":-0.009511470794677735,""e23"":0.06529612094163895,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":28,""pIdx"":27}
  100. {""t"":{""e00"":-0.009511590003967286,""e01"":0.0043851882219314579,""e02"":0.9999451041221619,""e03"":0.00729989493265748,""e10"":0.0,""e11"":0.9999904036521912,""e12"":-0.004385386593639851,""e13"":0.2633349895477295,""e20"":-0.9999547600746155,""e21"":-0.0000417118426412344,""e22"":-0.009511470794677735,""e23"":0.0657450333237648,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":29,""pIdx"":28}
  101. {""t"":{""e00"":-0.009511590003967286,""e01"":0.004385193809866905,""e02"":0.9999451041221619,""e03"":-0.03169197961688042,""e10"":-2.3283064365386965e-10,""e11"":0.9999917149543762,""e12"":-0.004385387059301138,""e13"":0.35539326071739199,""e20"":-0.9999547600746155,""e21"":-0.00004171213004156016,""e22"":-0.009511470794677735,""e23"":0.10955553501844406,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":30,""pIdx"":4}
  102. {""t"":{""e00"":-0.009511590003967286,""e01"":0.0043851882219314579,""e02"":0.9999451041221619,""e03"":-0.062846839427948,""e10"":0.0,""e11"":0.9999904036521912,""e12"":-0.004385386593639851,""e13"":0.3112974166870117,""e20"":-0.9999547600746155,""e21"":-0.0000417118426412344,""e22"":-0.009511470794677735,""e23"":0.10983497649431229,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":31,""pIdx"":30}
  103. {""t"":{""e00"":-0.009511590003967286,""e01"":0.00438518775627017,""e02"":0.9999451041221619,""e03"":-0.01885133422911167,""e10"":0.0,""e11"":0.9999904036521912,""e12"":-0.004385386593639851,""e13"":0.25776010751724245,""e20"":-0.9999547600746155,""e21"":-0.0000417118426412344,""e22"":-0.009511470794677735,""e23"":0.10939610749483109,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":32,""pIdx"":31}
  104. {""t"":{""e00"":-0.009511590003967286,""e01"":0.004385193809866905,""e02"":0.9999451041221619,""e03"":0.03022950142621994,""e10"":-2.3283064365386965e-10,""e11"":0.9999917149543762,""e12"":-0.004385387059301138,""e13"":0.35513389110565188,""e20"":-0.9999547600746155,""e21"":-0.00004171213004156016,""e22"":-0.009511470794677735,""e23"":0.10896364599466324,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":33,""pIdx"":4}
  105. {""t"":{""e00"":-0.009511590003967286,""e01"":0.0043851882219314579,""e02"":0.9999451041221619,""e03"":0.060996100306510928,""e10"":-2.3283064365386965e-10,""e11"":0.9999904036521912,""e12"":-0.004385387059301138,""e13"":0.31076645851135256,""e20"":-0.9999547600746155,""e21"":-0.00004171207547187805,""e22"":-0.009511470794677735,""e23"":0.10865407437086106,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":34,""pIdx"":33}
  106. {""t"":{""e00"":-0.009511590003967286,""e01"":0.0043851882219314579,""e02"":0.9999451041221619,""e03"":0.012109416536986828,""e10"":0.0,""e11"":0.9999904036521912,""e12"":-0.004385386593639851,""e13"":0.25763648748397829,""e20"":-0.9999547600746155,""e21"":-0.0000417118426412344,""e22"":-0.009511470794677735,""e23"":0.10909871011972428,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":35,""pIdx"":34}
  107. {""t"":{""e00"":-0.009511590003967286,""e01"":0.004385193809866905,""e02"":0.9999451041221619,""e03"":-0.035706087946891788,""e10"":-2.3283064365386965e-10,""e11"":0.9999917149543762,""e12"":-0.004385387059301138,""e13"":0.3549378216266632,""e20"":-0.9999547600746155,""e21"":-0.00004171213004156016,""e22"":-0.009511470794677735,""e23"":0.15301546454429627,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":36,""pIdx"":4}
  108. {""t"":{""e00"":-0.009511590003967286,""e01"":0.0043851882219314579,""e02"":0.9999451041221619,""e03"":-0.06683570146560669,""e10"":0.0,""e11"":0.9999904036521912,""e12"":-0.004385386593639851,""e13"":0.3165920376777649,""e20"":-0.9999547600746155,""e21"":-0.0000417118426412344,""e22"":-0.009511470794677735,""e23"":0.15329691767692567,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":37,""pIdx"":36}
  109. {""t"":{""e00"":-0.009511590003967286,""e01"":0.00438518775627017,""e02"":0.9999451041221619,""e03"":-0.02290000207722187,""e10"":0.0,""e11"":0.9999904036521912,""e12"":-0.004385386593639851,""e13"":0.24943137168884278,""e20"":-0.9999547600746155,""e21"":-0.0000417118426412344,""e22"":-0.009511470794677735,""e23"":0.15285342931747437,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":38,""pIdx"":37}
  110. {""t"":{""e00"":-0.009511590003967286,""e01"":0.004385181702673435,""e02"":0.9999451041221619,""e03"":0.035061296075582507,""e10"":-2.3283064365386965e-10,""e11"":0.9999917149543762,""e12"":-0.004385374952107668,""e13"":0.35463881492614748,""e20"":-0.9999547600746155,""e21"":-0.00004171213004156016,""e22"":-0.009511470794677735,""e23"":0.1523389220237732,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":39,""pIdx"":4}
  111. {""t"":{""e00"":-0.009511590003967286,""e01"":0.0043851761147379879,""e02"":0.9999451041221619,""e03"":0.06585314124822617,""e10"":-2.3283064365386965e-10,""e11"":0.9999904036521912,""e12"":-0.004385374486446381,""e13"":0.31602153182029726,""e20"":-0.9999547600746155,""e21"":-0.0000417118426412344,""e22"":-0.009511470794677735,""e23"":0.1520313322544098,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":40,""pIdx"":39}
  112. {""t"":{""e00"":-0.009511590003967286,""e01"":0.0043851756490767,""e02"":0.9999451041221619,""e03"":0.016906660050153734,""e10"":0.0,""e11"":0.9999904036521912,""e12"":-0.004385374020785093,""e13"":0.24926823377609254,""e20"":-0.9999547600746155,""e21"":-0.000041711609810590744,""e22"":-0.009511470794677735,""e23"":0.1524713635444641,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":41,""pIdx"":40}
  113. {""t"":{""e00"":-0.0474093072116375,""e01"":-0.1206977367401123,""e02"":0.9915567636489868,""e03"":0.04236358776688576,""e10"":-3.725291186640334e-9,""e11"":0.9926728010177612,""e12"":0.12083364278078079,""e13"":0.3311834931373596,""e20"":-0.9988757371902466,""e21"":0.005728639662265778,""e22"":-0.04706193134188652,""e23"":-0.16093911230564118,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":42,""pIdx"":2}
  114. {""t"":{""e00"":-0.010897038504481316,""e01"":-0.03234786540269852,""e02"":0.9994173049926758,""e03"":0.06020510941743851,""e10"":-1.8626448161640497e-9,""e11"":0.999476432800293,""e12"":0.03234979137778282,""e13"":0.2161196768283844,""e20"":-0.9999404549598694,""e21"":0.0003525167121551931,""e22"":-0.010891318321228028,""e23"":-0.08046384155750275,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":43,""pIdx"":42}
  115. {""t"":{""e00"":0.10037016868591309,""e01"":0.12381786108016968,""e02"":0.9872161746025086,""e03"":0.06338051706552506,""e10"":-3.725290298461914e-9,""e11"":0.9922264814376831,""e12"":-0.124446339905262,""e13"":0.08677050471305847,""e20"":-0.9949501156806946,""e21"":0.012490684166550637,""e22"":0.0995899885892868,""e23"":-0.17327861487865449,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":44,""pIdx"":43}
  116. {""t"":{""e00"":0.10037011653184891,""e01"":0.12381783872842789,""e02"":0.9872161746025086,""e03"":0.05114911496639252,""e10"":-3.7252883000604699e-9,""e11"":0.9922263026237488,""e12"":-0.124446339905262,""e13"":-0.007940173149108887,""e20"":-0.9949495792388916,""e21"":0.012490681372582913,""e22"":0.0995899885892868,""e23"":-0.1703803986310959,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":45,""pIdx"":44}
  117. {""t"":{""e00"":0.0719158798456192,""e01"":0.14087340235710145,""e02"":0.9874125123023987,""e03"":-0.04236357659101486,""e10"":7.450582373280668e-9,""e11"":0.9899755120277405,""e12"":-0.14123913645744325,""e13"":0.33118364214897158,""e20"":-0.9974110722541809,""e21"":0.010157346725463868,""e22"":0.07119496166706085,""e23"":-0.16093912720680238,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":46,""pIdx"":2}
  118. {""t"":{""e00"":0.012521684169769287,""e01"":0.01153626013547182,""e02"":0.9998553991317749,""e03"":-0.06452900171279907,""e10"":-4.656612873077393e-10,""e11"":0.9999335408210754,""e12"":-0.011537167243659497,""e13"":0.2165732979774475,""e20"":-0.9999216794967651,""e21"":0.00014446537534240633,""e22"":0.012520852498710156,""e23"":-0.0808926671743393,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":47,""pIdx"":46}
  119. {""t"":{""e00"":-0.10063096880912781,""e01"":-0.1399202197790146,""e02"":0.9850360155105591,""e03"":-0.06485509127378464,""e10"":-7.450578376477779e-9,""e11"":0.9900615811347961,""e12"":0.14063411951065064,""e13"":0.08734381198883057,""e20"":-0.9949235320091248,""e21"":0.014152138493955136,""e22"":-0.09963096678256989,""e23"":-0.1739276647567749,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":48,""pIdx"":47}
  120. {""t"":{""e00"":-0.10063096135854721,""e01"":-0.13992024958133698,""e02"":0.9850364923477173,""e03"":-0.051012326031923297,""e10"":-7.450577932388569e-9,""e11"":0.9900617599487305,""e12"":0.1406341940164566,""e13"":-0.007123708724975586,""e20"":-0.99492347240448,""e21"":0.01415214128792286,""e22"":-0.09963101148605347,""e23"":-0.17041225731372834,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":49,""pIdx"":48}
  121. {""t"":{""e00"":-0.16802315413951875,""e01"":-0.29772090911865237,""e02"":0.9397505521774292,""e03"":6.1435265763520878e-9,""e10"":-1.4901164746561336e-8,""e11"":0.9533032774925232,""e12"":0.30201470851898196,""e13"":0.39260783791542055,""e20"":-0.9857833385467529,""e21"":0.05074542760848999,""e22"":-0.16017703711986543,""e23"":-0.16848251223564149,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":50,""pIdx"":2}
  122. {""t"":{""e00"":-0.06370317935943604,""e01"":-0.33597519993782046,""e02"":0.9397143125534058,""e03"":-0.000003875705260725226,""e10"":-2.9802322387695315e-8,""e11"":0.9416264891624451,""e12"":0.3366590440273285,""e13"":0.34287920594215395,""e20"":-0.9979690313339233,""e21"":0.02144618146121502,""e22"":-0.05998469144105911,""e23"":-0.26227137446403506,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":51,""pIdx"":50}
  123. {""t"":{""e00"":-0.06370317190885544,""e01"":-0.3359752297401428,""e02"":0.9397144317626953,""e03"":-0.00000434078401667648,""e10"":-2.9802318834981635e-8,""e11"":0.9416266083717346,""e12"":0.33665910363197329,""e13"":0.32425931096076968,""e20"":-0.9979689121246338,""e21"":0.02144618332386017,""e22"":-0.05998469889163971,""e23"":-0.3667825162410736,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":52,""pIdx"":51}
  124. {""t"":{""e00"":-0.06370317935943604,""e01"":-0.3359752297401428,""e02"":0.9397141933441162,""e03"":0.0024889586493372919,""e10"":-2.9802322387695315e-8,""e11"":0.9416266083717346,""e12"":0.3366590142250061,""e13"":0.30017104744911196,""e20"":-0.9979690313339233,""e21"":0.02144618332386017,""e22"":-0.059984683990478519,""e23"":-0.5071608424186707,""e30"":0.0,""e31"":0.0,""e32"":0.0,""e33"":1.0},""idx"":53,""pIdx"":52}";
  125. #endregion
  126. /// <summary>
  127. /// Draws a human skeleton.
  128. /// </summary>
  129. /// <param name="point">Point.</param>
  130. /// <param name="rotation">Rotation.</param>
  131. /// <param name="scale">Scale.</param>
  132. /// <param name="color">Color.</param>
  133. internal static void DrawHumanSkeletonLine (Vector3 point, Quaternion rotation, Vector3 scale, Color color)
  134. {
  135. if(humanBonesTransformData.Count == 0)
  136. {
  137. StringReader strRead = new StringReader( humanBonesArrayTransform );
  138. string line = null;
  139. humanBonesTransformData.Clear();
  140. do
  141. {
  142. line = strRead.ReadLine ();
  143. if(string.IsNullOrEmpty (line))
  144. {
  145. break;
  146. }
  147. humanBonesTransformData.Add(JsonUtility.FromJson<serializeTransform>(line));
  148. }
  149. while (line != null);
  150. }
  151. Matrix4x4 rootT = Matrix4x4.TRS (point, rotation, scale);
  152. for(int i=0; i < humanBonesTransformData.Count; i++)
  153. {
  154. var humanBoneTransform = humanBonesTransformData[i];
  155. Matrix4x4 boneT = humanBoneTransform.t;
  156. boneT.m00 = scale.x;//scale.x
  157. boneT.m11 = scale.y;//scale.y
  158. boneT.m22 = scale.z;//scale.z
  159. Vector3 p = (rootT * boneT).MultiplyPoint (Vector3.zero);
  160. UltiDraw.DrawWireSphere (p, Quaternion.identity, 0.05f, color);
  161. if(humanBonesTransformData[i].pIdx >= 0)
  162. {
  163. var humanBoneParentTransform = humanBonesTransformData[humanBoneTransform.pIdx];
  164. Matrix4x4 parentBoneT = humanBoneParentTransform.t;
  165. parentBoneT.m00 = scale.x;//scale.x
  166. parentBoneT.m11 = scale.y;//scale.y
  167. parentBoneT.m22 = scale.z;//scale.z
  168. Vector3 p2 = (rootT * parentBoneT).MultiplyPoint (Vector3.zero);
  169. UltiDraw.DrawLine (p, p2, color);
  170. }
  171. }
  172. }
  173. /// <summary>
  174. /// Draws the mesh wire frame.
  175. /// </summary>
  176. /// <param name="point">Point.</param>
  177. /// <param name="rotation">Rotation.</param>
  178. /// <param name="scale">Scale.</param>
  179. /// <param name="mesh">Mesh.</param>
  180. /// <param name="color">Color.</param>
  181. internal static void DrawMeshWireFrame (Vector3 point, Quaternion rotation, Vector3 scale, Mesh mesh, Color color)
  182. {
  183. Matrix4x4 world = Matrix4x4.TRS(point, rotation, scale);
  184. int[] tris = mesh.triangles;
  185. Vector3[] points = mesh.vertices;
  186. int triCount = tris.Length / 3;
  187. for (int tri = 0; tri < triCount; tri++)
  188. {
  189. Vector3 v1 = world.MultiplyPoint3x4 (points[tris[tri * 3]]);
  190. Vector3 v2 = world.MultiplyPoint3x4 (points[tris[tri * 3 + 1]]);
  191. Vector3 v3 = world.MultiplyPoint3x4 (points[tris[tri * 3 + 2]]);
  192. //UltiDraw.DrawLine(v1, v2, color);
  193. //UltiDraw.DrawLine(v2, v3, color);
  194. //UltiDraw.DrawLine(v3, v1, color);
  195. UltiDraw.DrawTriangleWire(v1, v2, v3, color);
  196. }
  197. }
  198. /// <summary>
  199. /// Draws a human skeleton.
  200. /// </summary>
  201. /// <param name="point">Point.</param>
  202. /// <param name="rotation">Rotation.</param>
  203. /// <param name="scale">Scale.</param>
  204. /// <param name="color">Color.</param>
  205. internal static void DrawHumanSkeleton (Vector3 point, Quaternion rotation, Vector3 scale, Color color)
  206. {
  207. if(humanBonesTransformData.Count == 0)
  208. {
  209. StringReader strRead = new StringReader( humanBonesArrayTransform );
  210. string line = null;
  211. humanBonesTransformData.Clear();
  212. do
  213. {
  214. line = strRead.ReadLine ();
  215. if(string.IsNullOrEmpty (line))
  216. {
  217. break;
  218. }
  219. humanBonesTransformData.Add(JsonUtility.FromJson<serializeTransform>(line));
  220. }
  221. while (line != null);
  222. }
  223. Matrix4x4 rootT = Matrix4x4.TRS (point, rotation, scale);
  224. for(int i=0; i < humanBonesTransformData.Count; i++)
  225. {
  226. var humanBoneTransform = humanBonesTransformData[i];
  227. Matrix4x4 boneT = humanBoneTransform.t;
  228. boneT.m00 = scale.x;//scale.x
  229. boneT.m11 = scale.y;//scale.y
  230. boneT.m22 = scale.z;//scale.z
  231. Vector3 p = (rootT * boneT).MultiplyPoint (Vector3.zero);
  232. UltiDraw.DrawWireSphere (p, Quaternion.identity, 0.05f, color);
  233. if(humanBonesTransformData[i].pIdx >= 0)
  234. {
  235. var humanBoneParentTransform = humanBonesTransformData[humanBoneTransform.pIdx];
  236. Matrix4x4 parentBoneT = humanBoneParentTransform.t;
  237. parentBoneT.m00 = scale.x;//scale.x
  238. parentBoneT.m11 = scale.y;//scale.y
  239. parentBoneT.m22 = scale.z;//scale.z
  240. Vector3 p2 = (rootT * parentBoneT).MultiplyPoint (Vector3.zero);
  241. Vector3 vect = p2 - p;
  242. Quaternion boneFwd = Quaternion.identity;
  243. if(vect != Vector3.zero)
  244. {
  245. boneFwd = Quaternion.LookRotation(vect);
  246. }
  247. UltiDraw.DrawBone (p, boneFwd, scale.x/8, vect.magnitude, color);
  248. }
  249. }
  250. }
  251. /// <summary>
  252. /// Draws a dog skeleton line.
  253. /// </summary>
  254. /// <param name="point">Point.</param>
  255. /// <param name="rotation">Rotation.</param>
  256. /// <param name="scale">Scale.</param>
  257. /// <param name="color">Color.</param>
  258. internal static void DrawDogSkeletonLine (Vector3 point, Quaternion rotation, Vector3 scale, Color color)
  259. {
  260. if(dogBoneTransformData.Count == 0)
  261. {
  262. StringReader strRead = new StringReader(dogBonesArrayTransform);
  263. string line = null;
  264. dogBoneTransformData.Clear();
  265. do
  266. {
  267. line = strRead.ReadLine ();
  268. if(string.IsNullOrEmpty (line))
  269. {
  270. break;
  271. }
  272. dogBoneTransformData.Add(JsonUtility.FromJson<serializeTransform>(line));
  273. }
  274. while (line != null);
  275. }
  276. Matrix4x4 rootT = Matrix4x4.TRS (point, rotation, scale);
  277. for(int i=0; i < dogBoneTransformData.Count; i++)
  278. {
  279. var dogBoneTransform = dogBoneTransformData[i];
  280. Matrix4x4 boneT = dogBoneTransform.t;
  281. boneT.m00 = scale.x;//scale.x
  282. boneT.m11 = scale.y;//scale.y
  283. boneT.m22 = scale.z;//scale.z
  284. Vector3 p = (rootT * boneT).MultiplyPoint (Vector3.zero);
  285. UltiDraw.DrawWireSphere (p, Quaternion.identity, 0.05f, color);
  286. if(dogBoneTransform.pIdx >= 0)
  287. {
  288. var dogBoneParentTransform = dogBoneTransformData[dogBoneTransform.pIdx];
  289. Matrix4x4 parentBoneT = dogBoneParentTransform.t;
  290. parentBoneT.m00 = scale.x;//scale.x
  291. parentBoneT.m11 = scale.y;//scale.y
  292. parentBoneT.m22 = scale.z;//scale.z
  293. Vector3 p2 = (rootT * parentBoneT).MultiplyPoint (Vector3.zero);
  294. UltiDraw.DrawLine (p, p2, color);
  295. }
  296. }
  297. }
  298. /// <summary>
  299. /// Draws a dog skeleton.
  300. /// </summary>
  301. /// <param name="point">Point.</param>
  302. /// <param name="rotation">Rotation.</param>
  303. /// <param name="scale">Scale.</param>
  304. /// <param name="color">Color.</param>
  305. internal static void DrawDogSkeleton (Vector3 point, Quaternion rotation, Vector3 scale, Color color)
  306. {
  307. if(dogBoneTransformData.Count == 0)
  308. {
  309. StringReader strRead = new StringReader(dogBonesArrayTransform);
  310. string line = null;
  311. dogBoneTransformData.Clear();
  312. do
  313. {
  314. line = strRead.ReadLine ();
  315. if(string.IsNullOrEmpty (line))
  316. {
  317. break;
  318. }
  319. dogBoneTransformData.Add(JsonUtility.FromJson<serializeTransform>(line));
  320. }
  321. while (line != null);
  322. }
  323. Matrix4x4 rootT = Matrix4x4.TRS (point, rotation, scale);
  324. for(int i=0; i < dogBoneTransformData.Count; i++)
  325. {
  326. var dogBoneTransform = dogBoneTransformData[i];
  327. Matrix4x4 boneT = dogBoneTransform.t;
  328. boneT.m00 = scale.x;//scale.x
  329. boneT.m11 = scale.y;//scale.y
  330. boneT.m22 = scale.z;//scale.z
  331. Vector3 p = (rootT * boneT).MultiplyPoint (Vector3.zero);
  332. UltiDraw.DrawWireSphere (p, Quaternion.identity, 0.05f, color);
  333. if(dogBoneTransform.pIdx >= 0)
  334. {
  335. var dogBoneParentTransform = dogBoneTransformData[dogBoneTransform.pIdx];
  336. Matrix4x4 parentBoneT = dogBoneParentTransform.t;
  337. parentBoneT.m00 = scale.x;//scale.x
  338. parentBoneT.m11 = scale.y;//scale.y
  339. parentBoneT.m22 = scale.z;//scale.z
  340. Vector3 p2 = (rootT * parentBoneT).MultiplyPoint (Vector3.zero);
  341. Vector3 vect = p2 - p;
  342. Quaternion boneFwd = Quaternion.identity;
  343. if(vect != Vector3.zero)
  344. {
  345. boneFwd = Quaternion.LookRotation(vect);
  346. }
  347. UltiDraw.DrawBone (p, boneFwd, scale.x/8, vect.magnitude, color);
  348. }
  349. }
  350. }
  351. }
  352. }