GLTFNode.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using System.Collections.Generic;
  2. using System.Runtime.Serialization;
  3. namespace GLTFExport.Entities
  4. {
  5. [DataContract]
  6. public class GLTFNode : GLTFIndexedChildRootProperty
  7. {
  8. [DataMember(EmitDefaultValue = false)]
  9. public int? camera { get; set; }
  10. [DataMember(EmitDefaultValue = false)]
  11. public int[] children { get; set; }
  12. [DataMember(EmitDefaultValue = false)]
  13. public int? skin { get; set; }
  14. // Either matrix or Translation+Rotation+Scale
  15. //[DataMember]
  16. //public float[] matrix { get; set; }
  17. [DataMember(EmitDefaultValue = false)]
  18. public int? mesh { get; set; }
  19. [DataMember(IsRequired = true)]
  20. public float[] translation { get; set; }
  21. [DataMember(IsRequired = true)]
  22. public float[] rotation { get; set; }
  23. [DataMember(IsRequired = true)]
  24. public float[] scale { get; set; }
  25. [DataMember(EmitDefaultValue = false)]
  26. public float[] weights { get; set; }
  27. public List<int> ChildrenList { get; private set; }
  28. // Used to compute transform world matrix
  29. public GLTFNode parent;
  30. public GLTFNode()
  31. {
  32. ChildrenList = new List<int>();
  33. }
  34. public void Prepare()
  35. {
  36. // Do not export empty arrays
  37. if (ChildrenList.Count > 0)
  38. {
  39. children = ChildrenList.ToArray();
  40. }
  41. }
  42. }
  43. }