1 /** 2 Anchor point in AR Space. 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.arvranchor; 14 import std.meta : AliasSeq, staticIndexOf; 15 import std.traits : Unqual; 16 import godot.d.meta; 17 import godot.core; 18 import godot.c; 19 import godot.d.bind; 20 import godot.d.reference; 21 import godot.object; 22 import godot.classdb; 23 import godot.spatial; 24 import godot.node; 25 /** 26 Anchor point in AR Space. 27 28 The ARVR Anchor point is a spatial node that maps a real world location identified by the AR platform to a position within the game world. For example, as long as plane detection in ARKit is on, ARKit will identify and update the position of planes (tables, floors, etc) and create anchors for them. 29 This node is mapped to one of the anchors through its unique id. When you receive a signal that a new anchor is available you should add this node to your scene for that anchor. You can predefine nodes and set the id and the nodes will simply remain on 0,0,0 until a plane is recognised. 30 Keep in mind that as long as plane detection is enable the size, placing and orientation of an anchor will be updates as the detection logic learns more about the real world out there especially if only part of the surface is in view. 31 */ 32 @GodotBaseClass struct ARVRAnchor 33 { 34 enum string _GODOT_internal_name = "ARVRAnchor"; 35 public: 36 @nogc nothrow: 37 union { godot_object _godot_object; Spatial _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 _classBinding 42 { 43 __gshared: 44 @GodotName("set_anchor_id") GodotMethod!(void, long) setAnchorId; 45 @GodotName("get_anchor_id") GodotMethod!(long) getAnchorId; 46 @GodotName("get_anchor_name") GodotMethod!(String) getAnchorName; 47 @GodotName("get_is_active") GodotMethod!(bool) getIsActive; 48 @GodotName("get_size") GodotMethod!(Vector3) getSize; 49 @GodotName("get_plane") GodotMethod!(Plane) getPlane; 50 } 51 bool opEquals(in ARVRAnchor other) const { return _godot_object.ptr is other._godot_object.ptr; } 52 ARVRAnchor opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; } 53 bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; } 54 mixin baseCasts; 55 static ARVRAnchor _new() 56 { 57 static godot_class_constructor constructor; 58 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("ARVRAnchor"); 59 if(constructor is null) return typeof(this).init; 60 return cast(ARVRAnchor)(constructor()); 61 } 62 @disable new(size_t s); 63 /** 64 65 */ 66 void setAnchorId(in long anchor_id) 67 { 68 checkClassBinding!(typeof(this))(); 69 ptrcall!(void)(_classBinding.setAnchorId, _godot_object, anchor_id); 70 } 71 /** 72 73 */ 74 long getAnchorId() const 75 { 76 checkClassBinding!(typeof(this))(); 77 return ptrcall!(long)(_classBinding.getAnchorId, _godot_object); 78 } 79 /** 80 Returns the name given to this anchor. 81 */ 82 String getAnchorName() const 83 { 84 checkClassBinding!(typeof(this))(); 85 return ptrcall!(String)(_classBinding.getAnchorName, _godot_object); 86 } 87 /** 88 Returns true if the anchor is being tracked and false if no anchor with this id is currently known. 89 */ 90 bool getIsActive() const 91 { 92 checkClassBinding!(typeof(this))(); 93 return ptrcall!(bool)(_classBinding.getIsActive, _godot_object); 94 } 95 /** 96 Returns the estimated size of the plane that was detected. Say when the anchor relates to a table in the real world, this is the estimated size of the surface of that table. 97 */ 98 Vector3 getSize() const 99 { 100 checkClassBinding!(typeof(this))(); 101 return ptrcall!(Vector3)(_classBinding.getSize, _godot_object); 102 } 103 /** 104 Returns a plane aligned with our anchor, handy for intersection testing 105 */ 106 Plane getPlane() const 107 { 108 checkClassBinding!(typeof(this))(); 109 return ptrcall!(Plane)(_classBinding.getPlane, _godot_object); 110 } 111 /** 112 The anchor's id. You can set this before the anchor itself exists. The first anchor gets an id of `1`, the second an id of `2`, etc. When anchors get removed, the engine can then assign the corresponding id to new anchors. The most common situation where anchors 'disappear' is when the AR server identifies that two anchors represent different parts of the same plane and merges them. 113 */ 114 @property long anchorId() 115 { 116 return getAnchorId(); 117 } 118 /// ditto 119 @property void anchorId(long v) 120 { 121 setAnchorId(v); 122 } 123 }