1 /**
2 An 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.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.spatial;
25 import godot.mesh;
26 /**
27 An anchor point in AR space.
28 
29 The $(D ARVRAnchor) 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.
30 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; the nodes will simply remain on 0,0,0 until a plane is recognized.
31 Keep in mind that, as long as plane detection is enabled, the size, placing and orientation of an anchor will be updated as the detection logic learns more about the real world out there especially if only part of the surface is in view.
32 */
33 @GodotBaseClass struct ARVRAnchor
34 {
35 	package(godot) enum string _GODOT_internal_name = "ARVRAnchor";
36 public:
37 @nogc nothrow:
38 	union { /** */ godot_object _godot_object; /** */ Spatial _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("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_mesh") GodotMethod!(Mesh) getMesh;
49 		@GodotName("get_plane") GodotMethod!(Plane) getPlane;
50 		@GodotName("get_size") GodotMethod!(Vector3) getSize;
51 		@GodotName("set_anchor_id") GodotMethod!(void, long) setAnchorId;
52 	}
53 	/// 
54 	pragma(inline, true) bool opEquals(in ARVRAnchor 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 ARVRAnchor.
66 	/// Note: use `memnew!ARVRAnchor` instead.
67 	static ARVRAnchor _new()
68 	{
69 		static godot_class_constructor constructor;
70 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("ARVRAnchor");
71 		if(constructor is null) return typeof(this).init;
72 		return cast(ARVRAnchor)(constructor());
73 	}
74 	@disable new(size_t s);
75 	/**
76 	
77 	*/
78 	long getAnchorId() const
79 	{
80 		checkClassBinding!(typeof(this))();
81 		return ptrcall!(long)(GDNativeClassBinding.getAnchorId, _godot_object);
82 	}
83 	/**
84 	Returns the name given to this anchor.
85 	*/
86 	String getAnchorName() const
87 	{
88 		checkClassBinding!(typeof(this))();
89 		return ptrcall!(String)(GDNativeClassBinding.getAnchorName, _godot_object);
90 	}
91 	/**
92 	Returns `true` if the anchor is being tracked and `false` if no anchor with this ID is currently known.
93 	*/
94 	bool getIsActive() const
95 	{
96 		checkClassBinding!(typeof(this))();
97 		return ptrcall!(bool)(GDNativeClassBinding.getIsActive, _godot_object);
98 	}
99 	/**
100 	If provided by the $(D ARVRInterface), this returns a mesh object for the anchor. For an anchor, this can be a shape related to the object being tracked or it can be a mesh that provides topology related to the anchor and can be used to create shadows/reflections on surfaces or for generating collision shapes.
101 	*/
102 	Ref!Mesh getMesh() const
103 	{
104 		checkClassBinding!(typeof(this))();
105 		return ptrcall!(Mesh)(GDNativeClassBinding.getMesh, _godot_object);
106 	}
107 	/**
108 	Returns a plane aligned with our anchor; handy for intersection testing.
109 	*/
110 	Plane getPlane() const
111 	{
112 		checkClassBinding!(typeof(this))();
113 		return ptrcall!(Plane)(GDNativeClassBinding.getPlane, _godot_object);
114 	}
115 	/**
116 	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.
117 	*/
118 	Vector3 getSize() const
119 	{
120 		checkClassBinding!(typeof(this))();
121 		return ptrcall!(Vector3)(GDNativeClassBinding.getSize, _godot_object);
122 	}
123 	/**
124 	
125 	*/
126 	void setAnchorId(in long anchor_id)
127 	{
128 		checkClassBinding!(typeof(this))();
129 		ptrcall!(void)(GDNativeClassBinding.setAnchorId, _godot_object, anchor_id);
130 	}
131 	/**
132 	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.
133 	*/
134 	@property long anchorId()
135 	{
136 		return getAnchorId();
137 	}
138 	/// ditto
139 	@property void anchorId(long v)
140 	{
141 		setAnchorId(v);
142 	}
143 }