1 /**
2 This is our AR/VR Server.
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.arvrserver;
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.arvrinterface;
23 import godot.arvrpositionaltracker;
24 /**
25 This is our AR/VR Server.
26 
27 The AR/VR Server is the heart of our AR/VR solution and handles all the processing.
28 */
29 @GodotBaseClass struct ARVRServerSingleton
30 {
31 	enum string _GODOT_internal_name = "ARVRServer";
32 public:
33 @nogc nothrow:
34 	union { godot_object _godot_object; GodotObject _GODOT_base; }
35 	alias _GODOT_base this;
36 	alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses);
37 	package(godot) __gshared bool _classBindingInitialized = false;
38 	package(godot) static struct _classBinding
39 	{
40 		__gshared:
41 		godot_object _singleton;
42 		immutable char* _singletonName = "ARVRServer";
43 		@GodotName("get_world_scale") GodotMethod!(double) getWorldScale;
44 		@GodotName("set_world_scale") GodotMethod!(void, double) setWorldScale;
45 		@GodotName("get_reference_frame") GodotMethod!(Transform) getReferenceFrame;
46 		@GodotName("center_on_hmd") GodotMethod!(void, long, bool) centerOnHmd;
47 		@GodotName("get_hmd_transform") GodotMethod!(Transform) getHmdTransform;
48 		@GodotName("get_interface_count") GodotMethod!(long) getInterfaceCount;
49 		@GodotName("get_interface") GodotMethod!(ARVRInterface, long) getInterface;
50 		@GodotName("get_interfaces") GodotMethod!(Array) getInterfaces;
51 		@GodotName("find_interface") GodotMethod!(ARVRInterface, String) findInterface;
52 		@GodotName("get_tracker_count") GodotMethod!(long) getTrackerCount;
53 		@GodotName("get_tracker") GodotMethod!(ARVRPositionalTracker, long) getTracker;
54 		@GodotName("get_primary_interface") GodotMethod!(ARVRInterface) getPrimaryInterface;
55 		@GodotName("set_primary_interface") GodotMethod!(void, ARVRInterface) setPrimaryInterface;
56 		@GodotName("get_last_process_usec") GodotMethod!(long) getLastProcessUsec;
57 		@GodotName("get_last_commit_usec") GodotMethod!(long) getLastCommitUsec;
58 		@GodotName("get_last_frame_usec") GodotMethod!(long) getLastFrameUsec;
59 	}
60 	bool opEquals(in ARVRServerSingleton other) const { return _godot_object.ptr is other._godot_object.ptr; }
61 	ARVRServerSingleton opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; }
62 	bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; }
63 	mixin baseCasts;
64 	static ARVRServerSingleton _new()
65 	{
66 		static godot_class_constructor constructor;
67 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("ARVRServer");
68 		if(constructor is null) return typeof(this).init;
69 		return cast(ARVRServerSingleton)(constructor());
70 	}
71 	@disable new(size_t s);
72 	/// 
73 	enum RotationMode : int
74 	{
75 		/**
76 		Fully reset the orientation of the HMD. Regardless of what direction the user is looking to in the real world. The user will look dead ahead in the virtual world.
77 		*/
78 		resetFullRotation = 0,
79 		/**
80 		Resets the orientation but keeps the tilt of the device. So if we're looking down, we keep looking down but heading will be reset.
81 		*/
82 		resetButKeepTilt = 1,
83 		/**
84 		Does not reset the orientation of the HMD, only the position of the player gets centered.
85 		*/
86 		dontResetRotation = 2,
87 	}
88 	/// 
89 	enum TrackerType : int
90 	{
91 		/**
92 		Our tracker tracks the location of a controller.
93 		*/
94 		trackerController = 1,
95 		/**
96 		Our tracker tracks the location of a base station.
97 		*/
98 		trackerBasestation = 2,
99 		/**
100 		Our tracker tracks the location and size of an AR anchor.
101 		*/
102 		trackerAnchor = 4,
103 		/**
104 		Used internally to filter trackers of any known type.
105 		*/
106 		trackerAnyKnown = 127,
107 		/**
108 		Used internally if we haven't set the tracker type yet.
109 		*/
110 		trackerUnknown = 128,
111 		/**
112 		Used internally to select all trackers.
113 		*/
114 		trackerAny = 255,
115 	}
116 	/// 
117 	enum Constants : int
118 	{
119 		resetFullRotation = 0,
120 		resetButKeepTilt = 1,
121 		trackerController = 1,
122 		dontResetRotation = 2,
123 		trackerBasestation = 2,
124 		trackerAnchor = 4,
125 		trackerAnyKnown = 127,
126 		trackerUnknown = 128,
127 		trackerAny = 255,
128 	}
129 	/**
130 	
131 	*/
132 	double getWorldScale() const
133 	{
134 		checkClassBinding!(typeof(this))();
135 		return ptrcall!(double)(_classBinding.getWorldScale, _godot_object);
136 	}
137 	/**
138 	
139 	*/
140 	void setWorldScale(in double arg0)
141 	{
142 		checkClassBinding!(typeof(this))();
143 		ptrcall!(void)(_classBinding.setWorldScale, _godot_object, arg0);
144 	}
145 	/**
146 	Gets our reference frame transform, mostly used internally and exposed for GDNative build interfaces.
147 	*/
148 	Transform getReferenceFrame() const
149 	{
150 		checkClassBinding!(typeof(this))();
151 		return ptrcall!(Transform)(_classBinding.getReferenceFrame, _godot_object);
152 	}
153 	/**
154 	This is a really important function to understand correctly. AR and VR platforms all handle positioning slightly differently.
155 	For platforms that do not offer spatial tracking our origin point (0,0,0) is the location of our HMD but you have little control over the direction the player is facing in the real world.
156 	For platforms that do offer spatial tracking our origin point depends very much on the system. For OpenVR our origin point is usually the center of the tracking space, on the ground. For other platforms its often the location of the tracking camera.
157 	This method allows you to center our tracker on the location of the HMD, it will take the current location of the HMD and use that to adjust all our tracking data in essence realigning the real world to your players current position in your game world.
158 	For this method to produce usable results tracking information should be available and this often takes a few frames after starting your game.
159 	You should call this method after a few seconds have passed, when the user requests a realignment of the display holding a designated button on a controller for a short period of time, and when implementing a teleport mechanism.
160 	*/
161 	void centerOnHmd(in long rotation_mode, in bool keep_height)
162 	{
163 		checkClassBinding!(typeof(this))();
164 		ptrcall!(void)(_classBinding.centerOnHmd, _godot_object, rotation_mode, keep_height);
165 	}
166 	/**
167 	Returns the primary interface's transformation.
168 	*/
169 	Transform getHmdTransform()
170 	{
171 		checkClassBinding!(typeof(this))();
172 		return ptrcall!(Transform)(_classBinding.getHmdTransform, _godot_object);
173 	}
174 	/**
175 	Get the number of interfaces currently registered with the AR/VR server. If you're game supports multiple AR/VR platforms you can look through the available interface and either present the user with a selection or simply try an initialize each interface and use the first one that returns true.
176 	*/
177 	long getInterfaceCount() const
178 	{
179 		checkClassBinding!(typeof(this))();
180 		return ptrcall!(long)(_classBinding.getInterfaceCount, _godot_object);
181 	}
182 	/**
183 	Get the interface registered at a given index in our list of interfaces.
184 	*/
185 	Ref!ARVRInterface getInterface(in long idx) const
186 	{
187 		checkClassBinding!(typeof(this))();
188 		return ptrcall!(ARVRInterface)(_classBinding.getInterface, _godot_object, idx);
189 	}
190 	/**
191 	Returns a list of available interfaces with both id and name of the interface.
192 	*/
193 	Array getInterfaces() const
194 	{
195 		checkClassBinding!(typeof(this))();
196 		return ptrcall!(Array)(_classBinding.getInterfaces, _godot_object);
197 	}
198 	/**
199 	Find an interface by its name. Say that you're making a game that uses specific capabilities of an AR/VR platform you can find the interface for that platform by name and initialize it.
200 	*/
201 	Ref!ARVRInterface findInterface(StringArg0)(in StringArg0 name) const
202 	{
203 		checkClassBinding!(typeof(this))();
204 		return ptrcall!(ARVRInterface)(_classBinding.findInterface, _godot_object, name);
205 	}
206 	/**
207 	Get the number of trackers currently registered.
208 	*/
209 	long getTrackerCount() const
210 	{
211 		checkClassBinding!(typeof(this))();
212 		return ptrcall!(long)(_classBinding.getTrackerCount, _godot_object);
213 	}
214 	/**
215 	Get the positional tracker at the given ID.
216 	*/
217 	ARVRPositionalTracker getTracker(in long idx) const
218 	{
219 		checkClassBinding!(typeof(this))();
220 		return ptrcall!(ARVRPositionalTracker)(_classBinding.getTracker, _godot_object, idx);
221 	}
222 	/**
223 	
224 	*/
225 	Ref!ARVRInterface getPrimaryInterface() const
226 	{
227 		checkClassBinding!(typeof(this))();
228 		return ptrcall!(ARVRInterface)(_classBinding.getPrimaryInterface, _godot_object);
229 	}
230 	/**
231 	
232 	*/
233 	void setPrimaryInterface(ARVRInterface _interface)
234 	{
235 		checkClassBinding!(typeof(this))();
236 		ptrcall!(void)(_classBinding.setPrimaryInterface, _godot_object, _interface);
237 	}
238 	/**
239 	
240 	*/
241 	long getLastProcessUsec()
242 	{
243 		checkClassBinding!(typeof(this))();
244 		return ptrcall!(long)(_classBinding.getLastProcessUsec, _godot_object);
245 	}
246 	/**
247 	
248 	*/
249 	long getLastCommitUsec()
250 	{
251 		checkClassBinding!(typeof(this))();
252 		return ptrcall!(long)(_classBinding.getLastCommitUsec, _godot_object);
253 	}
254 	/**
255 	
256 	*/
257 	long getLastFrameUsec()
258 	{
259 		checkClassBinding!(typeof(this))();
260 		return ptrcall!(long)(_classBinding.getLastFrameUsec, _godot_object);
261 	}
262 	/**
263 	Allows you to adjust the scale to your game's units. Most AR/VR platforms assume a scale of 1 game world unit = 1 meter in the real world.
264 	*/
265 	@property double worldScale()
266 	{
267 		return getWorldScale();
268 	}
269 	/// ditto
270 	@property void worldScale(double v)
271 	{
272 		setWorldScale(v);
273 	}
274 	/**
275 	
276 	*/
277 	@property ARVRInterface primaryInterface()
278 	{
279 		return getPrimaryInterface();
280 	}
281 	/// ditto
282 	@property void primaryInterface(ARVRInterface v)
283 	{
284 		setPrimaryInterface(v);
285 	}
286 }
287 /// Returns: the ARVRServerSingleton
288 @property @nogc nothrow pragma(inline, true)
289 ARVRServerSingleton ARVRServer()
290 {
291 	checkClassBinding!ARVRServerSingleton();
292 	return ARVRServerSingleton(ARVRServerSingleton._classBinding._singleton);
293 }