2
0

@EditSkeleton.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /******************************************************************************/
  2. /******************************************************************************/
  3. class EditSkeleton
  4. {
  5. class Node // node as imported from FBX, this is set only one time during import
  6. {
  7. Str name; // original node name as imported from FBX (can be an empty string)
  8. int parent; // parent node index, -1=none
  9. OrientP orient_pos; // as imported from FBX
  10. uint memUsage()C;
  11. bool save(File &f)C;
  12. bool load(File &f);
  13. bool loadOld(File &f);
  14. public:
  15. Node();
  16. };
  17. class Bone : Mems<IndexWeight> // links 1 'SkelBone' -> multiple 'Node'
  18. {
  19. Str8 name; // 'SkelBone' name
  20. uint memUsage()C;
  21. void init(C Str &name, int node);
  22. void addWeight(int index, flt weight);
  23. int mainNode()C; // get the first node with highest weight
  24. bool save(File &f)C;
  25. bool load(File &f);
  26. bool loadOld(File &f);
  27. };
  28. int root; // root node index, -1=none
  29. Mems<Node> nodes;
  30. Mems<Bone> bones; // links 'SkelBone' -> 'Node'
  31. uint memUsage()C;
  32. void del();
  33. void create(C Skeleton &skel, C MemPtr<Str> &node_names=null);
  34. void set(Skeleton &skel)C;
  35. enum MAPPING
  36. {
  37. KEEP ,
  38. BONE_NAME_IS_NODE_INDEX,
  39. BONE_NAME_IS_NODE_NAME ,
  40. };
  41. void set(Mems<Mems<IndexWeight> > &weights, C Skeleton &old_skel, C Skeleton &new_skel, MAPPING mapping)C;
  42. Str nodeUID(int i)C; // unique string identifying a node !! needs to be the same as 'Import.nodeUID' !!
  43. bool rootZero()C;
  44. bool hasNode (C Str &name);
  45. Node* findNode (C Str &name);
  46. C Node* findNode (C Str &name)C;
  47. int findNodeI(C Str &name, C Str&path=S)C;
  48. int findBoneI(C Str &name)C;
  49. Bone* findBone (C Str &name);
  50. C Bone* findBone (C Str &name)C;
  51. void removeBone (C Str &name);
  52. void renameBone (C Str &old_name, C Str&new_name);
  53. int nodeToBone(int node_i)C; // will return only direct mapping (if 1 weight and 1 bone link) only
  54. int boneToNode(int bone_i)C; // find the first node with highest weight
  55. int boneToNode(C Str &name)C; // find the first node with highest weight
  56. Bone* getBone(C Str &name);
  57. void animate(C AnimSkel &anim_skel, C MemPtrN<Matrix, 256> &matrixes);
  58. class NodePtr
  59. {
  60. bool is; // have to use 'is' instead of doing "name.is() ? " because names are allowed to be empty
  61. Str name;
  62. void set(int node_i, C EditSkeleton &skel);
  63. public:
  64. NodePtr();
  65. };
  66. void add(C EditSkeleton &src_skel, bool replace); // assumes that 'bones' names are unique in both skeletons, but 'nodes' names can overlap
  67. // io
  68. bool save(File &f)C;
  69. bool load(File &f);
  70. bool load(C Str &name);
  71. private:
  72. class Bone0
  73. {
  74. Str8 original_name, dest_name, // 'original_name'=as imported from FBX (can be an empty string), 'dest_name'=as renamed to a custom bone
  75. parent_original_name; // 'parent_original_name'=parent name as imported from FBX
  76. OrientP orient_pos;
  77. bool load(File &f);
  78. };
  79. public:
  80. EditSkeleton();
  81. };
  82. /******************************************************************************/
  83. /******************************************************************************/
  84. /******************************************************************************/