1 /** 2 Joint used with $(D Skeleton2D) to control and animate other nodes. 3 4 Copyright: 5 Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. 6 Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) 7 Copyright (c) 2017-2018 Godot-D contributors 8 9 License: $(LINK2 https://opensource.org/licenses/MIT, MIT License) 10 11 12 */ 13 module godot.bone2d; 14 import std.meta : AliasSeq, staticIndexOf; 15 import std.traits : Unqual; 16 import godot.d.traits; 17 import godot.core; 18 import godot.c; 19 import godot.d.bind; 20 import godot.d.reference; 21 import godot.globalenums; 22 import godot.object; 23 import godot.classdb; 24 import godot.node2d; 25 /** 26 Joint used with $(D Skeleton2D) to control and animate other nodes. 27 28 Use a hierarchy of `Bone2D` bound to a $(D Skeleton2D) to control, and animate other $(D Node2D) nodes. 29 You can use `Bone2D` and `Skeleton2D` nodes to animate 2D meshes created with the Polygon 2D UV editor. 30 Each bone has a $(D rest) transform that you can reset to with $(D applyRest). These rest poses are relative to the bone's parent. 31 If in the editor, you can set the rest pose of an entire skeleton using a menu option, from the code, you need to iterate over the bones to set their individual rest poses. 32 */ 33 @GodotBaseClass struct Bone2D 34 { 35 package(godot) enum string _GODOT_internal_name = "Bone2D"; 36 public: 37 @nogc nothrow: 38 union { /** */ godot_object _godot_object; /** */ Node2D _GODOT_base; } 39 alias _GODOT_base this; 40 alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses); 41 package(godot) __gshared bool _classBindingInitialized = false; 42 package(godot) static struct GDNativeClassBinding 43 { 44 __gshared: 45 @GodotName("apply_rest") GodotMethod!(void) applyRest; 46 @GodotName("get_default_length") GodotMethod!(double) getDefaultLength; 47 @GodotName("get_index_in_skeleton") GodotMethod!(long) getIndexInSkeleton; 48 @GodotName("get_rest") GodotMethod!(Transform2D) getRest; 49 @GodotName("get_skeleton_rest") GodotMethod!(Transform2D) getSkeletonRest; 50 @GodotName("set_default_length") GodotMethod!(void, double) setDefaultLength; 51 @GodotName("set_rest") GodotMethod!(void, Transform2D) setRest; 52 } 53 /// 54 pragma(inline, true) bool opEquals(in Bone2D other) const 55 { return _godot_object.ptr is other._godot_object.ptr; } 56 /// 57 pragma(inline, true) typeof(null) opAssign(typeof(null) n) 58 { _godot_object.ptr = n; return null; } 59 /// 60 pragma(inline, true) bool opEquals(typeof(null) n) const 61 { return _godot_object.ptr is n; } 62 /// 63 size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; } 64 mixin baseCasts; 65 /// Construct a new instance of Bone2D. 66 /// Note: use `memnew!Bone2D` instead. 67 static Bone2D _new() 68 { 69 static godot_class_constructor constructor; 70 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("Bone2D"); 71 if(constructor is null) return typeof(this).init; 72 return cast(Bone2D)(constructor()); 73 } 74 @disable new(size_t s); 75 /** 76 Stores the node's current transforms in $(D rest). 77 */ 78 void applyRest() 79 { 80 checkClassBinding!(typeof(this))(); 81 ptrcall!(void)(GDNativeClassBinding.applyRest, _godot_object); 82 } 83 /** 84 85 */ 86 double getDefaultLength() const 87 { 88 checkClassBinding!(typeof(this))(); 89 return ptrcall!(double)(GDNativeClassBinding.getDefaultLength, _godot_object); 90 } 91 /** 92 Returns the node's index as part of the entire skeleton. See $(D Skeleton2D). 93 */ 94 long getIndexInSkeleton() const 95 { 96 checkClassBinding!(typeof(this))(); 97 return ptrcall!(long)(GDNativeClassBinding.getIndexInSkeleton, _godot_object); 98 } 99 /** 100 101 */ 102 Transform2D getRest() const 103 { 104 checkClassBinding!(typeof(this))(); 105 return ptrcall!(Transform2D)(GDNativeClassBinding.getRest, _godot_object); 106 } 107 /** 108 Returns the node's $(D rest) `Transform2D` if it doesn't have a parent, or its rest pose relative to its parent. 109 */ 110 Transform2D getSkeletonRest() const 111 { 112 checkClassBinding!(typeof(this))(); 113 return ptrcall!(Transform2D)(GDNativeClassBinding.getSkeletonRest, _godot_object); 114 } 115 /** 116 117 */ 118 void setDefaultLength(in double default_length) 119 { 120 checkClassBinding!(typeof(this))(); 121 ptrcall!(void)(GDNativeClassBinding.setDefaultLength, _godot_object, default_length); 122 } 123 /** 124 125 */ 126 void setRest(in Transform2D rest) 127 { 128 checkClassBinding!(typeof(this))(); 129 ptrcall!(void)(GDNativeClassBinding.setRest, _godot_object, rest); 130 } 131 /** 132 Length of the bone's representation drawn in the editor's viewport in pixels. 133 */ 134 @property double defaultLength() 135 { 136 return getDefaultLength(); 137 } 138 /// ditto 139 @property void defaultLength(double v) 140 { 141 setDefaultLength(v); 142 } 143 /** 144 Rest transform of the bone. You can reset the node's transforms to this value using $(D applyRest). 145 */ 146 @property Transform2D rest() 147 { 148 return getRest(); 149 } 150 /// ditto 151 @property void rest(Transform2D v) 152 { 153 setRest(v); 154 } 155 }