1 /** 2 A tracked object. 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.arvrpositionaltracker; 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.mesh; 25 import godot.arvrserver; 26 /** 27 A tracked object. 28 29 An instance of this object represents a device that is tracked, such as a controller or anchor point. HMDs aren't represented here as they are handled internally. 30 As controllers are turned on and the AR/VR interface detects them, instances of this object are automatically added to this list of active tracking objects accessible through the $(D ARVRServer). 31 The $(D ARVRController) and $(D ARVRAnchor) both consume objects of this type and should be used in your project. The positional trackers are just under-the-hood objects that make this all work. These are mostly exposed so that GDNative-based interfaces can interact with them. 32 */ 33 @GodotBaseClass struct ARVRPositionalTracker 34 { 35 package(godot) enum string _GODOT_internal_name = "ARVRPositionalTracker"; 36 public: 37 @nogc nothrow: 38 union { /** */ godot_object _godot_object; /** */ GodotObject _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("_set_joy_id") GodotMethod!(void, long) _setJoyId; 46 @GodotName("_set_mesh") GodotMethod!(void, Mesh) _setMesh; 47 @GodotName("_set_name") GodotMethod!(void, String) _setName; 48 @GodotName("_set_orientation") GodotMethod!(void, Basis) _setOrientation; 49 @GodotName("_set_rw_position") GodotMethod!(void, Vector3) _setRwPosition; 50 @GodotName("_set_type") GodotMethod!(void, long) _setType; 51 @GodotName("get_hand") GodotMethod!(ARVRPositionalTracker.TrackerHand) getHand; 52 @GodotName("get_joy_id") GodotMethod!(long) getJoyId; 53 @GodotName("get_mesh") GodotMethod!(Mesh) getMesh; 54 @GodotName("get_name") GodotMethod!(String) getName; 55 @GodotName("get_orientation") GodotMethod!(Basis) getOrientation; 56 @GodotName("get_position") GodotMethod!(Vector3) getPosition; 57 @GodotName("get_rumble") GodotMethod!(double) getRumble; 58 @GodotName("get_tracker_id") GodotMethod!(long) getTrackerId; 59 @GodotName("get_tracks_orientation") GodotMethod!(bool) getTracksOrientation; 60 @GodotName("get_tracks_position") GodotMethod!(bool) getTracksPosition; 61 @GodotName("get_transform") GodotMethod!(Transform, bool) getTransform; 62 @GodotName("get_type") GodotMethod!(ARVRServer.TrackerType) getType; 63 @GodotName("set_rumble") GodotMethod!(void, double) setRumble; 64 } 65 /// 66 pragma(inline, true) bool opEquals(in ARVRPositionalTracker other) const 67 { return _godot_object.ptr is other._godot_object.ptr; } 68 /// 69 pragma(inline, true) typeof(null) opAssign(typeof(null) n) 70 { _godot_object.ptr = n; return null; } 71 /// 72 pragma(inline, true) bool opEquals(typeof(null) n) const 73 { return _godot_object.ptr is n; } 74 /// 75 size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; } 76 mixin baseCasts; 77 /// Construct a new instance of ARVRPositionalTracker. 78 /// Note: use `memnew!ARVRPositionalTracker` instead. 79 static ARVRPositionalTracker _new() 80 { 81 static godot_class_constructor constructor; 82 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("ARVRPositionalTracker"); 83 if(constructor is null) return typeof(this).init; 84 return cast(ARVRPositionalTracker)(constructor()); 85 } 86 @disable new(size_t s); 87 /// 88 enum TrackerHand : int 89 { 90 /** 91 The hand this tracker is held in is unknown or not applicable. 92 */ 93 trackerHandUnknown = 0, 94 /** 95 This tracker is the left hand controller. 96 */ 97 trackerLeftHand = 1, 98 /** 99 This tracker is the right hand controller. 100 */ 101 trackerRightHand = 2, 102 } 103 /// 104 enum Constants : int 105 { 106 trackerHandUnknown = 0, 107 trackerLeftHand = 1, 108 trackerRightHand = 2, 109 } 110 /** 111 112 */ 113 void _setJoyId(in long joy_id) 114 { 115 Array _GODOT_args = Array.make(); 116 _GODOT_args.append(joy_id); 117 String _GODOT_method_name = String("_set_joy_id"); 118 this.callv(_GODOT_method_name, _GODOT_args); 119 } 120 /** 121 122 */ 123 void _setMesh(Mesh mesh) 124 { 125 Array _GODOT_args = Array.make(); 126 _GODOT_args.append(mesh); 127 String _GODOT_method_name = String("_set_mesh"); 128 this.callv(_GODOT_method_name, _GODOT_args); 129 } 130 /** 131 132 */ 133 void _setName(in String name) 134 { 135 Array _GODOT_args = Array.make(); 136 _GODOT_args.append(name); 137 String _GODOT_method_name = String("_set_name"); 138 this.callv(_GODOT_method_name, _GODOT_args); 139 } 140 /** 141 142 */ 143 void _setOrientation(in Basis orientation) 144 { 145 Array _GODOT_args = Array.make(); 146 _GODOT_args.append(orientation); 147 String _GODOT_method_name = String("_set_orientation"); 148 this.callv(_GODOT_method_name, _GODOT_args); 149 } 150 /** 151 152 */ 153 void _setRwPosition(in Vector3 rw_position) 154 { 155 Array _GODOT_args = Array.make(); 156 _GODOT_args.append(rw_position); 157 String _GODOT_method_name = String("_set_rw_position"); 158 this.callv(_GODOT_method_name, _GODOT_args); 159 } 160 /** 161 162 */ 163 void _setType(in long type) 164 { 165 Array _GODOT_args = Array.make(); 166 _GODOT_args.append(type); 167 String _GODOT_method_name = String("_set_type"); 168 this.callv(_GODOT_method_name, _GODOT_args); 169 } 170 /** 171 Returns the hand holding this tracker, if known. See $(D trackerhand) constants. 172 */ 173 ARVRPositionalTracker.TrackerHand getHand() const 174 { 175 checkClassBinding!(typeof(this))(); 176 return ptrcall!(ARVRPositionalTracker.TrackerHand)(GDNativeClassBinding.getHand, _godot_object); 177 } 178 /** 179 If this is a controller that is being tracked, the controller will also be represented by a joystick entry with this ID. 180 */ 181 long getJoyId() const 182 { 183 checkClassBinding!(typeof(this))(); 184 return ptrcall!(long)(GDNativeClassBinding.getJoyId, _godot_object); 185 } 186 /** 187 Returns the mesh related to a controller or anchor point if one is available. 188 */ 189 Ref!Mesh getMesh() const 190 { 191 checkClassBinding!(typeof(this))(); 192 return ptrcall!(Mesh)(GDNativeClassBinding.getMesh, _godot_object); 193 } 194 /** 195 Returns the controller or anchor point's name if available. 196 */ 197 String getName() const 198 { 199 checkClassBinding!(typeof(this))(); 200 return ptrcall!(String)(GDNativeClassBinding.getName, _godot_object); 201 } 202 /** 203 Returns the controller's orientation matrix. 204 */ 205 Basis getOrientation() const 206 { 207 checkClassBinding!(typeof(this))(); 208 return ptrcall!(Basis)(GDNativeClassBinding.getOrientation, _godot_object); 209 } 210 /** 211 Returns the world-space controller position. 212 */ 213 Vector3 getPosition() const 214 { 215 checkClassBinding!(typeof(this))(); 216 return ptrcall!(Vector3)(GDNativeClassBinding.getPosition, _godot_object); 217 } 218 /** 219 220 */ 221 double getRumble() const 222 { 223 checkClassBinding!(typeof(this))(); 224 return ptrcall!(double)(GDNativeClassBinding.getRumble, _godot_object); 225 } 226 /** 227 Returns the internal tracker ID. This uniquely identifies the tracker per tracker type and matches the ID you need to specify for nodes such as the $(D ARVRController) and $(D ARVRAnchor) nodes. 228 */ 229 long getTrackerId() const 230 { 231 checkClassBinding!(typeof(this))(); 232 return ptrcall!(long)(GDNativeClassBinding.getTrackerId, _godot_object); 233 } 234 /** 235 Returns `true` if this device tracks orientation. 236 */ 237 bool getTracksOrientation() const 238 { 239 checkClassBinding!(typeof(this))(); 240 return ptrcall!(bool)(GDNativeClassBinding.getTracksOrientation, _godot_object); 241 } 242 /** 243 Returns `true` if this device tracks position. 244 */ 245 bool getTracksPosition() const 246 { 247 checkClassBinding!(typeof(this))(); 248 return ptrcall!(bool)(GDNativeClassBinding.getTracksPosition, _godot_object); 249 } 250 /** 251 Returns the transform combining this device's orientation and position. 252 */ 253 Transform getTransform(in bool adjust_by_reference_frame) const 254 { 255 checkClassBinding!(typeof(this))(); 256 return ptrcall!(Transform)(GDNativeClassBinding.getTransform, _godot_object, adjust_by_reference_frame); 257 } 258 /** 259 Returns the tracker's type. 260 */ 261 ARVRServer.TrackerType getType() const 262 { 263 checkClassBinding!(typeof(this))(); 264 return ptrcall!(ARVRServer.TrackerType)(GDNativeClassBinding.getType, _godot_object); 265 } 266 /** 267 268 */ 269 void setRumble(in double rumble) 270 { 271 checkClassBinding!(typeof(this))(); 272 ptrcall!(void)(GDNativeClassBinding.setRumble, _godot_object, rumble); 273 } 274 /** 275 The degree to which the tracker rumbles. Ranges from `0.0` to `1.0` with precision `.01`. 276 */ 277 @property double rumble() 278 { 279 return getRumble(); 280 } 281 /// ditto 282 @property void rumble(double v) 283 { 284 setRumble(v); 285 } 286 }