AMBinaryRotation.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using UnityEngine;
  5. public class AMBinaryRotation : AMBinaryDataBaseObject
  6. {
  7. public static bool CheckType(AMTrack track)
  8. {
  9. return !(track == null) && track.getTrackType() == AMBinaryRotation.kTypeName;
  10. }
  11. public override void Update(int frame)
  12. {
  13. this.trans_.rotation = this.quaternion_array[frame];
  14. }
  15. public override void Write(BinaryWriter binary)
  16. {
  17. List<KeyValuePair<int, int>> list;
  18. Quaternion[] array = base.Compression<Quaternion>(ref this.quaternion_array, out list);
  19. base.Write(binary);
  20. for (int i = 0; i < this.quaternion_array.Length; i++)
  21. {
  22. binary.Write(this.quaternion_array[i].x);
  23. binary.Write(this.quaternion_array[i].y);
  24. binary.Write(this.quaternion_array[i].z);
  25. binary.Write(this.quaternion_array[i].w);
  26. }
  27. }
  28. public override void Read(BinaryReader binary)
  29. {
  30. base.Read(binary);
  31. this.quaternion_array = new Quaternion[this.total_frame];
  32. for (int i = 0; i < this.quaternion_array.Length; i++)
  33. {
  34. Quaternion quaternion = default(Quaternion);
  35. quaternion.x = binary.ReadSingle();
  36. quaternion.y = binary.ReadSingle();
  37. quaternion.z = binary.ReadSingle();
  38. quaternion.w = binary.ReadSingle();
  39. this.quaternion_array[i] = quaternion;
  40. }
  41. this.trans_ = base.obj.transform;
  42. }
  43. public override void SetGameObject(GameObject new_obj)
  44. {
  45. base.obj = new_obj;
  46. this.trans_ = base.obj.transform;
  47. }
  48. public override string type_name
  49. {
  50. get
  51. {
  52. return AMBinaryRotation.kTypeName;
  53. }
  54. }
  55. public static string kTypeName = "Rotation";
  56. public Transform trans_;
  57. public Quaternion[] quaternion_array;
  58. }