skeleton_profile.cpp 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850
  1. /**************************************************************************/
  2. /* skeleton_profile.cpp */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /**************************************************************************/
  30. #include "skeleton_profile.h"
  31. bool SkeletonProfile::_set(const StringName &p_path, const Variant &p_value) {
  32. ERR_FAIL_COND_V(is_read_only, false);
  33. String path = p_path;
  34. if (path.begins_with("groups/")) {
  35. int which = path.get_slicec('/', 1).to_int();
  36. String what = path.get_slicec('/', 2);
  37. ERR_FAIL_INDEX_V(which, groups.size(), false);
  38. if (what == "group_name") {
  39. set_group_name(which, p_value);
  40. } else if (what == "texture") {
  41. set_texture(which, p_value);
  42. } else {
  43. return false;
  44. }
  45. }
  46. if (path.begins_with("bones/")) {
  47. int which = path.get_slicec('/', 1).to_int();
  48. String what = path.get_slicec('/', 2);
  49. ERR_FAIL_INDEX_V(which, bones.size(), false);
  50. if (what == "bone_name") {
  51. set_bone_name(which, p_value);
  52. } else if (what == "bone_parent") {
  53. set_bone_parent(which, p_value);
  54. } else if (what == "tail_direction") {
  55. set_tail_direction(which, static_cast<TailDirection>((int)p_value));
  56. } else if (what == "bone_tail") {
  57. set_bone_tail(which, p_value);
  58. } else if (what == "reference_pose") {
  59. set_reference_pose(which, p_value);
  60. } else if (what == "handle_offset") {
  61. set_handle_offset(which, p_value);
  62. } else if (what == "group") {
  63. set_group(which, p_value);
  64. } else if (what == "require") {
  65. set_required(which, p_value);
  66. } else {
  67. return false;
  68. }
  69. }
  70. return true;
  71. }
  72. bool SkeletonProfile::_get(const StringName &p_path, Variant &r_ret) const {
  73. String path = p_path;
  74. if (path.begins_with("groups/")) {
  75. int which = path.get_slicec('/', 1).to_int();
  76. String what = path.get_slicec('/', 2);
  77. ERR_FAIL_INDEX_V(which, groups.size(), false);
  78. if (what == "group_name") {
  79. r_ret = get_group_name(which);
  80. } else if (what == "texture") {
  81. r_ret = get_texture(which);
  82. } else {
  83. return false;
  84. }
  85. }
  86. if (path.begins_with("bones/")) {
  87. int which = path.get_slicec('/', 1).to_int();
  88. String what = path.get_slicec('/', 2);
  89. ERR_FAIL_INDEX_V(which, bones.size(), false);
  90. if (what == "bone_name") {
  91. r_ret = get_bone_name(which);
  92. } else if (what == "bone_parent") {
  93. r_ret = get_bone_parent(which);
  94. } else if (what == "tail_direction") {
  95. r_ret = get_tail_direction(which);
  96. } else if (what == "bone_tail") {
  97. r_ret = get_bone_tail(which);
  98. } else if (what == "reference_pose") {
  99. r_ret = get_reference_pose(which);
  100. } else if (what == "handle_offset") {
  101. r_ret = get_handle_offset(which);
  102. } else if (what == "group") {
  103. r_ret = get_group(which);
  104. } else if (what == "require") {
  105. r_ret = is_required(which);
  106. } else {
  107. return false;
  108. }
  109. }
  110. return true;
  111. }
  112. void SkeletonProfile::_validate_property(PropertyInfo &p_property) const {
  113. if (is_read_only) {
  114. if (p_property.name == ("group_size") || p_property.name == ("bone_size") || p_property.name == ("root_bone") || p_property.name == ("scale_base_bone")) {
  115. p_property.usage = PROPERTY_USAGE_NO_EDITOR;
  116. return;
  117. }
  118. }
  119. if (p_property.name == ("root_bone") || p_property.name == ("scale_base_bone")) {
  120. String hint = "";
  121. for (int i = 0; i < bones.size(); i++) {
  122. if (i > 0) {
  123. hint += ",";
  124. }
  125. hint += String(bones[i].bone_name);
  126. }
  127. p_property.hint_string = hint;
  128. }
  129. PackedStringArray split = p_property.name.split("/");
  130. if (split.size() == 3 && split[0] == "bones") {
  131. if (split[2] == "bone_tail" && get_tail_direction(split[1].to_int()) != TAIL_DIRECTION_SPECIFIC_CHILD) {
  132. p_property.usage = PROPERTY_USAGE_NONE;
  133. }
  134. }
  135. }
  136. void SkeletonProfile::_get_property_list(List<PropertyInfo> *p_list) const {
  137. if (is_read_only) {
  138. return;
  139. }
  140. String group_names = "";
  141. for (int i = 0; i < groups.size(); i++) {
  142. String path = "groups/" + itos(i) + "/";
  143. p_list->push_back(PropertyInfo(Variant::STRING_NAME, path + "group_name"));
  144. p_list->push_back(PropertyInfo(Variant::OBJECT, path + "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"));
  145. if (i > 0) {
  146. group_names = group_names + ",";
  147. }
  148. group_names = group_names + groups[i].group_name;
  149. }
  150. for (int i = 0; i < bones.size(); i++) {
  151. String path = "bones/" + itos(i) + "/";
  152. p_list->push_back(PropertyInfo(Variant::STRING_NAME, path + "bone_name"));
  153. p_list->push_back(PropertyInfo(Variant::STRING_NAME, path + "bone_parent"));
  154. p_list->push_back(PropertyInfo(Variant::INT, path + "tail_direction", PROPERTY_HINT_ENUM, "AverageChildren,SpecificChild,End"));
  155. p_list->push_back(PropertyInfo(Variant::STRING_NAME, path + "bone_tail"));
  156. p_list->push_back(PropertyInfo(Variant::TRANSFORM3D, path + "reference_pose"));
  157. p_list->push_back(PropertyInfo(Variant::VECTOR2, path + "handle_offset"));
  158. p_list->push_back(PropertyInfo(Variant::STRING_NAME, path + "group", PROPERTY_HINT_ENUM, group_names));
  159. p_list->push_back(PropertyInfo(Variant::BOOL, path + "require"));
  160. }
  161. for (PropertyInfo &E : *p_list) {
  162. _validate_property(E);
  163. }
  164. }
  165. StringName SkeletonProfile::get_root_bone() {
  166. return root_bone;
  167. }
  168. void SkeletonProfile::set_root_bone(const StringName &p_bone_name) {
  169. if (is_read_only) {
  170. return;
  171. }
  172. root_bone = p_bone_name;
  173. }
  174. StringName SkeletonProfile::get_scale_base_bone() {
  175. return scale_base_bone;
  176. }
  177. void SkeletonProfile::set_scale_base_bone(const StringName &p_bone_name) {
  178. if (is_read_only) {
  179. return;
  180. }
  181. scale_base_bone = p_bone_name;
  182. }
  183. int SkeletonProfile::get_group_size() {
  184. return groups.size();
  185. }
  186. void SkeletonProfile::set_group_size(int p_size) {
  187. if (is_read_only) {
  188. return;
  189. }
  190. ERR_FAIL_COND(p_size < 0);
  191. groups.resize(p_size);
  192. emit_signal("profile_updated");
  193. notify_property_list_changed();
  194. }
  195. StringName SkeletonProfile::get_group_name(int p_group_idx) const {
  196. ERR_FAIL_INDEX_V(p_group_idx, groups.size(), StringName());
  197. return groups[p_group_idx].group_name;
  198. }
  199. void SkeletonProfile::set_group_name(int p_group_idx, const StringName &p_group_name) {
  200. if (is_read_only) {
  201. return;
  202. }
  203. ERR_FAIL_INDEX(p_group_idx, groups.size());
  204. groups.write[p_group_idx].group_name = p_group_name;
  205. emit_signal("profile_updated");
  206. }
  207. Ref<Texture2D> SkeletonProfile::get_texture(int p_group_idx) const {
  208. ERR_FAIL_INDEX_V(p_group_idx, groups.size(), Ref<Texture2D>());
  209. return groups[p_group_idx].texture;
  210. }
  211. void SkeletonProfile::set_texture(int p_group_idx, const Ref<Texture2D> &p_texture) {
  212. if (is_read_only) {
  213. return;
  214. }
  215. ERR_FAIL_INDEX(p_group_idx, groups.size());
  216. groups.write[p_group_idx].texture = p_texture;
  217. emit_signal("profile_updated");
  218. }
  219. int SkeletonProfile::get_bone_size() {
  220. return bones.size();
  221. }
  222. void SkeletonProfile::set_bone_size(int p_size) {
  223. if (is_read_only) {
  224. return;
  225. }
  226. ERR_FAIL_COND(p_size < 0);
  227. bones.resize(p_size);
  228. emit_signal("profile_updated");
  229. notify_property_list_changed();
  230. }
  231. int SkeletonProfile::find_bone(const StringName &p_bone_name) const {
  232. if (p_bone_name == StringName()) {
  233. return -1;
  234. }
  235. for (int i = 0; i < bones.size(); i++) {
  236. if (bones[i].bone_name == p_bone_name) {
  237. return i;
  238. }
  239. }
  240. return -1;
  241. }
  242. PackedStringArray SkeletonProfile::get_bone_names() {
  243. PackedStringArray s;
  244. for (const SkeletonProfileBone &bone : bones) {
  245. s.push_back(bone.bone_name);
  246. }
  247. return s;
  248. }
  249. StringName SkeletonProfile::get_bone_name(int p_bone_idx) const {
  250. ERR_FAIL_INDEX_V(p_bone_idx, bones.size(), StringName());
  251. return bones[p_bone_idx].bone_name;
  252. }
  253. void SkeletonProfile::set_bone_name(int p_bone_idx, const StringName &p_bone_name) {
  254. if (is_read_only) {
  255. return;
  256. }
  257. ERR_FAIL_INDEX(p_bone_idx, bones.size());
  258. bones.write[p_bone_idx].bone_name = p_bone_name;
  259. emit_signal("profile_updated");
  260. }
  261. StringName SkeletonProfile::get_bone_parent(int p_bone_idx) const {
  262. ERR_FAIL_INDEX_V(p_bone_idx, bones.size(), StringName());
  263. return bones[p_bone_idx].bone_parent;
  264. }
  265. void SkeletonProfile::set_bone_parent(int p_bone_idx, const StringName &p_bone_parent) {
  266. if (is_read_only) {
  267. return;
  268. }
  269. ERR_FAIL_INDEX(p_bone_idx, bones.size());
  270. bones.write[p_bone_idx].bone_parent = p_bone_parent;
  271. emit_signal("profile_updated");
  272. }
  273. SkeletonProfile::TailDirection SkeletonProfile::get_tail_direction(int p_bone_idx) const {
  274. ERR_FAIL_INDEX_V(p_bone_idx, bones.size(), TAIL_DIRECTION_AVERAGE_CHILDREN);
  275. return bones[p_bone_idx].tail_direction;
  276. }
  277. void SkeletonProfile::set_tail_direction(int p_bone_idx, TailDirection p_tail_direction) {
  278. if (is_read_only) {
  279. return;
  280. }
  281. ERR_FAIL_INDEX(p_bone_idx, bones.size());
  282. bones.write[p_bone_idx].tail_direction = p_tail_direction;
  283. emit_signal("profile_updated");
  284. notify_property_list_changed();
  285. }
  286. StringName SkeletonProfile::get_bone_tail(int p_bone_idx) const {
  287. ERR_FAIL_INDEX_V(p_bone_idx, bones.size(), StringName());
  288. return bones[p_bone_idx].bone_tail;
  289. }
  290. void SkeletonProfile::set_bone_tail(int p_bone_idx, const StringName &p_bone_tail) {
  291. if (is_read_only) {
  292. return;
  293. }
  294. ERR_FAIL_INDEX(p_bone_idx, bones.size());
  295. bones.write[p_bone_idx].bone_tail = p_bone_tail;
  296. emit_signal("profile_updated");
  297. }
  298. Transform3D SkeletonProfile::get_reference_pose(int p_bone_idx) const {
  299. ERR_FAIL_INDEX_V(p_bone_idx, bones.size(), Transform3D());
  300. return bones[p_bone_idx].reference_pose;
  301. }
  302. void SkeletonProfile::set_reference_pose(int p_bone_idx, const Transform3D &p_reference_pose) {
  303. if (is_read_only) {
  304. return;
  305. }
  306. ERR_FAIL_INDEX(p_bone_idx, bones.size());
  307. bones.write[p_bone_idx].reference_pose = p_reference_pose;
  308. emit_signal("profile_updated");
  309. }
  310. Vector2 SkeletonProfile::get_handle_offset(int p_bone_idx) const {
  311. ERR_FAIL_INDEX_V(p_bone_idx, bones.size(), Vector2());
  312. return bones[p_bone_idx].handle_offset;
  313. }
  314. void SkeletonProfile::set_handle_offset(int p_bone_idx, const Vector2 &p_handle_offset) {
  315. if (is_read_only) {
  316. return;
  317. }
  318. ERR_FAIL_INDEX(p_bone_idx, bones.size());
  319. bones.write[p_bone_idx].handle_offset = p_handle_offset;
  320. emit_signal("profile_updated");
  321. }
  322. StringName SkeletonProfile::get_group(int p_bone_idx) const {
  323. ERR_FAIL_INDEX_V(p_bone_idx, bones.size(), StringName());
  324. return bones[p_bone_idx].group;
  325. }
  326. void SkeletonProfile::set_group(int p_bone_idx, const StringName &p_group) {
  327. if (is_read_only) {
  328. return;
  329. }
  330. ERR_FAIL_INDEX(p_bone_idx, bones.size());
  331. bones.write[p_bone_idx].group = p_group;
  332. emit_signal("profile_updated");
  333. }
  334. bool SkeletonProfile::is_required(int p_bone_idx) const {
  335. ERR_FAIL_INDEX_V(p_bone_idx, bones.size(), false);
  336. return bones[p_bone_idx].required;
  337. }
  338. void SkeletonProfile::set_required(int p_bone_idx, bool p_required) {
  339. if (is_read_only) {
  340. return;
  341. }
  342. ERR_FAIL_INDEX(p_bone_idx, bones.size());
  343. bones.write[p_bone_idx].required = p_required;
  344. emit_signal("profile_updated");
  345. }
  346. bool SkeletonProfile::has_bone(const StringName &p_bone_name) {
  347. bool is_found = false;
  348. for (int i = 0; i < bones.size(); i++) {
  349. if (bones[i].bone_name == p_bone_name) {
  350. is_found = true;
  351. break;
  352. }
  353. }
  354. return is_found;
  355. }
  356. void SkeletonProfile::_bind_methods() {
  357. ClassDB::bind_method(D_METHOD("set_root_bone", "bone_name"), &SkeletonProfile::set_root_bone);
  358. ClassDB::bind_method(D_METHOD("get_root_bone"), &SkeletonProfile::get_root_bone);
  359. ClassDB::bind_method(D_METHOD("set_scale_base_bone", "bone_name"), &SkeletonProfile::set_scale_base_bone);
  360. ClassDB::bind_method(D_METHOD("get_scale_base_bone"), &SkeletonProfile::get_scale_base_bone);
  361. ClassDB::bind_method(D_METHOD("set_group_size", "size"), &SkeletonProfile::set_group_size);
  362. ClassDB::bind_method(D_METHOD("get_group_size"), &SkeletonProfile::get_group_size);
  363. ClassDB::bind_method(D_METHOD("get_group_name", "group_idx"), &SkeletonProfile::get_group_name);
  364. ClassDB::bind_method(D_METHOD("set_group_name", "group_idx", "group_name"), &SkeletonProfile::set_group_name);
  365. ClassDB::bind_method(D_METHOD("get_texture", "group_idx"), &SkeletonProfile::get_texture);
  366. ClassDB::bind_method(D_METHOD("set_texture", "group_idx", "texture"), &SkeletonProfile::set_texture);
  367. ClassDB::bind_method(D_METHOD("set_bone_size", "size"), &SkeletonProfile::set_bone_size);
  368. ClassDB::bind_method(D_METHOD("get_bone_size"), &SkeletonProfile::get_bone_size);
  369. ClassDB::bind_method(D_METHOD("find_bone", "bone_name"), &SkeletonProfile::find_bone);
  370. ClassDB::bind_method(D_METHOD("get_bone_name", "bone_idx"), &SkeletonProfile::get_bone_name);
  371. ClassDB::bind_method(D_METHOD("set_bone_name", "bone_idx", "bone_name"), &SkeletonProfile::set_bone_name);
  372. ClassDB::bind_method(D_METHOD("get_bone_parent", "bone_idx"), &SkeletonProfile::get_bone_parent);
  373. ClassDB::bind_method(D_METHOD("set_bone_parent", "bone_idx", "bone_parent"), &SkeletonProfile::set_bone_parent);
  374. ClassDB::bind_method(D_METHOD("get_tail_direction", "bone_idx"), &SkeletonProfile::get_tail_direction);
  375. ClassDB::bind_method(D_METHOD("set_tail_direction", "bone_idx", "tail_direction"), &SkeletonProfile::set_tail_direction);
  376. ClassDB::bind_method(D_METHOD("get_bone_tail", "bone_idx"), &SkeletonProfile::get_bone_tail);
  377. ClassDB::bind_method(D_METHOD("set_bone_tail", "bone_idx", "bone_tail"), &SkeletonProfile::set_bone_tail);
  378. ClassDB::bind_method(D_METHOD("get_reference_pose", "bone_idx"), &SkeletonProfile::get_reference_pose);
  379. ClassDB::bind_method(D_METHOD("set_reference_pose", "bone_idx", "bone_name"), &SkeletonProfile::set_reference_pose);
  380. ClassDB::bind_method(D_METHOD("get_handle_offset", "bone_idx"), &SkeletonProfile::get_handle_offset);
  381. ClassDB::bind_method(D_METHOD("set_handle_offset", "bone_idx", "handle_offset"), &SkeletonProfile::set_handle_offset);
  382. ClassDB::bind_method(D_METHOD("get_group", "bone_idx"), &SkeletonProfile::get_group);
  383. ClassDB::bind_method(D_METHOD("set_group", "bone_idx", "group"), &SkeletonProfile::set_group);
  384. ClassDB::bind_method(D_METHOD("is_required", "bone_idx"), &SkeletonProfile::is_required);
  385. ClassDB::bind_method(D_METHOD("set_required", "bone_idx", "required"), &SkeletonProfile::set_required);
  386. ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "root_bone", PROPERTY_HINT_ENUM_SUGGESTION, ""), "set_root_bone", "get_root_bone");
  387. ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "scale_base_bone", PROPERTY_HINT_ENUM_SUGGESTION, ""), "set_scale_base_bone", "get_scale_base_bone");
  388. ADD_PROPERTY(PropertyInfo(Variant::INT, "group_size", PROPERTY_HINT_RANGE, "0,100,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_ARRAY, "Groups,groups/"), "set_group_size", "get_group_size");
  389. ADD_PROPERTY(PropertyInfo(Variant::INT, "bone_size", PROPERTY_HINT_RANGE, "0,100,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_ARRAY, "Bones,bones/"), "set_bone_size", "get_bone_size");
  390. ADD_SIGNAL(MethodInfo("profile_updated"));
  391. BIND_ENUM_CONSTANT(TAIL_DIRECTION_AVERAGE_CHILDREN);
  392. BIND_ENUM_CONSTANT(TAIL_DIRECTION_SPECIFIC_CHILD);
  393. BIND_ENUM_CONSTANT(TAIL_DIRECTION_END);
  394. }
  395. SkeletonProfile::SkeletonProfile() {
  396. }
  397. SkeletonProfile::~SkeletonProfile() {
  398. }
  399. SkeletonProfileHumanoid::SkeletonProfileHumanoid() {
  400. is_read_only = true;
  401. root_bone = "Root";
  402. scale_base_bone = "Hips";
  403. groups.resize(4);
  404. groups.write[0].group_name = "Body";
  405. groups.write[1].group_name = "Face";
  406. groups.write[2].group_name = "LeftHand";
  407. groups.write[3].group_name = "RightHand";
  408. bones.resize(56);
  409. bones.write[0].bone_name = "Root";
  410. bones.write[0].reference_pose = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0);
  411. bones.write[0].handle_offset = Vector2(0.5, 0.91);
  412. bones.write[0].group = "Body";
  413. bones.write[1].bone_name = "Hips";
  414. bones.write[1].bone_parent = "Root";
  415. bones.write[1].tail_direction = TAIL_DIRECTION_SPECIFIC_CHILD;
  416. bones.write[1].bone_tail = "Spine";
  417. bones.write[1].reference_pose = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.75, 0);
  418. bones.write[1].handle_offset = Vector2(0.5, 0.5);
  419. bones.write[1].group = "Body";
  420. bones.write[1].required = true;
  421. bones.write[2].bone_name = "Spine";
  422. bones.write[2].bone_parent = "Hips";
  423. bones.write[2].reference_pose = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.1, 0);
  424. bones.write[2].handle_offset = Vector2(0.5, 0.43);
  425. bones.write[2].group = "Body";
  426. bones.write[2].required = true;
  427. bones.write[3].bone_name = "Chest";
  428. bones.write[3].bone_parent = "Spine";
  429. bones.write[3].reference_pose = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.1, 0);
  430. bones.write[3].handle_offset = Vector2(0.5, 0.36);
  431. bones.write[3].group = "Body";
  432. bones.write[4].bone_name = "UpperChest";
  433. bones.write[4].bone_parent = "Chest";
  434. bones.write[4].reference_pose = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.1, 0);
  435. bones.write[4].handle_offset = Vector2(0.5, 0.29);
  436. bones.write[4].group = "Body";
  437. bones.write[5].bone_name = "Neck";
  438. bones.write[5].bone_parent = "UpperChest";
  439. bones.write[5].tail_direction = TAIL_DIRECTION_SPECIFIC_CHILD;
  440. bones.write[5].bone_tail = "Head";
  441. bones.write[5].reference_pose = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.1, 0);
  442. bones.write[5].handle_offset = Vector2(0.5, 0.23);
  443. bones.write[5].group = "Body";
  444. bones.write[5].required = false;
  445. bones.write[6].bone_name = "Head";
  446. bones.write[6].bone_parent = "Neck";
  447. bones.write[6].tail_direction = TAIL_DIRECTION_END;
  448. bones.write[6].reference_pose = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.1, 0);
  449. bones.write[6].handle_offset = Vector2(0.5, 0.18);
  450. bones.write[6].group = "Body";
  451. bones.write[6].required = true;
  452. bones.write[7].bone_name = "LeftEye";
  453. bones.write[7].bone_parent = "Head";
  454. bones.write[7].reference_pose = Transform3D(1, 0, 0, 0, 0, -1, 0, 1, 0, 0.05, 0.15, 0);
  455. bones.write[7].handle_offset = Vector2(0.6, 0.46);
  456. bones.write[7].group = "Face";
  457. bones.write[8].bone_name = "RightEye";
  458. bones.write[8].bone_parent = "Head";
  459. bones.write[8].reference_pose = Transform3D(1, 0, 0, 0, 0, -1, 0, 1, 0, -0.05, 0.15, 0);
  460. bones.write[8].handle_offset = Vector2(0.37, 0.46);
  461. bones.write[8].group = "Face";
  462. bones.write[9].bone_name = "Jaw";
  463. bones.write[9].bone_parent = "Head";
  464. bones.write[9].reference_pose = Transform3D(-1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0.05, 0.05);
  465. bones.write[9].handle_offset = Vector2(0.46, 0.75);
  466. bones.write[9].group = "Face";
  467. bones.write[10].bone_name = "LeftShoulder";
  468. bones.write[10].bone_parent = "UpperChest";
  469. bones.write[10].reference_pose = Transform3D(0, 1, 0, 0, 0, 1, 1, 0, 0, 0.05, 0.1, 0);
  470. bones.write[10].handle_offset = Vector2(0.55, 0.235);
  471. bones.write[10].group = "Body";
  472. bones.write[10].required = true;
  473. bones.write[11].bone_name = "LeftUpperArm";
  474. bones.write[11].bone_parent = "LeftShoulder";
  475. bones.write[11].reference_pose = Transform3D(-1, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0.05, 0);
  476. bones.write[11].handle_offset = Vector2(0.6, 0.24);
  477. bones.write[11].group = "Body";
  478. bones.write[11].required = true;
  479. bones.write[12].bone_name = "LeftLowerArm";
  480. bones.write[12].bone_parent = "LeftUpperArm";
  481. bones.write[12].reference_pose = Transform3D(0, 0, -1, 0, 1, 0, 1, 0, 0, 0, 0.25, 0);
  482. bones.write[12].handle_offset = Vector2(0.7, 0.24);
  483. bones.write[12].group = "Body";
  484. bones.write[12].required = true;
  485. bones.write[13].bone_name = "LeftHand";
  486. bones.write[13].bone_parent = "LeftLowerArm";
  487. bones.write[13].tail_direction = TAIL_DIRECTION_SPECIFIC_CHILD;
  488. bones.write[13].bone_tail = "LeftMiddleProximal";
  489. bones.write[13].reference_pose = Transform3D(0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 0.25, 0);
  490. bones.write[13].handle_offset = Vector2(0.82, 0.235);
  491. bones.write[13].group = "Body";
  492. bones.write[13].required = true;
  493. bones.write[14].bone_name = "LeftThumbMetacarpal";
  494. bones.write[14].bone_parent = "LeftHand";
  495. bones.write[14].reference_pose = Transform3D(0, -0.577, 0.816, 0, 0.816, 0.577, -1, 0, 0, -0.025, 0.025, 0);
  496. bones.write[14].handle_offset = Vector2(0.4, 0.8);
  497. bones.write[14].group = "LeftHand";
  498. bones.write[15].bone_name = "LeftThumbProximal";
  499. bones.write[15].bone_parent = "LeftThumbMetacarpal";
  500. bones.write[15].reference_pose = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.043, 0);
  501. bones.write[15].handle_offset = Vector2(0.3, 0.69);
  502. bones.write[15].group = "LeftHand";
  503. bones.write[16].bone_name = "LeftThumbDistal";
  504. bones.write[16].bone_parent = "LeftThumbProximal";
  505. bones.write[16].reference_pose = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.043, 0);
  506. bones.write[16].handle_offset = Vector2(0.23, 0.555);
  507. bones.write[16].group = "LeftHand";
  508. bones.write[17].bone_name = "LeftIndexProximal";
  509. bones.write[17].bone_parent = "LeftHand";
  510. bones.write[17].reference_pose = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.025, 0.075, 0);
  511. bones.write[17].handle_offset = Vector2(0.413, 0.52);
  512. bones.write[17].group = "LeftHand";
  513. bones.write[18].bone_name = "LeftIndexIntermediate";
  514. bones.write[18].bone_parent = "LeftIndexProximal";
  515. bones.write[18].reference_pose = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.05, 0);
  516. bones.write[18].handle_offset = Vector2(0.403, 0.36);
  517. bones.write[18].group = "LeftHand";
  518. bones.write[19].bone_name = "LeftIndexDistal";
  519. bones.write[19].bone_parent = "LeftIndexIntermediate";
  520. bones.write[19].reference_pose = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.025, 0);
  521. bones.write[19].handle_offset = Vector2(0.403, 0.255);
  522. bones.write[19].group = "LeftHand";
  523. bones.write[20].bone_name = "LeftMiddleProximal";
  524. bones.write[20].bone_parent = "LeftHand";
  525. bones.write[20].reference_pose = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.075, 0);
  526. bones.write[20].handle_offset = Vector2(0.5, 0.51);
  527. bones.write[20].group = "LeftHand";
  528. bones.write[21].bone_name = "LeftMiddleIntermediate";
  529. bones.write[21].bone_parent = "LeftMiddleProximal";
  530. bones.write[21].reference_pose = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.075, 0);
  531. bones.write[21].handle_offset = Vector2(0.5, 0.345);
  532. bones.write[21].group = "LeftHand";
  533. bones.write[22].bone_name = "LeftMiddleDistal";
  534. bones.write[22].bone_parent = "LeftMiddleIntermediate";
  535. bones.write[22].reference_pose = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.025, 0);
  536. bones.write[22].handle_offset = Vector2(0.5, 0.22);
  537. bones.write[22].group = "LeftHand";
  538. bones.write[23].bone_name = "LeftRingProximal";
  539. bones.write[23].bone_parent = "LeftHand";
  540. bones.write[23].reference_pose = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.025, 0.075, 0);
  541. bones.write[23].handle_offset = Vector2(0.586, 0.52);
  542. bones.write[23].group = "LeftHand";
  543. bones.write[24].bone_name = "LeftRingIntermediate";
  544. bones.write[24].bone_parent = "LeftRingProximal";
  545. bones.write[24].reference_pose = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.05, 0);
  546. bones.write[24].handle_offset = Vector2(0.59, 0.36);
  547. bones.write[24].group = "LeftHand";
  548. bones.write[25].bone_name = "LeftRingDistal";
  549. bones.write[25].bone_parent = "LeftRingIntermediate";
  550. bones.write[25].reference_pose = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.025, 0);
  551. bones.write[25].handle_offset = Vector2(0.591, 0.25);
  552. bones.write[25].group = "LeftHand";
  553. bones.write[26].bone_name = "LeftLittleProximal";
  554. bones.write[26].bone_parent = "LeftHand";
  555. bones.write[26].reference_pose = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.05, 0.05, 0);
  556. bones.write[26].handle_offset = Vector2(0.663, 0.543);
  557. bones.write[26].group = "LeftHand";
  558. bones.write[27].bone_name = "LeftLittleIntermediate";
  559. bones.write[27].bone_parent = "LeftLittleProximal";
  560. bones.write[27].reference_pose = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.05, 0);
  561. bones.write[27].handle_offset = Vector2(0.672, 0.415);
  562. bones.write[27].group = "LeftHand";
  563. bones.write[28].bone_name = "LeftLittleDistal";
  564. bones.write[28].bone_parent = "LeftLittleIntermediate";
  565. bones.write[28].reference_pose = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.025, 0);
  566. bones.write[28].handle_offset = Vector2(0.672, 0.32);
  567. bones.write[28].group = "LeftHand";
  568. bones.write[29].bone_name = "RightShoulder";
  569. bones.write[29].bone_parent = "UpperChest";
  570. bones.write[29].reference_pose = Transform3D(0, -1, 0, 0, 0, 1, -1, 0, 0, -0.05, 0.1, 0);
  571. bones.write[29].handle_offset = Vector2(0.45, 0.235);
  572. bones.write[29].group = "Body";
  573. bones.write[29].required = true;
  574. bones.write[30].bone_name = "RightUpperArm";
  575. bones.write[30].bone_parent = "RightShoulder";
  576. bones.write[30].reference_pose = Transform3D(-1, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0.05, 0);
  577. bones.write[30].handle_offset = Vector2(0.4, 0.24);
  578. bones.write[30].group = "Body";
  579. bones.write[30].required = true;
  580. bones.write[31].bone_name = "RightLowerArm";
  581. bones.write[31].bone_parent = "RightUpperArm";
  582. bones.write[31].reference_pose = Transform3D(0, 0, 1, 0, 1, 0, -1, 0, 0, 0, 0.25, 0);
  583. bones.write[31].handle_offset = Vector2(0.3, 0.24);
  584. bones.write[31].group = "Body";
  585. bones.write[31].required = true;
  586. bones.write[32].bone_name = "RightHand";
  587. bones.write[32].bone_parent = "RightLowerArm";
  588. bones.write[32].tail_direction = TAIL_DIRECTION_SPECIFIC_CHILD;
  589. bones.write[32].bone_tail = "RightMiddleProximal";
  590. bones.write[32].reference_pose = Transform3D(0, 0, -1, 0, 1, 0, 1, 0, 0, 0, 0.25, 0);
  591. bones.write[32].handle_offset = Vector2(0.18, 0.235);
  592. bones.write[32].group = "Body";
  593. bones.write[32].required = true;
  594. bones.write[33].bone_name = "RightThumbMetacarpal";
  595. bones.write[33].bone_parent = "RightHand";
  596. bones.write[33].reference_pose = Transform3D(0, 0.577, -0.816, 0, 0.816, 0.577, 1, 0, 0, 0.025, 0.025, 0);
  597. bones.write[33].handle_offset = Vector2(0.6, 0.8);
  598. bones.write[33].group = "RightHand";
  599. bones.write[34].bone_name = "RightThumbProximal";
  600. bones.write[34].bone_parent = "RightThumbMetacarpal";
  601. bones.write[34].reference_pose = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.043, 0);
  602. bones.write[34].handle_offset = Vector2(0.7, 0.69);
  603. bones.write[34].group = "RightHand";
  604. bones.write[35].bone_name = "RightThumbDistal";
  605. bones.write[35].bone_parent = "RightThumbProximal";
  606. bones.write[35].reference_pose = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.043, 0);
  607. bones.write[35].handle_offset = Vector2(0.77, 0.555);
  608. bones.write[35].group = "RightHand";
  609. bones.write[36].bone_name = "RightIndexProximal";
  610. bones.write[36].bone_parent = "RightHand";
  611. bones.write[36].reference_pose = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.025, 0.075, 0);
  612. bones.write[36].handle_offset = Vector2(0.587, 0.52);
  613. bones.write[36].group = "RightHand";
  614. bones.write[37].bone_name = "RightIndexIntermediate";
  615. bones.write[37].bone_parent = "RightIndexProximal";
  616. bones.write[37].reference_pose = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.05, 0);
  617. bones.write[37].handle_offset = Vector2(0.597, 0.36);
  618. bones.write[37].group = "RightHand";
  619. bones.write[38].bone_name = "RightIndexDistal";
  620. bones.write[38].bone_parent = "RightIndexIntermediate";
  621. bones.write[38].reference_pose = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.025, 0);
  622. bones.write[38].handle_offset = Vector2(0.597, 0.255);
  623. bones.write[38].group = "RightHand";
  624. bones.write[39].bone_name = "RightMiddleProximal";
  625. bones.write[39].bone_parent = "RightHand";
  626. bones.write[39].reference_pose = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.075, 0);
  627. bones.write[39].handle_offset = Vector2(0.5, 0.51);
  628. bones.write[39].group = "RightHand";
  629. bones.write[40].bone_name = "RightMiddleIntermediate";
  630. bones.write[40].bone_parent = "RightMiddleProximal";
  631. bones.write[40].reference_pose = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.075, 0);
  632. bones.write[40].handle_offset = Vector2(0.5, 0.345);
  633. bones.write[40].group = "RightHand";
  634. bones.write[41].bone_name = "RightMiddleDistal";
  635. bones.write[41].bone_parent = "RightMiddleIntermediate";
  636. bones.write[41].reference_pose = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.025, 0);
  637. bones.write[41].handle_offset = Vector2(0.5, 0.22);
  638. bones.write[41].group = "RightHand";
  639. bones.write[42].bone_name = "RightRingProximal";
  640. bones.write[42].bone_parent = "RightHand";
  641. bones.write[42].reference_pose = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.025, 0.075, 0);
  642. bones.write[42].handle_offset = Vector2(0.414, 0.52);
  643. bones.write[42].group = "RightHand";
  644. bones.write[43].bone_name = "RightRingIntermediate";
  645. bones.write[43].bone_parent = "RightRingProximal";
  646. bones.write[43].reference_pose = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.05, 0);
  647. bones.write[43].handle_offset = Vector2(0.41, 0.36);
  648. bones.write[43].group = "RightHand";
  649. bones.write[44].bone_name = "RightRingDistal";
  650. bones.write[44].bone_parent = "RightRingIntermediate";
  651. bones.write[44].reference_pose = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.025, 0);
  652. bones.write[44].handle_offset = Vector2(0.409, 0.25);
  653. bones.write[44].group = "RightHand";
  654. bones.write[45].bone_name = "RightLittleProximal";
  655. bones.write[45].bone_parent = "RightHand";
  656. bones.write[45].reference_pose = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.05, 0.05, 0);
  657. bones.write[45].handle_offset = Vector2(0.337, 0.543);
  658. bones.write[45].group = "RightHand";
  659. bones.write[46].bone_name = "RightLittleIntermediate";
  660. bones.write[46].bone_parent = "RightLittleProximal";
  661. bones.write[46].reference_pose = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.05, 0);
  662. bones.write[46].handle_offset = Vector2(0.328, 0.415);
  663. bones.write[46].group = "RightHand";
  664. bones.write[47].bone_name = "RightLittleDistal";
  665. bones.write[47].bone_parent = "RightLittleIntermediate";
  666. bones.write[47].reference_pose = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.025, 0);
  667. bones.write[47].handle_offset = Vector2(0.328, 0.32);
  668. bones.write[47].group = "RightHand";
  669. bones.write[48].bone_name = "LeftUpperLeg";
  670. bones.write[48].bone_parent = "Hips";
  671. bones.write[48].reference_pose = Transform3D(-1, 0, 0, 0, -1, 0, 0, 0, 1, 0.1, 0, 0);
  672. bones.write[48].handle_offset = Vector2(0.549, 0.49);
  673. bones.write[48].group = "Body";
  674. bones.write[48].required = true;
  675. bones.write[49].bone_name = "LeftLowerLeg";
  676. bones.write[49].bone_parent = "LeftUpperLeg";
  677. bones.write[49].reference_pose = Transform3D(-1, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0.375, 0);
  678. bones.write[49].handle_offset = Vector2(0.548, 0.683);
  679. bones.write[49].group = "Body";
  680. bones.write[49].required = true;
  681. bones.write[50].bone_name = "LeftFoot";
  682. bones.write[50].bone_parent = "LeftLowerLeg";
  683. bones.write[50].reference_pose = Transform3D(-1, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0.375, 0);
  684. bones.write[50].handle_offset = Vector2(0.545, 0.9);
  685. bones.write[50].group = "Body";
  686. bones.write[50].required = true;
  687. bones.write[51].bone_name = "LeftToes";
  688. bones.write[51].bone_parent = "LeftFoot";
  689. bones.write[51].reference_pose = Transform3D(-1, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0.15, 0);
  690. bones.write[51].handle_offset = Vector2(0.545, 0.95);
  691. bones.write[51].group = "Body";
  692. bones.write[52].bone_name = "RightUpperLeg";
  693. bones.write[52].bone_parent = "Hips";
  694. bones.write[52].reference_pose = Transform3D(-1, 0, 0, 0, -1, 0, 0, 0, 1, -0.1, 0, 0);
  695. bones.write[52].handle_offset = Vector2(0.451, 0.49);
  696. bones.write[52].group = "Body";
  697. bones.write[52].required = true;
  698. bones.write[53].bone_name = "RightLowerLeg";
  699. bones.write[53].bone_parent = "RightUpperLeg";
  700. bones.write[53].reference_pose = Transform3D(-1, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0.375, 0);
  701. bones.write[53].handle_offset = Vector2(0.452, 0.683);
  702. bones.write[53].group = "Body";
  703. bones.write[53].required = true;
  704. bones.write[54].bone_name = "RightFoot";
  705. bones.write[54].bone_parent = "RightLowerLeg";
  706. bones.write[54].reference_pose = Transform3D(-1, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0.375, 0);
  707. bones.write[54].handle_offset = Vector2(0.455, 0.9);
  708. bones.write[54].group = "Body";
  709. bones.write[54].required = true;
  710. bones.write[55].bone_name = "RightToes";
  711. bones.write[55].bone_parent = "RightFoot";
  712. bones.write[55].reference_pose = Transform3D(-1, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0.15, 0);
  713. bones.write[55].handle_offset = Vector2(0.455, 0.95);
  714. bones.write[55].group = "Body";
  715. }
  716. SkeletonProfileHumanoid::~SkeletonProfileHumanoid() {
  717. }
  718. //////////////////////////////////////