1 /** 2 A twist joint between two 3D PhysicsBodies. 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.conetwistjoint; 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.joint; 25 /** 26 A twist joint between two 3D PhysicsBodies. 27 28 The joint can rotate the bodies across an axis defined by the local x-axes of the $(D Joint). 29 The twist axis is initiated as the X axis of the $(D Joint). 30 Once the Bodies swing, the twist axis is calculated as the middle of the x-axes of the Joint in the local space of the two Bodies. See also $(D Generic6DOFJoint). 31 */ 32 @GodotBaseClass struct ConeTwistJoint 33 { 34 package(godot) enum string _GODOT_internal_name = "ConeTwistJoint"; 35 public: 36 @nogc nothrow: 37 union { /** */ godot_object _godot_object; /** */ Joint _GODOT_base; } 38 alias _GODOT_base this; 39 alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses); 40 package(godot) __gshared bool _classBindingInitialized = false; 41 package(godot) static struct GDNativeClassBinding 42 { 43 __gshared: 44 @GodotName("_get_swing_span") GodotMethod!(double) _getSwingSpan; 45 @GodotName("_get_twist_span") GodotMethod!(double) _getTwistSpan; 46 @GodotName("_set_swing_span") GodotMethod!(void, double) _setSwingSpan; 47 @GodotName("_set_twist_span") GodotMethod!(void, double) _setTwistSpan; 48 @GodotName("get_param") GodotMethod!(double, long) getParam; 49 @GodotName("set_param") GodotMethod!(void, long, double) setParam; 50 } 51 /// 52 pragma(inline, true) bool opEquals(in ConeTwistJoint other) const 53 { return _godot_object.ptr is other._godot_object.ptr; } 54 /// 55 pragma(inline, true) typeof(null) opAssign(typeof(null) n) 56 { _godot_object.ptr = n; return null; } 57 /// 58 pragma(inline, true) bool opEquals(typeof(null) n) const 59 { return _godot_object.ptr is n; } 60 /// 61 size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; } 62 mixin baseCasts; 63 /// Construct a new instance of ConeTwistJoint. 64 /// Note: use `memnew!ConeTwistJoint` instead. 65 static ConeTwistJoint _new() 66 { 67 static godot_class_constructor constructor; 68 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("ConeTwistJoint"); 69 if(constructor is null) return typeof(this).init; 70 return cast(ConeTwistJoint)(constructor()); 71 } 72 @disable new(size_t s); 73 /// 74 enum Param : int 75 { 76 /** 77 Swing is rotation from side to side, around the axis perpendicular to the twist axis. 78 The swing span defines, how much rotation will not get corrected along the swing axis. 79 Could be defined as looseness in the $(D ConeTwistJoint). 80 If below 0.05, this behavior is locked. 81 */ 82 paramSwingSpan = 0, 83 /** 84 Twist is the rotation around the twist axis, this value defined how far the joint can twist. 85 Twist is locked if below 0.05. 86 */ 87 paramTwistSpan = 1, 88 /** 89 The speed with which the swing or twist will take place. 90 The higher, the faster. 91 */ 92 paramBias = 2, 93 /** 94 The ease with which the joint starts to twist. If it's too low, it takes more force to start twisting the joint. 95 */ 96 paramSoftness = 3, 97 /** 98 Defines, how fast the swing- and twist-speed-difference on both sides gets synced. 99 */ 100 paramRelaxation = 4, 101 /** 102 Represents the size of the $(D param) enum. 103 */ 104 paramMax = 5, 105 } 106 /// 107 enum Constants : int 108 { 109 paramSwingSpan = 0, 110 paramTwistSpan = 1, 111 paramBias = 2, 112 paramSoftness = 3, 113 paramRelaxation = 4, 114 paramMax = 5, 115 } 116 /** 117 118 */ 119 double _getSwingSpan() const 120 { 121 Array _GODOT_args = Array.make(); 122 String _GODOT_method_name = String("_get_swing_span"); 123 return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!double); 124 } 125 /** 126 127 */ 128 double _getTwistSpan() const 129 { 130 Array _GODOT_args = Array.make(); 131 String _GODOT_method_name = String("_get_twist_span"); 132 return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!double); 133 } 134 /** 135 136 */ 137 void _setSwingSpan(in double swing_span) 138 { 139 Array _GODOT_args = Array.make(); 140 _GODOT_args.append(swing_span); 141 String _GODOT_method_name = String("_set_swing_span"); 142 this.callv(_GODOT_method_name, _GODOT_args); 143 } 144 /** 145 146 */ 147 void _setTwistSpan(in double twist_span) 148 { 149 Array _GODOT_args = Array.make(); 150 _GODOT_args.append(twist_span); 151 String _GODOT_method_name = String("_set_twist_span"); 152 this.callv(_GODOT_method_name, _GODOT_args); 153 } 154 /** 155 156 */ 157 double getParam(in long param) const 158 { 159 checkClassBinding!(typeof(this))(); 160 return ptrcall!(double)(GDNativeClassBinding.getParam, _godot_object, param); 161 } 162 /** 163 164 */ 165 void setParam(in long param, in double value) 166 { 167 checkClassBinding!(typeof(this))(); 168 ptrcall!(void)(GDNativeClassBinding.setParam, _godot_object, param, value); 169 } 170 /** 171 The speed with which the swing or twist will take place. 172 The higher, the faster. 173 */ 174 @property double bias() 175 { 176 return getParam(2); 177 } 178 /// ditto 179 @property void bias(double v) 180 { 181 setParam(2, v); 182 } 183 /** 184 Defines, how fast the swing- and twist-speed-difference on both sides gets synced. 185 */ 186 @property double relaxation() 187 { 188 return getParam(4); 189 } 190 /// ditto 191 @property void relaxation(double v) 192 { 193 setParam(4, v); 194 } 195 /** 196 The ease with which the joint starts to twist. If it's too low, it takes more force to start twisting the joint. 197 */ 198 @property double softness() 199 { 200 return getParam(3); 201 } 202 /// ditto 203 @property void softness(double v) 204 { 205 setParam(3, v); 206 } 207 /** 208 Swing is rotation from side to side, around the axis perpendicular to the twist axis. 209 The swing span defines, how much rotation will not get corrected along the swing axis. 210 Could be defined as looseness in the $(D ConeTwistJoint). 211 If below 0.05, this behavior is locked. 212 */ 213 @property double swingSpan() 214 { 215 return _getSwingSpan(); 216 } 217 /// ditto 218 @property void swingSpan(double v) 219 { 220 _setSwingSpan(v); 221 } 222 /** 223 Twist is the rotation around the twist axis, this value defined how far the joint can twist. 224 Twist is locked if below 0.05. 225 */ 226 @property double twistSpan() 227 { 228 return _getTwistSpan(); 229 } 230 /// ditto 231 @property void twistSpan(double v) 232 { 233 _setTwistSpan(v); 234 } 235 }